Package com.tnsai.payment.x402
Class InMemoryWallet
java.lang.Object
com.tnsai.payment.x402.InMemoryWallet
- All Implemented Interfaces:
Wallet
Test-only
Wallet that never touches real cryptography.
What it does
- Holds a fixed
0x...address and aNetwork. signTypedData(EIP712TypedData)returns a deterministic 65-byte (EVM) or 64-byte (SVM) array computed asSHA-256(address || domainSeparator || structHash)padded to the requested length. The output looks like a signature byte-shape-wise but is not verifiable on any chain.
Why it exists
Two reasons:- Unit tests of the broker layer need a
Walletthey can call without a private key or a network. The deterministic output lets tests assert "the broker passed the right digest" without hard-coding a signature value. - The SPI's "what does an implementation look like" reference — anything trickier than this would obscure the shape.
What it is NOT
Not for production. Not for testnet either — its output won't pass any real facilitator's signature check. Any code path that constructs anInMemoryWallet and ships to mainnet has a bug, and the class
name is meant to make that bug visible at code review.- Since:
- 0.10.5 (TNS-449 P2)
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.tnsai.payment.x402.Wallet
Wallet.Factory -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringBackend id used byWallet.Factorydiscovery to address this wallet shape. -
Method Summary
Modifier and TypeMethodDescriptionaddress()Lowercase0x...hex address.static InMemoryWalletforTesting(String address, Network network) Factory method — naming makes the test-only intent explicit at the call site.network()Network the wallet is bound to.byte[]Produce a signature over the EIP-712 digest implied bytd.
-
Field Details
-
BACKEND_ID
Backend id used byWallet.Factorydiscovery to address this wallet shape. P2 ships the class but not the factory — callers in tests instantiate viaforTesting(String, Network).- See Also:
-
-
Method Details
-
forTesting
Factory method — naming makes the test-only intent explicit at the call site. Production code that wants a wallet should go throughWallet.Factory.discover()instead.- Parameters:
address-0x...hex address; case is normalisednetwork- the network this wallet claims to be on
-
address
Description copied from interface:WalletLowercase0x...hex address. EVM addresses are 42 chars. -
network
Description copied from interface:WalletNetwork the wallet is bound to. Cross-network use is not supported. -
signTypedData
Description copied from interface:WalletProduce a signature over the EIP-712 digest implied bytd.- Specified by:
signTypedDatain interfaceWallet- Parameters:
td- prepared domain-separator + struct-hash pair- Returns:
- 65 bytes for EVM (
r || s || v), 64 for SVM
-