( provider: NetworkProvider, address: string, utxo: Utxo, )
| 86 | } |
| 87 | |
| 88 | async function sendLiveAddUtxo( |
| 89 | provider: NetworkProvider, |
| 90 | address: string, |
| 91 | utxo: Utxo, |
| 92 | ): Promise<Utxo> { |
| 93 | const funderUtxos = (await provider.getUtxos(funderAddress)) |
| 94 | .filter(isNonTokenUtxo) |
| 95 | .sort(utxoComparator) |
| 96 | .reverse(); |
| 97 | |
| 98 | const { utxos: selected } = gatherUtxos(funderUtxos, { amount: utxo.satoshis, fee: 2000n }); |
| 99 | |
| 100 | const tx = await new TransactionBuilder({ provider }) |
| 101 | .addInputs(selected, new SignatureTemplate(funderPriv).unlockP2PKH()) |
| 102 | .addOutput({ to: address, amount: utxo.satoshis }) |
| 103 | .addBchChangeOutputIfNeeded({ to: funderAddress, feeRate: 1.0 }) |
| 104 | .send(); |
| 105 | |
| 106 | return { |
| 107 | txid: tx.txid, |
| 108 | vout: 0, |
| 109 | satoshis: utxo.satoshis, |
| 110 | }; |
| 111 | } |
| 112 | |
| 113 | export function gatherUtxos( |
| 114 | utxos: Utxo[], |
no test coverage detected