coinselect icon indicating copy to clipboard operation
coinselect copied to clipboard

feat: calculate segwit, taproot and script hash input/output bytes

Open ChrisCho-H opened this issue 2 years ago • 8 comments

add logic to calculate segwit, taproot and script hash input and output to support satoshi per vbyte.

ChrisCho-H avatar Aug 18 '23 09:08 ChrisCho-H

+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.

KorbisInc avatar Aug 30 '23 13:08 KorbisInc

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!

ChrisCho-H avatar Aug 31 '23 06:08 ChrisCho-H

@LeeKorbisCa I published my forked version to npm bitcoinselect, u can use it if u want https://github.com/ChrisCho-H/bitcoinselect

ChrisCho-H avatar Sep 13 '23 06:09 ChrisCho-H

@Overtorment could you please review when you've got a moment? :smiley: (Pinging you since it seems junderw delegates to you :))

KorbisInc avatar Sep 18 '23 17:09 KorbisInc

@ChrisCho-H I'm now using your fork in the meantime. Thank you again for publishing this

KorbisInc avatar Oct 04 '23 16:10 KorbisInc

~~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 :)

KorbisInc avatar Oct 04 '23 16:10 KorbisInc

@junderw maybe you can help with the review? The feature with seg-wit & TapRoot coin selection seems to be very necessary for JS bitcoiners

DmytroShalaiev avatar Dec 14 '23 15:12 DmytroShalaiev

@landabaso would u mind to review it?

ChrisCho-H avatar Jan 09 '24 02:01 ChrisCho-H