Bitcoin Forum
May 10, 2024, 05:05:45 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: calculation fee from change  (Read 1032 times)
init1 (OP)
Jr. Member
*
Offline Offline

Activity: 43
Merit: 1


View Profile
November 23, 2015, 11:27:49 AM
 #1

Hello,

prepared rawTx by all tx output, added destination and change address

Code:
'{"sedtination":11, "change":9}'

how to calculate fee ? can I add fee automatically from change ?

Thanks.
Even in the event that an attacker gains more than 50% of the network's computational power, only transactions sent by the attacker could be reversed or double-spent. The network would not be destroyed.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715360745
Hero Member
*
Offline Offline

Posts: 1715360745

View Profile Personal Message (Offline)

Ignore
1715360745
Reply with quote  #2

1715360745
Report to moderator
1715360745
Hero Member
*
Offline Offline

Posts: 1715360745

View Profile Personal Message (Offline)

Ignore
1715360745
Reply with quote  #2

1715360745
Report to moderator
1715360745
Hero Member
*
Offline Offline

Posts: 1715360745

View Profile Personal Message (Offline)

Ignore
1715360745
Reply with quote  #2

1715360745
Report to moderator
shorena
Copper Member
Legendary
*
Offline Offline

Activity: 1498
Merit: 1520


No I dont escrow anymore.


View Profile WWW
November 23, 2015, 12:18:11 PM
 #2

Fee = sum of inputs - sum of outputs

The fee is every satoshi you do not spend in one of the outputs. You can substract that from the change or from the payment, but usually change makes more sense.

Im not really here, its just your imagination.
init1 (OP)
Jr. Member
*
Offline Offline

Activity: 43
Merit: 1


View Profile
November 24, 2015, 08:33:48 AM
 #3

More example please. Found next
Code:
sendrawtransaction "hexstring" ( allowhighfees )
if i add allowhighfees option it will calculate from change automatic ? 
shorena
Copper Member
Legendary
*
Offline Offline

Activity: 1498
Merit: 1520


No I dont escrow anymore.


View Profile WWW
November 24, 2015, 09:58:33 AM
 #4

More example please. Found next
Code:
sendrawtransaction "hexstring" ( allowhighfees )
if i add allowhighfees option it will calculate from change automatic ? 

No, this will only allow you to pay a high fee.

An example would be you have 2 inputs worth 2 BTC each (so 4 BTC in total) and want to spend 2.5 BTC with a 0.001 BTC fee.

You would create an output for 2.5 BTC to the address of the recipient and an output of (4-2.5-0.001) 1.499 BTC as change to an address of yourself. The fee will be the rest. You dont have to set the fee directly when creating a rawtransaction.

Maybe sendfrom[1] is what you are looking for?

[1] https://bitcoin.org/en/developer-reference#sendfrom

Im not really here, its just your imagination.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
November 24, 2015, 03:04:51 PM
 #5

More example please.
- snip -

Sure.  Lets grab a random transaction out of the blockchain and take a look at it. I'll pick txID 44d1430102af06489c1a82ae7bb285f684e32a849907b2e11aca67651ac5e292 for this example:

The transaction spends, as an input, the second output (vout=1) of transaction 452d20b51161a8177ce40fa569a26947406d1dae9e40f8472948623d06356ede.
The sum of the values of all the inputs is 26.85898588 BTC.

It sends 3 BTC to 1FeFue5cHarn2B8ntC4wWdfY7eJa3nyUgY
It sends 23.85888588 BTC to 141SFBdbrK9YD4J71LqJw7Fb9vqwYfSmeX
The sum of the values of all the outputs is 26.85888588 BTC.

This leaves 0.0001 BTC unaccounted for in the transaction.  All unaccounted for amounts are defined as transaction fees.  Therefore, since the transaction used 26.85898588 BTC of value for the inputs and only 26.85888588 BTC for the outputs, the miners take the unaccounted for 0.0001 BTC and pay it to themselves as a transaction fee.

Using createrawtransaction in Bitcoin Core the transaction could have been created as follows:

Code:
createrawtransaction [{\"txid\":\"44d1430102af06489c1a82ae7bb285f684e32a849907b2e11aca67651ac5e292\",\"vout\":1}] {\"1FeFue5cHarn2B8ntC4wWdfY7eJa3nyUgY\":3.0, \"141SFBdbrK9YD4J71LqJw7Fb9vqwYfSmeX\": 23.85888588}
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!