Bitcoin Forum
May 12, 2024, 12:32:49 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Assistance please regarding createrawtransaction  (Read 2174 times)
DannyHamilton (OP)
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
March 27, 2013, 11:41:40 AM
 #1

Given the following usage from https://en.bitcoin.it/wiki/Raw_Transactions

Quote
createrawtransaction [{"txid":txid,"vout":n},...] {address:amount,...}

I'm assuming I can type the following in the Bitcoin-Qt console window:

Quote
createrawtransaction [{\"txid\":\"7e252ce7176a7a585ed99d4a6ecfb005f34b34574fc933748113a7aa755f824d\",\"vout\":1}] {\"13YteEVecArYiRETzyccPvG7nrTrjg1mhD\":5.40537687}

The balance of the output being used is (at the time of writing this post) 5.40537687 according to this:
https://blockchain.info/tx/7e252ce7176a7a585ed99d4a6ecfb005f34b34574fc933748113a7aa755f824d

This should create a transaction that has no transaction fee, correct?

My first concern before trying this is that I thought that Bitcoin-Qt represented balances internally as integers, so I'm not certain if I should use 5.40537687 for the "amount" or if I should use 540537687

1715517169
Hero Member
*
Offline Offline

Posts: 1715517169

View Profile Personal Message (Offline)

Ignore
1715517169
Reply with quote  #2

1715517169
Report to moderator
Bitcoin mining is now a specialized and very risky industry, just like gold mining. Amateur miners are unlikely to make much money, and may even lose money. Bitcoin is much more than just mining, though!
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715517169
Hero Member
*
Offline Offline

Posts: 1715517169

View Profile Personal Message (Offline)

Ignore
1715517169
Reply with quote  #2

1715517169
Report to moderator
1715517169
Hero Member
*
Offline Offline

Posts: 1715517169

View Profile Personal Message (Offline)

Ignore
1715517169
Reply with quote  #2

1715517169
Report to moderator
Stephen Gornick
Legendary
*
Offline Offline

Activity: 2506
Merit: 1010


View Profile
March 27, 2013, 01:09:12 PM
 #2

The balance of the output being used is (at the time of writing this post) 5.40537687 according to this:
https://blockchain.info/tx/7e252ce7176a7a585ed99d4a6ecfb005f34b34574fc933748113a7aa755f824d

This wasn't your question but there is no "balance" for a transaction.  A transaction output is for a specific amount, period.  That amount is immutable -- it won't change.  Once the transaction is spent it will still be that same amount, it just will have been spent so some views of it might show a balance of 0, but the amount never changed.

My first concern before trying this is that I thought that Bitcoin-Qt represented balances internally as integers, so I'm not certain if I should use 5.40537687 for the "amount" or if I should use 540537687

The amount is decimal.

Here's an example.
 - http://bitcointalk.org/index.php?topic=104512.msg1146645#msg1146645

But this is what Testnet is for!   (Or use a transaction with an amount small enough so an error isn't costly)


Unichange.me

            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █


DannyHamilton (OP)
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
March 27, 2013, 02:50:57 PM
 #3

- snip -
This wasn't your question but there is no "balance" for a transaction.  A transaction output is for a specific amount, period.  That amount is immutable -- it won't change.  Once the transaction is spent it will still be that same amount, it just will have been spent so some views of it might show a balance of 0, but the amount never changed.

Yes, I realize this.  I wrote my post in the wee hours of the morning after a long night of drinking and gambling, so I may not have phrased it properly.  I suppose it would have been clearer if I'd have said "the value of the output", rather than "the balance of the output"
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1078


Ian Knowles - CIYAM Lead Developer


View Profile WWW
March 27, 2013, 02:53:40 PM
 #4

I can confirm that the value is decimal (have done many raw tx's) and as long as you are spending all of the UTXO then all is good.

BTW I have a simple web page for doing such simple raw tx's (its included in the CIYAM Safe distro) also if you have bitcoin-qt or bitcoind running then  "decoderawtransaction" is a good way to "double check" the tx before you send it.

(although I would not recommend sending raw tx's after a few too many drinks)

Smiley

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
DannyHamilton (OP)
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
March 27, 2013, 03:10:43 PM
 #5

(although I would not recommend sending raw tx's after a few too many drinks)
Agreed. I figured I'd ask the question before going to bed so that the answer would be there when I woke up.

 Wink

I realize that if I screw up a transaction, I can end up with a significantly larger than expected "transaction fee".  I'm taking this slow and careful, and I really hope I don't screw up with real bitcoins. Maybe I'll look into Testnet, I'd really like to get comfortable with the process. I've been thinking about a handful of bitcoin tools (such as an automatic dust sweeper, and a few new coin selection routines).
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1078


Ian Knowles - CIYAM Lead Developer


View Profile WWW
March 27, 2013, 03:12:03 PM
 #6

Am sure you'll do fine - but please don't try and break my 111 BTC fee record!

Cheesy

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
pc
Sr. Member
****
Offline Offline

Activity: 253
Merit: 250


View Profile
March 27, 2013, 03:15:10 PM
 #7

If you want an example of using the raw API, check out the "spendfrom" python script in bitcoin's contrib directory: https://github.com/bitcoin/bitcoin/tree/master/contrib/spendfrom
DannyHamilton (OP)
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
March 27, 2013, 03:15:28 PM
 #8

Am sure you'll do fine - but please don't try and break my 111 BTC fee record!

Yes, I'm aware of it.  It's one of the main reasons that I'm hesitant and double checking everything I do.  Additionally, I'll create a fresh wallet and only send a handful of bitcoins to an address at that wallet to work with (significantly reducing my risk exposure).
kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1025



View Profile
March 27, 2013, 04:48:44 PM
 #9

Don't look at a website to find the value of an unspent output.  Use listunspent, or getrawtransaction/decoderawtransaction.

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
DannyHamilton (OP)
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
March 27, 2013, 06:59:05 PM
 #10

Don't look at a website to find the value of an unspent output.  Use listunspent, or getrawtransaction/decoderawtransaction.

Yes. I was using listunspent, but thanks.
themerkle
Full Member
***
Offline Offline

Activity: 202
Merit: 100


View Profile
July 28, 2015, 09:20:12 PM
 #11

I am sorry for necroing this thread but I thought this might be of use to some. I was having a hard time calling the createrawtransaction function through an RPC client. I didn't see this anywhere else until it worked.

bitcoin-cli -regtest createrawtransaction '''
    [
      {
        "txid": "'334a94b6a337e86cc88afb1db5a22fa9b1b44546e0b1823c9f1d853be1c6177d'",
        "vout": '0'
      }
    ]
    ''' '''
    {
      "'1KupPMonFcC1Qn6a75kexDZPvwHRuD679s'": 49.9999
    }'''

This string will work. and bitcoin-cli should output (I used a random address on blockchain.info for this tx so its probably not valid):

01000000017d17c6e13b851d9f3c82b1e04645b4b1a92fa2b51dfb8ac86ce837a3b6944a3300000 00000ffffffff01f0ca052a010000001976a914cf6f731517e7e0c66d97c946d4fda0f98f7a23cd 88ac00000000

One important detail I found when messing around with the rpc client is that the vout has to be an integer. All the variables have to have matching types meaning the amount along with the vout has to be an integer and not a string. If you get a code 500 check your parameter types.




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!