build method
Builds and signs the transaction synchronously.
The signer is invoked once per input with the BIP-143 (segwit) or legacy
sighash digest and must return DER-encoded ECDSA signature bytes WITHOUT
the trailing sighash flag (the flag is appended when the input is
serialized, via InputSig.toBytes).
Implementation
Tx build(SignerCallback signer) {
final ordered = orderedInputs();
final outs = orderedOutputs();
final tx = unsignedTx(ordered, outs);
final signed = List<TxInput>.generate(ordered.length, (i) {
final meta = ordered[i];
final digest = computeDigest(tx, i, meta);
final sig = signer(tx, i, digest, meta.hashType);
return buildSignedInput(meta, sig);
});
return Tx(
version: version,
inputs: signed,
outputs: outs,
locktime: locktime,
);
}