-
-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Description
selectUTXO(..., { createTx: true }) requires changeAddress. Allow a richer changeOutput object so change can target script-only outputs (P2WSH, Taproot trees, P2A, etc.) without deriving an address.
API
type SelectUtxoOpts = {
changeAddress?: string; // existing
changeOutput?: {
script?: Bytes;
redeemScript?: Bytes;
witnessScript?: Bytes;
tapInternalKey?: Bytes;
bip32Derivation?: [Bytes, { fingerprint: number; path: number[] }][];
}; // NEW
feePerByte: bigint;
bip69?: boolean;
createTx?: boolean;
network?: Network;
};Example
const ms = btc.p2wsh(btc.p2ms(2, [pub1, pub2, pub3]));
const sel = btc.selectUTXO(utxo, outs, 'default', {
changeOutput: { script: ms.script, witnessScript: ms.witnessScript },
feePerByte: 2n,
createTx: true,
});Behavior
- If
changeOutputis set → use it for change and ignorechangeAddress. - Backward compatible when only
changeAddressis provided.
Metadata
Metadata
Assignees
Labels
No labels