Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ChrisCho-H
Copy link
Contributor

@ChrisCho-H ChrisCho-H commented Aug 18, 2023

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

@ChrisCho-H ChrisCho-H changed the title feat: segwit taproot calculator feat: calculate segwit, taproot and script hash input/output bytes Aug 22, 2023
@LeeKorbisCa
Copy link

LeeKorbisCa commented Aug 30, 2023

+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? ❤️ I looked it over and the calculation looks ok, but I'm not intimately familiar with TX size calculation.

@ChrisCho-H
Copy link
Contributor Author

ChrisCho-H commented Aug 31, 2023

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
Copy link
Contributor Author

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

@LeeKorbisCa
Copy link

LeeKorbisCa commented Sep 18, 2023

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

@LeeKorbisCa
Copy link

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

@LeeKorbisCa
Copy link

LeeKorbisCa commented Oct 4, 2023

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

@DmytroShalaiev
Copy link

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

@ChrisCho-H
Copy link
Contributor Author

@landabaso would u mind to review it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants