Bitcoin Forum
December 16, 2017, 06:55:10 PM *
News: Latest stable version of Bitcoin Core: 0.15.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: raw tx and change address  (Read 839 times)
init1
Jr. Member
*
Offline Offline

Activity: 43


View Profile
November 03, 2015, 09:50:15 AM
 #1

Hello

Want to prepare raw TX with change address.
according to the manual https://bitcoin.org/en/developer-examples#simple-raw-transaction

input had 50.0000 bitcoins and our output ($NEW_ADDRESS) is being paid 49.9999 bitcoins, so the transaction will include a fee of 0.0001 bitcoins. If we had paid $NEW_ADDRESS only 10 bitcoins with no other changes to this transaction, the transaction fee would be a whopping 40 bitcoins

I should add change address if I want to save change.

prepared Raw tx like this
Code:
./bitcoin-cli createrawtransaction
'[{"txid":"fba4b0a1e11b68c587aae3578844d68131c807913767a1efc9a699d38ecd9f06",
"vout":1,
"scriptPubKey":"a914e8fa0f97c663ba132bd81e6d657c46825d390e6c87",
"redeemscript":"524104d9546728bb1d1bf309ef3c2c7278d8d306052ecf7dc81443f16e75ae607099dfcfc573a3e71553bd8321d91c209bab03aa999befa6e77734c0f4dd34ef78ebfd41041050ff637a97fa462dffa19d0bc013869f6231895019bd9f263a0a55a067665cfca4473aab1dc38e8aecf359e23ce6bb35ff900bc84fdd890a3b982ea50dd92f4104e086dce7893384cbfa89fbbf7d33de3f1ee01279a1e9810d952f1c440e91fc7ee7cb9cf070dfbdee397e123c363d140221e81610b7bd695905fbf198edfd71a153ae"}]'
 '{"143UX8t7LNiAf1dNPqyWDYQ1Gedbk27R7b":0.0001}'

Could you please share example how to prepare raw tx with address for the change and fee  ?

Thanks.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1513450510
Hero Member
*
Offline Offline

Posts: 1513450510

View Profile Personal Message (Offline)

Ignore
1513450510
Reply with quote  #2

1513450510
Report to moderator
achow101
Moderator
Legendary
*
Offline Offline

Activity: 1246


17kKQppUsngUiByDsce4JXoZEjjpvX9bpR


View Profile WWW
November 03, 2015, 12:52:17 PM
 #2

Just add a second output the same way you added the first output.

fbueller
Sr. Member
****
Offline Offline

Activity: 412


View Profile
November 05, 2015, 03:38:02 PM
 #3

If you were doing:

in: 50 coin input,
fee: 0.0001
out: 10
 39.9999 change

Quote
...snippet...
'{"143UX8t7LNiAf1dNPqyWDYQ1Gedbk27R7b":"10","your-change-address", "39.9999"}'

And, remember to never use floats (BTC amounts) in additions, subtractions - use satoshis instead.

Bitwasp Developer.
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!