Closed junderw closed 6 years ago
Excellent example(s) to be added to README.
Will do.
Thanks!
@dcousens I fixed my example. It now works.
@junderw use .virtualSize
instead of / 4
?
See https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/src/transaction.js#L201
@afk11 virtualSize
probably should be virtualByteLength
... for consistency.
re: using virtualSize
The goal of this snippet was to give my colleagues an idea of how fee calculations will be done on segwit transactions and introducing them to the concept of weight in an intuitive readable couple of lines.
In prod we will definitely use virtualSize. ( | virtualByteLength)
Closing in favour of https://github.com/bitcoinjs/bitcoinjs-lib/pull/852
@junderw it is probably still worth show-casing how to spend the SegWit outputs, which #852 doesn't cover.
Feel like submitting a PR and putting it in test/integration/transactions.js
?
If not, I'll do it.
I know this is a long closed and "resolved" issue, and I would like to say test for p2sh-p2wpkh can be found here, but it is not the clearest example possible, unfortunately. The createPayment()
and getInputData()
functions make understanding the flow rather... clutterly.
Another example can be found here, but it features the now deprecated TransactionBuilder - and no example for using PSBT can be found elsewhere.
I would say I do comprehend what I am doing, but I'm trying to offload the signing step to a ledger hardware wallet, and struggling a bit with that. If this is the wrong place and I do not find the problem - I will create a separate issue asking for help later. Just wanted to point out there is not really concise documentation apart from the hard-to-follow test cases, and wanted to ask if there will be better examples in the future. :)
Is there a current example of this somewhere using current master...?
Also, as an extension of this, what would be an example of P2WSH (which is a 2 of 3 multisig script, let's say) that is also embedded in a BIP16 P2SH.
I knew it wouldn't work like this, and I was right, txb.sign throws an error.
EDIT: I got P2WSH-in-P2SH AND P2WPKH-in-P2SH to work. See below (I overwrote the old code)
P2WPKH-in-P2SH
P2WSH-in-P2SH (multisig 2-of-2)