Bitcoin Forum
May 07, 2024, 09:35:47 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Raw transaction fee  (Read 740 times)
jwz104 (OP)
Newbie
*
Offline Offline

Activity: 3
Merit: 0


View Profile
March 04, 2017, 06:44:17 PM
 #1

When I send a raw transaction, all bitcoins from the unspent transactions that I have selected will be send.
But how can I set the fee?
Do I have to send what I have paid to much back to my own address?

And I see a lot of people talking about that I can't know the fee before creating the transaction. But when I use 3 unspent transactions, and sum the amounts. I know exacly how much I send right?
1715074547
Hero Member
*
Offline Offline

Posts: 1715074547

View Profile Personal Message (Offline)

Ignore
1715074547
Reply with quote  #2

1715074547
Report to moderator
1715074547
Hero Member
*
Offline Offline

Posts: 1715074547

View Profile Personal Message (Offline)

Ignore
1715074547
Reply with quote  #2

1715074547
Report to moderator
1715074547
Hero Member
*
Offline Offline

Posts: 1715074547

View Profile Personal Message (Offline)

Ignore
1715074547
Reply with quote  #2

1715074547
Report to moderator
BitcoinCleanup.com: Learn why Bitcoin isn't bad for the environment
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715074547
Hero Member
*
Offline Offline

Posts: 1715074547

View Profile Personal Message (Offline)

Ignore
1715074547
Reply with quote  #2

1715074547
Report to moderator
1715074547
Hero Member
*
Offline Offline

Posts: 1715074547

View Profile Personal Message (Offline)

Ignore
1715074547
Reply with quote  #2

1715074547
Report to moderator
1715074547
Hero Member
*
Offline Offline

Posts: 1715074547

View Profile Personal Message (Offline)

Ignore
1715074547
Reply with quote  #2

1715074547
Report to moderator
Quickseller
Copper Member
Legendary
*
Offline Offline

Activity: 2870
Merit: 2298


View Profile
March 04, 2017, 06:56:26 PM
Merited by ABCbits (1)
 #2

The transaction fee is the difference between the sum of the inputs and the sum of the outputs in your transaction. There is nothing in the raw transaction that explicitly says the amount of the transaction fee.

Most block explorers will display this information because it is useful to the end user.
HI-TEC99
Legendary
*
Offline Offline

Activity: 2772
Merit: 2846



View Profile
March 04, 2017, 08:28:15 PM
Last edit: March 04, 2017, 10:38:49 PM by HI-TEC99
 #3

The total fee you pay depends on the length of the raw transaction. The length of the raw transaction generally depends on how many addresses are involved in it.

The transaction linked below is one address sending all its coins to one other address, with no change left over. It's one of the shortest type of transactions.


https://blockchain.info/tx/13f849eeffb2b35578c3a1b2841510f784ce0b6224a199c755594faa2ee1c8fd

This is the raw transaction.

Quote
0100000001f82d80a303764d640f8052a49c576a6172ba6ebd10b2a0c3fef7d415123d330b00000 0006a47304402204a915639a3b24827934b41e7986834750667dbdab6a03d946ebdc127537dc5c1 0220687d7d83e69ef61dd05efd58a09d5babab06ca1e9b1b60c9ccae4bcf46b700600121038ba44 8c24496282461eb694dd1230b0fda2368312d505b5871730f49fc158b34ffffffff01ac550c0000 0000001976a9146d4fc1569d47d2f4f1f04da5000df8487c6942bb88ac00000000



The next transaction linked below is five addresses sending some coins to another address, and the change left over to a second address.

https://blockchain.info/tx/720cd86ca414ecaa6018a359b6b056f52dea311faa3f05071b73f485eea1d3a4

This is the raw transaction. You can see how much longer it is compared to the first. It's longer because it has seven addresses involved in it.

Quote
0100000005ce6b0d5ec487631ff518ead9228ed8db8951fce61e5141e71109577a24b6c3bf01000 0006b483045022100d6a9f0c447fe0101f887135c66843cf58ac7adeed51ab8b6a23ced11cce88d 8c02204d90a4723a992bc751336a33673ed77ae38e84f38a4565d25cc9f9f1f338e6750121033e5 ab8d934b2210a7d7e04e9ea132b00eb785bfd3d513a0d1484670cf41832a3feffffffac9288c540 52639b503bfc2c628c8a4779623f0b54d12bbc6f835bb0480a2adc010000006a473044022050721 720a8c109b3f64b70b779a08fb93b74dde267015dc4820bc346d308b3e5022021d16fc044c12d24 ca477cf66ead7227ee02666f94fa6bb5019e512e8517dd7b012103f647181a56e3b326c962bd5fe 756f1a0be300bf8bf174187d43ea31535ca6790feffffff47b4b1d06dcf189aec8a67d2c44dfdac bfef611147c717b3afd862baa3adc904010000006b483045022100838e3faafefb61063a1f42502 d65355127959ea23166af66e8c35ca167fbef180220787c466efd2871ca959f6d7c0f587894aa1a bcbc9e01383273effa99c248292f01210340ea86b6b173041feb506034a6cdc9952435e72fa66f0 c4014cade7e4bed58a8feffffff73921325906fbc76adb54fb63671484937032d19609304949817 572b14d667f9010000006a47304402201b0534fd3cfba88ea3e09d8a66eabfbe39d487aec404853 fe89d0360770db5a902201f4cb68b4540fe8616d2807107da7f1b55e8df8d2c672e695f7d9a8132 e82b7b0121020e2afcba712782337d633c4bbf60ff6946b514cf02e407d9927e0a0ed605c4cafef ffffff0112085e4d5fa9899a6a1501c0d2e3a5a3887479c7985f4f1fbc6bb2f977ffa000000006a 4730440220127bee117ce62ca6a69050472901c15a51b8c18842f01ce68f71f11bc2a80df002204 113b397dabea98fdd42d4abb191ec9330af74ca2dafd3e8ba5052e2e855dabb012103dc19490250 a444199e6c42616c4685a7a4e8e9d05531f3606d52215c8650a170feffffff02674b0f000000000 01976a9141f9abe4254f7b33da8059b0270c62874d55f148c88ac90028c01000000001976a914a7 0ff371cc537164b6db77534fba2732b70a080688ac4ef40600

If two transactions pay the same fee per KB, the longest transaction with the most addresses in will pay a higher total fee. The length (size) of a raw transaction is measured in KB.

Some wallets have settings that allow you to view the total fee your transaction will pay before you send it. Electrum's preferences settings let you choose the fee per KB, and you can also view the total fee you will pay after creating a transaction if you check the setting to "set transaction fee manually" in preferences.
jwz104 (OP)
Newbie
*
Offline Offline

Activity: 3
Merit: 0


View Profile
March 05, 2017, 11:00:30 AM
 #4

That makes it a bit clearer. But I still don't fully understand the raw transactions.

Here is an example of how I now think it works. Can someone correct me if a step is wrong?

I have an unspent transaction with 1 bitcoin.
I want to move 0.5 to another address.
But because the unspent transaction is 1 bitcoin, the whole bitcoin will be send.
So I send the rest back to my own address.
So there is going 0.5 to the other user. And 0.5 back to me.
Does this mean I don't pay any fee? Or do I pay fee but the user doesn't receive the full 0.5 bitcoins.
And if I for example sent 0.49 instead of 0.5 back to me. Do I now pay 0.01 fee?
And do other wallet also work with sending the rest back? I can't remember that I can any incomming transaction after I made a transaction.
mezzomix
Legendary
*
Offline Offline

Activity: 2618
Merit: 1252


View Profile
March 05, 2017, 04:17:23 PM
 #5

And if I for example sent 0.49 instead of 0.5 back to me. Do I now pay 0.01 fee?

This!
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4623



View Profile
March 05, 2017, 04:27:44 PM
 #6

The total fee you pay depends on the length of the raw transaction. The length of the raw transaction generally depends on how many addresses are involved in it.

No.

It depends on how many inputs and how many outputs are involved.

It does NOT depend on addresses at all.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4623



View Profile
March 05, 2017, 04:40:29 PM
Merited by ABCbits (4)
 #7

That makes it a bit clearer. But I still don't fully understand the raw transactions.

Here is an example of how I now think it works. Can someone correct me if a step is wrong?

I'll try to help.

I have an unspent transaction with 1 bitcoin.

More accurately, you have an unspent transaction OUTPUT valued at 1 bitcoin.

I want to move 0.5 to another address.

You want to create a new transaction that has an output associated with another address and valued at 0.5 bitcoins

But because the unspent transaction is 1 bitcoin, the whole bitcoin will be send.

The unspent transaction OUTPUT is valued at 1 bitcoin.
Because of that, the whole OUTPUT (valued at 1 bitcoin) will be spent when it is used as an input to your new transaction.

So I send the rest back to my own address.

In your new transaction you create a second output that is associated with an address for which you have the private key and which is valued at 0.5 bitcoins.

So there is going 0.5 to the other user. And 0.5 back to me.

There are two outputs valued at 0.5 bitcoins each.  You have the private key associated with one of the outputs, and the other user has the private key associated with the other output.

Does this mean I don't pay any fee?

This means that you built a transaction that did not include any transaction fee.

Or do I pay fee but the user doesn't receive the full 0.5 bitcoins.

If you want to do that, then you will have to reduce the value of the output that you create for the other user.

And if I for example sent 0.49 instead of 0.5 back to me. Do I now pay 0.01 fee?

Correct. If you spend an output that is valued at 1 bitcoin, and you create 2 outputs (one valued at 0.5 bitcoins and the other valued at 0.49 bitcoins) then the transaction has a fee of 0.01 bitcoins.

And do other wallet also work with sending the rest back? I can't remember that I can any incomming transaction after I made a transaction.

This is how the bitcoin transaction protocol works.  All transactions are just a list of inputs (previously unspent outputs) that supply value to the transaction, and a list of new unspent outputs that are assigned value.  The total value of all the outputs cannot exceed the total value of all the inputs (if the sum of the outputs exceeds the sum of the inputs, then the transaction is INVALID and rejected by all nodes). If the sum of the outputs is LESS THAN the sum of the inputs, then the remaining value is a transaction fee that the miner can assign to themselves.

The user interface of some wallet programs might not be designed to show all these details (since they can confuse those that don't have a technical understanding of what is happening).
jwz104 (OP)
Newbie
*
Offline Offline

Activity: 3
Merit: 0


View Profile
March 05, 2017, 05:07:58 PM
 #8

DannyHamilton thanks a lot! It is all clear now.

So it is possible to set the fee to my needs(For example 0.01 per transaction).

I only need to make something so the user who does the transaction doesn't see the transaction that comes back.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!