(toAddresses: ISendToAddress[], feePerKb?: number)
| 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, |
no test coverage detected