Using PSBT vs fundrawtransaction for Offline Transactions

11 replies 133 views
rav3n_ninj4Senior Member
Posts: 15 · Reputation: 1643
#1Feb 3, 2021, 05:08 AM
I'm on Core Client 27.1, just using the daemon for now. Thought about switching to the GUI, but first let me explain my setup. I've got a cold wallet on a Raspberry Pi and a watch wallet on a regular PC. They communicate via QR codes. Pretty smooth, I can send like 2k of data with one code. I’m sticking to BIP 84 addresses, keeping things standard. Just need to send Bitcoin simply.
5 Reply Quote Share
rav3n_ninj4Senior Member
Posts: 15 · Reputation: 1643
#2Feb 3, 2021, 07:41 AM
I did some digging online and found this series of articles. The section on creating a PSBT the easy way seems perfect for me. Gonna give it a try. Saw HWI in the last article. Didn't know about it before. Seems useful, but feels like it complicates my current setup. Can I just stick to walletprocesspsbt on my Raspberry?
3 Reply Quote Share
matrix2021Full Member
Posts: 24 · Reputation: 612
#3Feb 3, 2021, 10:45 AM
Definitely go with PSBTs, they come packed with the info needed for signing. Raw transaction steps need you to supply that data separately, which is a hassle.
2 Reply Quote Share
0xChadNewbie
Posts: 186 · Reputation: 3
#4Feb 3, 2021, 12:39 PM
That setup should work. Just a heads up, the guide might be outdated since it was written for versions before 26.0. Since you're on 27.1, finalizepsbt won't be needed. walletprocesspsbt will give you the finalized hex to broadcast with your watch wallet.
1 Reply Quote Share
rav3n_ninj4Senior Member
Posts: 15 · Reputation: 1643
#5Feb 3, 2021, 01:39 PM
I switched to the qt-client after realizing it’s got a full PSBT workflow. Did two native SegWit transactions as a test. Signed them on my HW wallet, no issues, network accepted them. Surprisingly, the first PSBT was 3K big, the second only 300 bytes. Crazy difference! Didn’t expect that, thought they’d be around 300 bytes each.
1 Reply Quote Share
0xChadNewbie
Posts: 186 · Reputation: 3
#6Feb 3, 2021, 02:35 PM
But they both are P2WPKH transactions, right? No big structure differences should cause that. Maybe the number of UTXOs in the first one inflated its size?
2 Reply Quote Share
rav3n_ninj4Senior Member
Posts: 15 · Reputation: 1643
#7Feb 4, 2021, 09:48 AM
You still got copies of the PSBTs you used? You could run analyzepsbt to check the input counts.
3 Reply Quote Share
rav3n_ninj4Senior Member
Posts: 15 · Reputation: 1643
#8Feb 4, 2021, 11:47 AM
Here's the analyzepsbt for the first transaction (3071 bytes): And for the second one (272 bytes). Looks like both had one input? But the first one is way bigger. Each adds around 50 bytes when signed, I assume that's normal.
3 Reply Quote Share
rav3n_ninj4Senior Member
Posts: 15 · Reputation: 1643
#9Feb 4, 2021, 02:43 PM
Used decodepsbt to check the files in JSON. Major differences! From my user view, I did the same for both transactions. First, moved all from address 1 to 2. Then from 2 to 3. In the second transaction, I see an input and output under non_witness_utxo, which is mine. Seems normal? The first one has a bunch of other inputs and outputs.
3 Reply Quote Share
matrix2021Full Member
Posts: 24 · Reputation: 612
#10Feb 6, 2021, 01:25 PM
Shouldn't legacy addresses solve this issue? The PSBT file should be smaller, right? Just wondering if there are downsides apart from higher fees.
4 Reply Quote Share
rav3n_ninj4Senior Member
Posts: 15 · Reputation: 1643
#11Feb 9, 2021, 01:17 AM
Nah, it’s a security measure. Signing needs the output script of what you’re spending. That info isn’t part of the input, so it’s extra data in PSBT. Also, you wanna know the amount to verify things. With non-segwit, someone could trick you into signing a transaction with incorrect amounts.
1 Reply Quote Share
Posts: 1362 · Reputation: 35
#12Feb 9, 2021, 03:30 AM
You and nc50lc really helped me out here, thanks! I need to study more to grasp everything fully. What I get is that signing needs more data than it seems. The PSBT size depends on how inputs were added originally. Maybe I should look into Taproot (Bech32m) to avoid this issue. Average transaction size is just 300 bytes, so I should be good.
5 Reply Quote Share

Related topics