Bitcoin Forum
July 20, 2018, 09:39:34 AM *
News: Latest stable version of Bitcoin Core: 0.16.1  [Torrent]. (New!)
 
   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
Merit: 0


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.
1532079574
Hero Member
*
Offline Offline

Posts: 1532079574

View Profile Personal Message (Offline)

Ignore
1532079574
Reply with quote  #2

1532079574
Report to moderator
1532079574
Hero Member
*
Offline Offline

Posts: 1532079574

View Profile Personal Message (Offline)

Ignore
1532079574
Reply with quote  #2

1532079574
Report to moderator
Bitcoin addresses contain a checksum, so it is very unlikely that mistyping an address will cause you to lose money.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1532079574
Hero Member
*
Offline Offline

Posts: 1532079574

View Profile Personal Message (Offline)

Ignore
1532079574
Reply with quote  #2

1532079574
Report to moderator
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 1470
Merit: 1456


3F1Y9yquzvY6RWvKbw2n2zeo9V5mvBhADU


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
Merit: 250


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!