(toAddresses: ISendToAddress[], feePerKb?: number)
| 100 | } |
| 101 | |
| 102 | async sendEstimate(toAddresses: ISendToAddress[], feePerKb?: number) { |
| 103 | const utxos = await this.fetchAllAccountUtxos(); |
| 104 | feePerKb = feePerKb ?? (await this.getFeePerKb()).avgFee; |
| 105 | const network = |
| 106 | bitcoin.networks[ |
| 107 | this.config.network === "livenet" ? "bitcoin" : "testnet" |
| 108 | ]; |
| 109 | |
| 110 | const privateKeyBuffer = new PrivateKey( |
| 111 | this.currentAccount.privateKey |
| 112 | ).toBuffer(); |
| 113 | const privateKey = ECPair.fromPrivateKey(privateKeyBuffer); |
| 114 | |
| 115 | const estimatedPsbt = createCoinPsbt( |
| 116 | privateKey, |
| 117 | utxos, |
| 118 | toAddresses, |
| 119 | this.currentAccount.mainAddress!.address!, |
| 120 | network, |
| 121 | 1000 |
| 122 | ); |
| 123 | |
| 124 | const estimatedSize = estimatedPsbt.virtualSize(); |
| 125 | return Math.floor((estimatedSize * feePerKb) / 1000 + 1); |
| 126 | } |
| 127 | |
| 128 | async send(toAddresses: ISendToAddress[], feePerKb?: number) { |
| 129 | const utxos = await this.fetchAllAccountUtxos(); |
no test coverage detected