Interface TransactionSigner<P extends PrivateKeyable>

All Known Subinterfaces:
SignatureService<PK>
All Known Implementing Classes:
AbstractSignatureService, AbstractTransactionSigner, BcDerivedKeySignatureService, BcSignatureService

public interface TransactionSigner<P extends PrivateKeyable>
Defines how to sign an XRPL transaction using private key material supplied by the caller.
  • Method Details

    • derivePublicKey

      PublicKey derivePublicKey(P privateKeyable)
      Accessor for the public-key corresponding to the supplied key meta-data. This method exists to support implementations that hold private-key material internally yet need a way for external callers to determine the actual public key for signature verification or other purposes.
      Parameters:
      privateKeyable - A PrivateKeyable to derive a public key from.
      Returns:
      A PublicKey.
    • sign

      <T extends Transaction> SingleSignedTransaction<T> sign(P privateKeyable, T transaction)
      Get a transaction with a single-sig using privateKeyable.
      Type Parameters:
      T - The type Transaction to be signed.
      Parameters:
      privateKeyable - The TransactionSigner used to sign transaction.
      transaction - The Transaction to sign.
      Returns:
      A SingleSignedTransaction of type TransactionSigner containing everything related to a signed transaction.
    • sign

      Signature sign(P privateKeyable, UnsignedClaim unsignedClaim)
      Signs a claim for usage in a Payment Channel.
      Parameters:
      privateKeyable - A TransactionSigner used for signing.
      unsignedClaim - An UnsignedClaim.
      Returns:
      A Signature.
    • sign

      @Beta Signature sign(P privateKeyable, Attestation attestation)
      Sign attestations for cross-chain account creation or transfers.

      This method will be marked Beta until the featureXChainBridge amendment is enabled on mainnet. Its API is subject to change.

      Parameters:
      privateKeyable - The TransactionSigner used to sign attestation.
      attestation - An Attestation to sign.
      Returns:
      A Signature.
    • signInner

      @Beta Signature signInner(P privateKeyable, Batch batchTransaction)
      Get a signature for a batch transaction using the supplied TransactionSigner.

      Per XLS-0056, BatchSigners sign a specific format: HashPrefix::batch + flags + count + inner tx IDs. This differs from both single-signing and multi-signing.

      This method will be marked Beta until the featureBatch amendment is enabled on mainnet. Its API is subject to change.

      Parameters:
      privateKeyable - The TransactionSigner used to sign batchTransaction.
      batchTransaction - The Batch transaction to sign.
      Returns:
      A Signature for the batch transaction.
    • multiSign

      <T extends Transaction> Signature multiSign(P privateKeyable, T transaction)
      Get a signature for the supplied unsigned transaction using the supplied TransactionSigner. The primary reason this method's signature diverges from sign(PrivateKeyable, Transaction) is that for multi-sign scenarios, the interstitially signed transaction is always discarded. Instead, a quorum of signatures is needed, and then that quorum is submitted to the ledger with the unsigned transaction. Thus, getting a multi-signed transaction here is not useful and is not returned from this interface. Note that SignatureUtils can be used to assemble and obtain the bytes for a multi-signed transaction (these diverge slightly from the bytes of a single-signed transaction).
      Type Parameters:
      T - The type of the transaction to be signed.
      Parameters:
      privateKeyable - The TransactionSigner used to sign transaction.
      transaction - The Transaction to sign.
      Returns:
      A Signature for the transaction.
    • multiSignInner

      Signature multiSignInner(P privateKeyable, Batch batchTransaction)
      Obtain a multi-signature for a batch transaction using the supplied TransactionSigner.

      This is used when a multi-sig account acts as a BatchSigner with nested Signers. Per rippled's checkBatchMultiSign, this uses batch serialization (HashPrefix::batch + flags + count + tx IDs) followed by appending the signer's account ID.

      This method will be marked Beta until the featureBatch amendment is enabled on mainnet. Its API is subject to change.

      Parameters:
      privateKeyable - The TransactionSigner used to sign batchTransaction.
      batchTransaction - The Batch transaction to sign.
      Returns:
      A Signature for the batch transaction with multi-sig format.
    • multiSignToSigner

      @Deprecated default <T extends Transaction> Signer multiSignToSigner(P privateKeyable, T transaction)
      Deprecated.
      Use multiSign(PrivateKeyable, Transaction) instead and assemble a Signer manually. This will allow callers to better manage public-key derivation, especially for derived key scenarios like an HSM where public-key derivation is expensive and may only need to be done once for multiple multi-sig operations.
      Obtain a signature for the supplied unsigned transaction using the supplied TransactionSigner.

      As is the case with multiSign(PrivateKeyable, Transaction), the primary reason this method's signature diverges from sign(PrivateKeyable, Transaction) is that for multi-sign scenarios, the interstitially signed transaction is always discarded. Instead, a quorum of signatures is need and then that quorum is submitted to the ledger with the unsigned transaction. Thus, obtaining a multi-signed transaction here is not useful and is not returned from this interface. Note that SignatureUtils can be used to assemble and obtain the bytes for a multi-signed transaction (these diverge slightly from the bytes of a single-signed transaction).

      This method is nearly identical to multiSign(PrivateKeyable, Transaction) except that its return-type is a Signer, which is more convenient for submitting transactions to the XRP Ledger. Note however that this method internally calls derivePublicKey(PrivateKeyable), which in certain remote-key configurations (e.g., storing keys in a remote HSM) involves a potentially expensive remote call to the HSM. In most scenarios, the public key will already be available, so callers of this method should consider using multiSign(PrivateKeyable, Transaction) instead if public-key derivation is a performance concern.

      Type Parameters:
      T - The type of the transaction to be signed.
      Parameters:
      privateKeyable - The TransactionSigner used to sign transaction.
      transaction - The Transaction to sign.
      Returns:
      A Signature for the transaction.