HowTo: Construct a txID of an unsigned PSBT
See original GitHub issueHi,
as the title says, I would like to build the txID of an unsigned PSBT transaction. I built the PSBT with the following code snippet:
const psbt = new bitcoin.Psbt({ network });
psbt.setVersion(1);
for (const input of finalInputs) {
psbt.addInput({ hash: input.txId, index: input.vout, witnessUtxo: input.WitnessUtxo });
}
finalOutputs.forEach(output => {
psbt.addOutput({ address: output.address, value: output.value });
});
As I read through some threads here, I saw that it’s possible to get the txID with BuildIncomplete
via the TransactionBuilder but I wasn’t able to get it in any way from a PSBT transaction.
I would really appreciate if you could point me into the right direction!
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Create unsigned tx (PSBT) in a watch-only wallet using bitcoin ...
create wallet. cold-storage-example. Run the below commands in electrum console:
Read more >6. PSBT transactions - Build your own Bitcoin hardware wallet
Content:- Bitcoin transactions: legacy and segwit- BIP-174 - Partially Signed Bitcoin Transaction format- Parsing and change address ...
Read more >psbtbumpfee (0.21.0 RPC) - Bitcoin Core
psbtbumpfee "txid" ( options ) Bumps the fee of an opt-in-RBF transaction T, replacing it with a new transaction B. Returns a PSBT...
Read more >Command to populate PSBT inputs from given UTXOs
utxos must be an array of “txid:vout”, each of which must be reserved or available: the ... psbt (string): Unsigned PSBT which fulfills...
Read more >BIP 0174 - Bitcoin Wiki
Creating unsigned or partially signed transactions to be passed ... The Partially Signed Bitcoin Transaction (PSBT) format consists of ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
you could get the TransactionBuilder via:
although, the
__CACHE
is for now still private interface, meaning, it might break in the future update.I’m not sure if there’s a more appropriate way to do that as of now.
I was speaking on a theoretical basis.
In terms of your method (unsupported) the reason why this is happening is because PSBT leaves the inputs empty until the tx is extracted.
With P2SH-P2WSH you will need to have a scriptSig (input script) with the redeemscript.
tx.ins[i].script = bitcoinjs.script.compile([redeemScriptBuffer])
should allow you to use the work around for P2SH-P2WSH as well.However, be careful, as JavaScript passes by reference, so if you add those scripts the scripts will be added to the internal TX of the PSBT as well… so don’t do anything with the PSBT object after you’ve done this.