bitcoinjs / coinselect

An unspent transaction output (UTXO) selection module for bitcoin.
MIT License
176 stars 101 forks source link

Segregated witness support should result in significantly different fees #4

Open dcousens opened 7 years ago

dcousens commented 7 years ago

Perhaps base it off a .witness field in the inputs... with which case:

vsize of a transaction equals to 3 times of the size with original serialization, plus the size with new serialization, divide the result by 4 and round up to the next integer. For example, if a transaction is 200 bytes with new serialization, and becomes 99 bytes with marker, flag, and witness removed, the vsize is (99 * 3 + 200) / 4 = 125 with round up.

dcousens commented 7 years ago

Options:

The latter is probably better...

karelbilek commented 7 years ago

Hey, I will look at this soon, I am currently in need for coinselect to work on segwit :)

karelbilek commented 7 years ago

Which script types would like to support?

I could take the types from here (except for NONSTANDARD)

https://github.com/bitcoinjs/bitcoinjs-lib/blob/170328341bdcf2a22d6ee6df1df587ea4e83c8a9/src/templates/index.js#L11

dcousens commented 7 years ago

.script.length is used now for estimation [if provided] - without it, it assumes P2PKH.

If you're implementation can pre-sign all inputs, but with fake/blank signatures [for security], then script.length and an added reduction of byte length over the witness stack would be more than enough to do this.

karelbilek commented 7 years ago

Hm, but pre-signing all inputs with empty/fake privkeys will complicate things and needlessly slow down computation, when the inputs types usually have the same lengths anyway for the given type

dcousens commented 7 years ago

Hm, but pre-signing all inputs with empty/fake privkeys will complicate things and needlessly slow down computation

Not necessarily, it should be no different then the approach we'd be taking here (pattern match, speculate byte length impact via a fake script/witness.

dcousens commented 6 years ago

Resolved partially by https://github.com/bitcoinjs/coinselect/pull/22#discussion_r133176608 - but - the virtual size calculation isn't accounted for yet? .witness would need to be provided?

blmalone commented 5 years ago

Is this issue being worked on? :)

mahnunchik commented 11 months ago

Any news?

karelbilek commented 11 months ago

I don’t want to talk for current maintainers, but neither me or dcousens is in bitcoin business anymore

On Thu 13. 7. 2023 at 20:10, Evgeny @.***> wrote:

Any news?

— Reply to this email directly, view it on GitHub https://github.com/bitcoinjs/coinselect/issues/4#issuecomment-1634683699, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAZT4OYKJ2QO4HUWUQ3ZTTXQA2YNANCNFSM4CVUMZ6A . You are receiving this because you were assigned.Message ID: @.***>

mahnunchik commented 11 months ago

What's happened?

junderw commented 11 months ago

I am here, but this repository is not a priority for me.

PRs and more importantly PR reviews are greatly appreciated and needed.

ChrisCho-H commented 10 months ago

I made PR https://github.com/bitcoinjs/coinselect/pull/82 regarding this issue.