UNPKG

@xlink-network/xlink-sdk

Version:
46 lines (44 loc) 1.19 kB
import { hasAny } from "./chunk-PRLWYSC3.mjs"; // src/bitcoinUtils/createTransaction.ts import * as btc from "@scure/btc-signer"; function createTransaction(inputUTXOs, recipients, opReturnData) { const tx = new btc.Transaction({ allowUnknownOutputs: true, allowLegacyWitnessUtxo: true }); inputUTXOs.forEach((utxo) => { tx.addInput({ txid: utxo.txId, index: utxo.index, witnessUtxo: utxo.scriptPubKey == null ? void 0 : { script: utxo.scriptPubKey, amount: utxo.amount }, tapInternalKey: "tapInternalKey" in utxo ? utxo.tapInternalKey : void 0, redeemScript: "redeemScript" in utxo ? utxo.redeemScript : void 0, // Enable RBF sequence: btc.DEFAULT_SEQUENCE - 2 }); }); recipients.forEach((recipient) => { tx.addOutput({ script: recipient.addressScriptPubKey, amount: recipient.satsAmount }); }); if (hasAny(opReturnData)) { opReturnData.forEach((data) => { tx.addOutput({ script: btc.Script.encode(["RETURN", data]), amount: 0n }); }); } return tx; } export { createTransaction }; //# sourceMappingURL=chunk-ATRBHFDV.mjs.map