Package com.tnsai.payment.x402
Interface Wallet.Factory
- Enclosing interface:
Wallet
public static interface Wallet.Factory
Factory that turns a
WalletSpec into a live Wallet.
One concrete implementation per backend (in-memory, env keystore,
KMS, hardware, …); ships separately in P3+.-
Method Summary
Modifier and TypeMethodDescriptionbackend()Backend identifier this factory handles, matching theWalletSpec.backend()field.create(WalletSpec spec) Build a wallet forspec.static Optional<Wallet.Factory> discover()FirstWallet.Factoryregistered viaServiceLoader.static Optional<Wallet.Factory>
-
Method Details
-
backend
String backend()Backend identifier this factory handles, matching theWalletSpec.backend()field. Lowercase, kebab-case (e.g."in-memory","env-keystore"). -
create
Build a wallet forspec. Implementations should fail fast — missing required attributes raiseIllegalArgumentExceptionwith an operator-actionable message instead of returning a half-constructed wallet. -
discover
FirstWallet.Factoryregistered viaServiceLoader. ReturnsOptional.empty()when no factory is on the classpath — callers can then fall back to constructing a known wallet impl directly.P2 ships no production factory. Callers needing a wallet for tests should instantiate
InMemoryWalletexplicitly. -
discover
Likediscover()but selects the factory whosebackend()matchesbackendId. Useful when more than one factory ships on the classpath (e.g. an agent that wants both KMS and env-keystore available).
-