<p>If you are constructing your own transactions (rather than letting a wallet application do it for you), then you get to <em>choose</em> which inputs and outputs you use in the transaction.  For that matter, you also get to choose the fee for the transaction, since any leftover from the sum of the inputs minus the sum of the outputs is the mining fee.  Just remember that leaving too low of a fee will result in long delays of unconfirmed transactions.</p>

<p>Based on your needs, you can choose to use different <a href="https://bitcoin.stackexchange.com/q/1077/5406">coin selection algorithms</a>.  A coin selection algorithm's purpose is to select inputs from the pool of <a href="https://bitcoin.stackexchange.com/q/4301/5406">UTXOs</a> that you control.  Selecting too many for a single transaction will result in a higher fee.  However, refusing to use smaller UTXOs will leave your entire pool comprised of small ones, forcing you to use them (and pay higher fees) until your pool recovers.</p>

<p>There are pros and cons to different algorithms, especially when you are concerned with fees, so be sure to understand the ramifications of your decision.  A good place to start might be <a href="https://www.youtube.com/watch?v=_Z0ID-0DOnc" rel="nofollow noreferrer">@Murch's presentation at Scaling Bitcoin</a>.</p>

CC BY-SA 3.0
2017-06-06T14:28:45.173Z
2017-06-06T14:28:45.173Z
Jestin
<p>I am attempting to build a working withdrawal system where users can withdraw funds in BTC. I am required to estimate the fee before allowing them to withdraw to include it in their payment. I was able to determine the maximum estimated fee based on inputs and outputs of the transaction. I had assumed that the transactions would have 1 input and 2 outputs as when I was testing that was the outcome. I am now seeing transactions with multiple inputs and outputs making the transaction size larger, therefore, increasing the fee. This is problematic for me as I am having to pay for these fees. I need to be able to determine the inputs and outputs of the transaction before I send it to the blockchain.</p>

CC BY-SA 3.0
2017-06-04T12:41:53.633Z
Possible duplicate of [How to calculate transaction size before sending](https://bitcoin.stackexchange.com/questions/1195/how-to-calculate-transaction-size-before-sending)
pebwindkraft
CC BY-SA 3.0
2017-06-05T06:52:56.290Z
I am trying to determine inputs/outputs, not the formula to a transaction size
Monstrum
CC BY-SA 3.0
2017-06-06T05:54:44.880Z
I don't really see your question, but I think the term you're looking for is "Coin selection" or "Coin control". This question might help explain the issue at hand: [What is the coin selection algorithm?](https://bitcoin.stackexchange.com/q/1077/5406). Do you know what a [UTXO](https://bitcoin.stackexchange.com/q/4301/5406) is?
Murch
<transactions><transaction-fees><output><transaction-input>
Determine inputs/outputs of a transaction before sending
Monstrum
# Determine inputs/outputs of a transaction before sending

(Asked by: username_0 on 2017-06-04)

I am attempting to build a working withdrawal system where users can withdraw funds in BTC. I am required to estimate the fee before allowing them to withdraw to include it in their payment. I was able to determine the maximum estimated fee based on inputs and outputs of the transaction. I had assumed that the transactions would have 1 input and 2 outputs as when I was testing that was the outcome. I am now seeing transactions with multiple inputs and outputs making the transaction size larger, therefore, increasing the fee. This is problematic for me as I am having to pay for these fees. I need to be able to determine the inputs and outputs of the transaction before I send it to the blockchain.

**Tags:** transactions, transaction-fees, output, transaction-input

> **Comments:**
> **username_1**: Possible duplicate of [How to calculate transaction size before sending](https://bitcoin.stackexchange.com/questions/1195/how-to-calculate-transaction-size-before-sending)  
> **username_0**: I am trying to determine inputs/outputs, not the formula to a transaction size  
> **username_2**: I don't really see your question, but I think the term you're looking for is "Coin selection" or "Coin control". This question might help explain the issue at hand: [What is the coin selection algorithm?](https://bitcoin.stackexchange.com/q/1077/5406). Do you know what a [UTXO](https://bitcoin.stackexchange.com/q/4301/5406) is?  

---

## 1 answers

### Answer by username_3 on 2017-06-06. Score: 0 | Accepted answer

If you are constructing your own transactions (rather than letting a wallet application do it for you), then you get to *choose* which inputs and outputs you use in the transaction. For that matter, you also get to choose the fee for the transaction, since any leftover from the sum of the inputs minus the sum of the outputs is the mining fee. Just remember that leaving too low of a fee will result in long delays of unconfirmed transactions.

Based on your needs, you can choose to use different [coin selection algorithms](https://bitcoin.stackexchange.com/q/1077/5406). A coin selection algorithm's purpose is to select inputs from the pool of [UTXOs](https://bitcoin.stackexchange.com/q/4301/5406) that you control. Selecting too many for a single transaction will result in a higher fee. However, refusing to use smaller UTXOs will leave your entire pool comprised of small ones, forcing you to use them (and pay higher fees) until your pool recovers.

There are pros and cons to different algorithms, especially when you are concerned with fees, so be sure to understand the ramifications of your decision. A good place to start might be [@username_2's presentation at Scaling Bitcoin](https://www.youtube.com/watch?v=_Z0ID-0DOnc).


---

