CallbackTransactionSigner class

A TransactionSigner that delegates ECDSA signing to a callback.

The private key never leaves the secure context. The coordinator retrieves the key from SecureStorage, creates a closure that signs with it, and passes this signer to plugins. The plugin calls sign which invokes the closure — but cannot access the key itself.

// Coordinator retrieves key from SecureStorage, creates closure:
final privateKey = SVPrivateKey.fromWIF(await secureStorage.getWIF(walletId));
final signer = CallbackTransactionSigner(
  sigHashType: SighashType.SIGHASH_ALL.value | SighashType.SIGHASH_FORKID.value,
  onSign: (sighash, inputIndex) {
    final sig = SVSignature.fromPrivateKey(privateKey);
    sig.nhashtype = sigHashType;
    sig.sign(HEX.encode(sighash));
    return Uint8List.fromList(sig.toDER());
  },
);
// Plugin receives signer — can sign, cannot extract key
plugin.buildTransaction(PluginTransactionRequest(signer: signer, ...));

Constructors

CallbackTransactionSigner({required int sigHashType, required SigningCallback onSign})
Creates a signer with a 2-arg callback (backward compatible).
CallbackTransactionSigner.withScriptContext({required int sigHashType, required SigningCallbackWithScript onSign})
Creates a signer with a 3-arg callback that receives the locking script.

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sigHashType → int
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
sign(Transaction unsignedTxn, TransactionOutput utxo, int inputIndex) → Transaction
Sign a single input of unsignedTxn that spends utxo at inputIndex.
signPreimage(Uint8List preImage) → SVSignature
Sign a raw sighash preimage. Utility used by some unlock builders.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited