MCPcopy Create free account
hub / github.com/NoteProtocol/NoteWallet / send

Method send

src/btc/btc-wallet.ts:128–152  ·  view source on GitHub ↗
(toAddresses: ISendToAddress[], feePerKb?: number)

Source from the content-addressed store, hash-verified

126 }
127
128 async send(toAddresses: ISendToAddress[], feePerKb?: number) {
129 const utxos = await this.fetchAllAccountUtxos();
130 feePerKb = feePerKb ?? (await this.getFeePerKb()).avgFee;
131 const network =
132 bitcoin.networks[
133 this.config.network === "livenet" ? "bitcoin" : "testnet"
134 ];
135
136 const privateKeyBuffer = new PrivateKey(
137 this.currentAccount.privateKey
138 ).toBuffer();
139 const privateKey = ECPair.fromPrivateKey(privateKeyBuffer);
140
141 const realFee = await this.sendEstimate(toAddresses, feePerKb);
142
143 const finalTx = createCoinPsbt(
144 privateKey,
145 utxos,
146 toAddresses,
147 this.currentAccount.mainAddress!.address!,
148 network,
149 realFee
150 );
151 return await this.urchain.broadcast(finalTx.toHex());
152 }
153
154 protected async buildNoteTransaction(
155 payload: NotePayload,

Callers 4

buildEmptyTokenUTXOMethod · 0.95
mintP2TRNoteV1Method · 0.95
processCommandMethod · 0.80

Calls 4

getFeePerKbMethod · 0.95
sendEstimateMethod · 0.95
createCoinPsbtFunction · 0.90
broadcastMethod · 0.80

Tested by

no test coverage detected