Record Class WalletSpec

java.lang.Object
java.lang.Record
com.tnsai.payment.x402.WalletSpec
Record Components:
backend - backend identifier, e.g. "in-memory", "env-keystore"; matches the factory's discovery name
network - target network — wallets are network-bound at creation time
attributes - backend-specific key/value config (never null)

public record WalletSpec(String backend, Network network, Map<String,String> attributes) extends Record
Backend-agnostic configuration a Wallet.Factory consumes to instantiate a Wallet.

The shape stays deliberately bag-of-attributes — each concrete wallet backend (env keystore, AWS KMS, hardware ledger, …) reads the keys it cares about and ignores the rest. P2 only ships InMemoryWallet which reads address from attributes(); production backends arrive in P4.

Common keys callers are expected to populate (per-backend):

  • address — the wallet's public address (always required; backends that derive from a private key still echo it here so the upper layer doesn't need to round-trip the key).
  • passphrase_env — env var holding the unlock passphrase (env-keystore backend).
  • keystore_path — path to a JSON keystore on disk (env-keystore backend).
  • remote_signer_url — URL of an out-of-process signing service (delegated-wallet backend).

None of these keys are validated here on purpose — the factory's Wallet.Factory.create(WalletSpec) is the only place that knows what it actually needs.

Since:
0.10.5 (TNS-449 P2)
  • Constructor Details

    • WalletSpec

      public WalletSpec(String backend, Network network, Map<String,String> attributes)
      Creates an instance of a WalletSpec record class.
      Parameters:
      backend - the value for the backend record component
      network - the value for the network record component
      attributes - the value for the attributes record component
  • Method Details

    • attr

      public String attr(String key)
      Convenience accessor — returns the attribute value or null. Identical to attributes().get(key) but reads more cleanly at call sites where the bag-of-attributes shape feels noisy.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • backend

      public String backend()
      Returns the value of the backend record component.
      Returns:
      the value of the backend record component
    • network

      public Network network()
      Returns the value of the network record component.
      Returns:
      the value of the network record component
    • attributes

      public Map<String,String> attributes()
      Returns the value of the attributes record component.
      Returns:
      the value of the attributes record component