<p>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 
 <a href="https://docs.google.com/document/d/1XvmkeZnFgjC0vLQlPtCk2IInaolAmPUj16S2gl_eS2Q/edit" rel="nofollow noreferrer">document</a>  that explains this problem completely.</p>

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

CC BY-SA 4.0
2019-11-18T17:41:45.283Z
What exactly are you trying to calculate the size for? To calculate the transaction fee before coin selection? During selection? Or after?
Ava Chow
CC BY-SA 4.0
2019-11-19T04:50:34.033Z
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
CC BY-SA 4.0
2019-11-19T05:26:21.470Z
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.
Ava Chow
CC BY-SA 4.0
2019-11-20T06:07:47.630Z
I have done by using https://github.com/bitcoinjs/coinselect
aqeel kazmi
<bitcoin-core><transaction-fees><listunspent>
How to get concerned specific unspent(coin selection algorithm) from list of unspents in a wallet to calculate transaction size
aqeel kazmi
# How to get concerned specific unspent(coin selection algorithm) from list of unspents in a wallet to calculate transaction size

(Asked by: username_0 on 2019-11-18)

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](https://docs.google.com/document/d/1XvmkeZnFgjC0vLQlPtCk2IInaolAmPUj16S2gl_eS2Q/edit) 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?

**Tags:** bitcoin-core, transaction-fees, listunspent

> **Comments:**
> **username_1**: What exactly are you trying to calculate the size for? To calculate the transaction fee before coin selection? During selection? Or after?  
> **username_0**: 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.  
> **username_1**: 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.  
> **username_0**: I have done by using https://github.com/bitcoinjs/coinselect  

---

## 0 answers

