I am sorry if this has been responded sooner than, however I have not discovered somebody in reality deliver this up.
I’m looking to assemble a PSBT, which assumes a hard and fast feerate and a hard and fast quantity to ship to a couple cope with. Any additional sats is trade again to the sender. One thing like:
const psbt = new Psbt({ community: bitcoin.networks.bitcoin });
psbt.addInput({hash, index, witnessUtxo: {...}});
psbt.addOutput({cope with: recipient, worth: amountToSend});
psbt.addOutput({cope with: sender, worth: changeAmount}); // general inputs - amountToSend - charges
Alternatively, growing that final trade output turns out like a round workout:
- To decide the final output so as to add to the PSBT, we want to know the precise rate in satoshis we are keen to spend.
- To understand the precise rate in satoshis, we want to know the digital bytes that the tx will devour, which calls for us having an absolutely built and signed PSBT i.e.
signedPsbt.extractTransaction().virtualSize();
.
Am I lacking one thing obtrusive right here? Is there one thing to lend a hand estimate vsize sooner than signing a PSBT (by way of estimating the dimensions of signatures)? Or one thing to lend a hand estimate charges given selection of inputs and outputs?
Any lend a hand is liked. Thanks prematurely!