question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Turning an unsigned transasction into a PSBT

See original GitHub issue

I am trying to take an unsigned transaction and turn it into PSBT format so I can sign it with my cold card hardware wallet.

I have an unsigned transaction 0100000003701d805440cc9883a4791c0dc660e38064cd805983cdabb7ac88aa78ce1837000000000000ffffffffb16a8a95d0e5f28d30833f45478a4f63a79dde6b2412c4443acf81749e903a6d0000000000ffffffff02e90615d330ae57c2dfcd9f7b8c22d6b872c4f49fd74d14025515576c9a5ea70000000000ffffffff02204e00000000000017a914013b3ecc4de17f26f4035d1c4e17976a4776daa7876e1f00000000000017a9141282b344adde09f7f86a1969e639a2ad231d7f6e8700000000

Is there a way to turn that into a PSBT? I tried passing it into the constructor of PSBT and Transaction but both didn’t seem to accept it.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
junderwcommented, Apr 2, 2020

I highly recommend 2, since 1 will leave you with a PSBT with no input tags, and a PSBT without any input information is worthless… defeating the purpose of PSBT.

But it really depends on your needs. 2 will be best for 99.999% of cases.

1reaction
junderwcommented, Apr 2, 2020

Two ways to do this:

  1. (Hard) Use bip174 library’s Psbt class and create your own class that implements ITransaction for it, then plug it in. (If you look at ts_src/psbt.ts you can see how we implement it. Importing the bip174 Psbt as PsbtBase and implementing our own PsbtTransaction)

  2. (Easier) Create a Transaction object using Transaction.fromHex() and then create a new Psbt object, and loop through the Transaction.ins and Transaction.outs and place the info into the PSBT as needed.

However, an unsigned transaction lacks the needed information for signing, so you must also include that information while you are looping the inputs and outputs to create the PSBT.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is not possibile to convert a signed transaction into psbt?
In the bitcoin core doc is explicitly said that conversion from hex to psbt are only allowed for unsigned transactions, or, at most, ......
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 >
How to use an unsigned transaction with PSBT to create a ...
Hi, I was going through some code to create transactions for bitcoin and use a serialized hash of the unsigned transaction to create...
Read more >
What Are Partially Signed Bitcoin Transactions (PSBTs)?
Partially Signed Bitcoin Transactions are a Bitcoin standard that makes communicating and signing unsigned transactions easier for wallets and nodes.
Read more >
PSBT (BIP 174) - Partially Signed Bitcoin Transactions
Multisig transactions 1 have been a great use case of Bitcoin for the past ... they require unsigned or partially signed transactions to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found