feat: calculate segwit, taproot and script hash input/output bytes
add logic to calculate segwit, taproot and script hash input and output to support satoshi per vbyte.
+1 for this. I may have to go as far as using @ChrisCho-H 's fork / branch directly in my package.json since we use Segwit and it'd save us a lot on fees if this can't get in by the end of the month... @Overtorment could you review? :heart: I looked it over and the calculation looks ok, but I'm not intimately familiar with TX size calculation.
thanks a lot. it works for p2pkh, p2sh and p2wpkh(segwit).
I change a logic a bit to include all the cases(especially nested segwit) in 369093c.
script field is now separating redeemScript from witnessScript to identify(for p2sh, precise calculation could be done to put total script sig in redeemScript).
now it would work for most possible input and output cases!
@LeeKorbisCa I published my forked version to npm bitcoinselect, u can use it if u want
https://github.com/ChrisCho-H/bitcoinselect
@Overtorment could you please review when you've got a moment? :smiley: (Pinging you since it seems junderw delegates to you :))
@ChrisCho-H I'm now using your fork in the meantime. Thank you again for publishing this
~~So after some testing, it seems there's no difference in the fees calculated, at least not in the final TX. I'm using https://blockstream.info/api/fee-estimates to get a fee estimate in sat/vbyte for the 2nd block, and no matter what I try I'm getting similar values to coinselect. Any ideas @ChrisCho-H ?~~ Nevermind, all good :)
@junderw maybe you can help with the review? The feature with seg-wit & TapRoot coin selection seems to be very necessary for JS bitcoiners
@landabaso would u mind to review it?