user133417: Today I created my very first transaction of bitcoin on the testnet programmatically. I created a wallet A, first generated my private key and I generated a deposit address. I deposited 0.00074 btc into it and waited till 6 confirmations so I can send bitcoin to somebody else. I decided to send 0.0000646 BTC to different address B and the transaction was successful however I noticed the transaction fee was 0.0006754 BTC so literally the rest of the balance from wallet A was used as a fee. I found this in the documentation of the api I am using apidocs
"When the amount of funds that the recipient should receive is lower than the amount of funds from the UTXOs, the difference is used as a transaction fee."
Does that mean that for example if I deposit 1BTC to a specific address, if I want to send a certain amount of btc thats significantly smaller lets say 0.1 btc, 0.9btc will be used as a fee?? Then what If I want to send only a certain amount of money and dont want to pay such a massive fee do I have to create a completely new deposit address each time I want to send bitcoin and top it up only with the amount I want to send + fee? There must be a way to send small amounts I sent a small amounts from exchanges but did not see what logic is behind, could somebody please explain and give me some example?

user13866: You should send some money back to yourself as change. Normally wallets do this automatically for you. Wallets normally generate a new change address for each transaction.
So if A has a UTXO of 1 BTC and wants to send 0.1 BTC to B with a fee of 0.001BTC the transaction would be

Inputs

1 BTC (from A)


Outputs

0.1 BTC to B
0.899 BTC to A



This leaves 0.001 BTC unaccounted for which is the transaction fee to be claimed by a miner.

133417: <p>Today I created my very first transaction of bitcoin on the testnet programmatically. I created a wallet A, first generated my private key and I generated a deposit address. I deposited 0.00074 btc into it and waited till 6 confirmations so I can send bitcoin to somebody else. I decided to send 0.0000646 BTC to different address B and the transaction was successful however I noticed the transaction fee was 0.0006754 BTC so literally the rest of the balance from wallet A was used as a fee. I found this in the documentation of the api I am using <a href="https://docs.tatum.io/rest/blockchain/b3A6NDE2NTc3NTg-send-bitcoin-to-blockchain-addresses" rel="nofollow noreferrer">apidocs</a>
&quot;When the amount of funds that the recipient should receive is lower than the amount of funds from the UTXOs, the difference is used as a transaction fee.&quot;<br />
Does that mean that for example if I deposit 1BTC to a specific address, if I want to send a certain amount of btc thats significantly smaller lets say 0.1 btc, 0.9btc will be used as a fee?? Then what If I want to send only a certain amount of money and dont want to pay such a massive fee do I have to create a completely new deposit address each time I want to send bitcoin and top it up only with the amount I want to send + fee? There must be a way to send small amounts I sent a small amounts from exchanges but did not see what logic is behind, could somebody please explain and give me some example?</p>
 13866: <p>You should send some money back to yourself as change. Normally wallets do this automatically for you. Wallets normally generate a new change address for each transaction.</p>
<p>So if A has a UTXO of 1 BTC and wants to send 0.1 BTC to B with a fee of 0.001BTC the transaction would be</p>
<ul>
<li>Inputs
<ul>
<li>1 BTC (from A)</li>
</ul>
</li>
<li>Outputs
<ul>
<li>0.1 BTC to B</li>
<li>0.899 BTC to A</li>
</ul>
</li>
</ul>
<p>This leaves 0.001 BTC unaccounted for which is the transaction fee to be claimed by a miner.</p>
