Skip to content

Commit 8783f95

Browse files
OttoAllmendingerllm-git
andcommitted
feat(abstract-utxo): add encodeTransaction function
Add helper function to convert various transaction types to a Buffer Issue: BTC-2806 Co-authored-by: llm-git <[email protected]>
1 parent 87df3db commit 8783f95

File tree

1 file changed

+12
-0
lines changed
  • modules/abstract-utxo/src/transaction

1 file changed

+12
-0
lines changed

modules/abstract-utxo/src/transaction/decode.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,15 @@ export function decodePsbtWith(
5757
return fixedScriptWallet.BitGoPsbt.fromBytes(psbt, toNetworkName(network));
5858
}
5959
}
60+
61+
export function encodeTransaction(
62+
transaction: utxolib.bitgo.UtxoTransaction<bigint | number> | utxolib.bitgo.UtxoPsbt | fixedScriptWallet.BitGoPsbt
63+
): Buffer {
64+
if (transaction instanceof utxolib.bitgo.UtxoTransaction) {
65+
return transaction.toBuffer();
66+
} else if (transaction instanceof utxolib.bitgo.UtxoPsbt) {
67+
return transaction.toBuffer();
68+
} else {
69+
return Buffer.from(transaction.serialize());
70+
}
71+
}

0 commit comments

Comments
 (0)