Package com.tnsai.payment.x402
Interface Wallet
- All Known Implementing Classes:
InMemoryWallet,Web3jWallet
public interface Wallet
Signing surface the x402 payment broker needs.
Mirrors the FeedbackCollector / PromptInjectionDetector SPI shape
elsewhere in the framework: a public interface plus a nested
Wallet.Factory interface that can be discovered via
ServiceLoader. This keeps the broker decoupled from any single
key-management strategy — agents can plug in env-keystore wallets, KMS
wallets, hardware wallets, or a remote-signing daemon without the
broker code changing.
What an implementation must do
- Expose the wallet's
address()(lowercase0x...hex string, 42 chars for EVM addresses). - Report the
network()the wallet is bound to. A wallet is single-network on purpose — keeps the chain-id check at sign time honest and stops cross-chain replay accidents. - Sign a prepared
EIP712TypedDatadigest pair and return 65 bytes (r || s || v) for EVM family or 64 bytes (R || s) for SVM family.
Thread safety
Implementations must be safe to call from multiple threads — agents often run concurrent settlements. Stateless wrappers around a fixed key are fine; backends that talk to remote signers should serialise around their own client.Discovery
// resources/META-INF/services/com.tnsai.payment.x402.Wallet$Factory com.example.kms.AwsKmsWalletFactoryThen call
Wallet.Factory.discover() to retrieve the first registered
factory on the classpath (or Optional.empty() if none ship).- Since:
- 0.10.5 (TNS-449 P2)
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceFactory that turns aWalletSpecinto a liveWallet. -
Method Summary
-
Method Details
-
address
String address()Lowercase0x...hex address. EVM addresses are 42 chars. -
network
Network network()Network the wallet is bound to. Cross-network use is not supported. -
signTypedData
Produce a signature over the EIP-712 digest implied bytd.- Parameters:
td- prepared domain-separator + struct-hash pair- Returns:
- 65 bytes for EVM (
r || s || v), 64 for SVM - Throws:
NullPointerException- iftdis null
-