How to get concerned specific unspent(coin selection algorithm) from list of unspents in a wallet to calculate transaction size

0

I have a problem to calculate dynamic transaction fees. The problem which i am facing is to calculate the transaction size. When i have one unspent in my wallet it is too easy to calculate transaction size. but when there are multiple unspents in wallet i think then there is some coin selection algorithm to calculate the best unspent or combination of unspents. I have compiled document document that explains this problem completely.

I need opinion in which way i wanna move? whether to develop own coin selection algorithm or there are some other options exist?

aqeel kazmi

Posted 2019-11-18T06:27:50.180

Reputation: 1

What exactly are you trying to calculate the size for? To calculate the transaction fee before coin selection? During selection? Or after?Andrew Chow 2019-11-18T17:41:45.283

In a simple words i just want to get the size of transaction which i am going to broadcast. When i got the size then i will calculate transaction fees.aqeel kazmi 2019-11-19T04:50:34.033

If you just want to see the transaction fee before it is broadcast, use the raw transaction api (createrawtranscation,fundrawtransaction, etc.) or the psbt api (walletcreatefundedpsbt,walletprocesspsbt,etc.) and make the transaction. Then inspect it before you broadcast it.Andrew Chow 2019-11-19T05:26:21.470

I have done by using https://github.com/bitcoinjs/coinselect

aqeel kazmi 2019-11-20T06:07:47.630

No answers