Bitcoin Forum
April 19, 2024, 11:01:07 PM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 »  All
  Print  
Author Topic: Raw Transactions API... Am I using it correctly?  (Read 4871 times)
isis (OP)
Full Member
***
Offline Offline

Activity: 154
Merit: 102


View Profile
August 29, 2012, 08:50:21 PM
Merited by ABCbits (2)
 #1

Hi all,

I've been trying to work with the raw transactions API since it's crucial to something I'm working on and I'm encountering a problem.
Code:
createrawtransaction [{"txid":eb63d5d53cd906b5cf75a014e1bcf1c0198ae58d378d45dbfa15045ac89a38ac,"vout":0}] {1FQvMNzFJRf2nFJbhri2pWEVMqTtdLSCmA:2336129790}

As far as I can tell the above should work, but when I put it into the debug console I get the following error.
Code:
Error: Error parsing JSON:[{txid:eb63d5d53cd906b5cf75a014e1bcf1c0198ae58f378d45dbfa15045ac89a38ac,vout:0}]

I've a hunch I'm calling it wrong, however it looks well formed to me so I'm at a loss.

I'm using v0.7.0rc1-beta

Thanks for any information!

Interested in OpenPay?
https://github.com/openpay
Donate to show your appreciation and support the effort!

1LMDCSAwjhT2Vp1sSf62dybEYW3MYpsoZj

Pyramining Links - Help OpenPay and get a 10% bonus on your funds.
http://pyramining.com/referral/zre9ysgqt
http://pyramining.com/referral/ans9km72g
http://pyramining.com/referral/f3k4xebzp
http://pyramining.com/referral/nc3ag2sdb
1713567667
Hero Member
*
Offline Offline

Posts: 1713567667

View Profile Personal Message (Offline)

Ignore
1713567667
Reply with quote  #2

1713567667
Report to moderator
1713567667
Hero Member
*
Offline Offline

Posts: 1713567667

View Profile Personal Message (Offline)

Ignore
1713567667
Reply with quote  #2

1713567667
Report to moderator
1713567667
Hero Member
*
Offline Offline

Posts: 1713567667

View Profile Personal Message (Offline)

Ignore
1713567667
Reply with quote  #2

1713567667
Report to moderator
Each block is stacked on top of the previous one. Adding another block to the top makes all lower blocks more difficult to remove: there is more "weight" above each block. A transaction in a block 6 blocks deep (6 confirmations) will be very difficult to remove.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713567667
Hero Member
*
Offline Offline

Posts: 1713567667

View Profile Personal Message (Offline)

Ignore
1713567667
Reply with quote  #2

1713567667
Report to moderator
Gavin Andresen
Legendary
*
qt
Offline Offline

Activity: 1652
Merit: 2216


Chief Scientist


View Profile WWW
August 29, 2012, 08:53:50 PM
Merited by ABCbits (2)
 #2

Using bitcoind on a command-line?  What operating system?

Something is stripping off the double-quotes from the "txid" and "vout" keys before it gets to bitcoind.  If you're using bash on linux, then put single quotes around the arguments.  Like this:

Code:
createrawtransaction '[{"txid":eb63d5d53cd906b5cf75a014e1bcf1c0198ae58d378d45dbfa15045ac89a38ac,"vout":0}]' '{"1FQvMNzFJRf2nFJbhri2pWEVMqTtdLSCmA":23.36129790}'

I also corrected the second argument, the address is a string (strings in JSON are always "whatever") and the amount is decimal number-of-bitcoins.

How often do you get the chance to work on a potentially world-changing project?
gmaxwell
Moderator
Legendary
*
expert
Offline Offline

Activity: 4158
Merit: 8382



View Profile WWW
August 29, 2012, 09:28:35 PM
Merited by ABCbits (1)
 #3

put it into the debug console
There is a quoting bug with the debug console, see page 2 of the 0.7.0rc1 thread for details on a workaround.
isis (OP)
Full Member
***
Offline Offline

Activity: 154
Merit: 102


View Profile
August 30, 2012, 03:27:49 AM
 #4

put it into the debug console
There is a quoting bug with the debug console, see page 2 of the 0.7.0rc1 thread for details on a workaround.

Followed the instructions in that thread which amounts to escaping all your quotes in the debug console and it's the same issue but at least it's not stripping the quotes anymore.

Interested in OpenPay?
https://github.com/openpay
Donate to show your appreciation and support the effort!

1LMDCSAwjhT2Vp1sSf62dybEYW3MYpsoZj

Pyramining Links - Help OpenPay and get a 10% bonus on your funds.
http://pyramining.com/referral/zre9ysgqt
http://pyramining.com/referral/ans9km72g
http://pyramining.com/referral/f3k4xebzp
http://pyramining.com/referral/nc3ag2sdb
isis (OP)
Full Member
***
Offline Offline

Activity: 154
Merit: 102


View Profile
August 30, 2012, 03:44:52 AM
 #5

put it into the debug console
There is a quoting bug with the debug console, see page 2 of the 0.7.0rc1 thread for details on a workaround.

Followed the instructions in that thread which amounts to escaping all your quotes in the debug console and it's the same issue but at least it's not stripping the quotes anymore.

I don't think this is an issue with the debug console.  I tried it from the command line both with and without escaping the quotes and I'm still getting the same issue.

Interested in OpenPay?
https://github.com/openpay
Donate to show your appreciation and support the effort!

1LMDCSAwjhT2Vp1sSf62dybEYW3MYpsoZj

Pyramining Links - Help OpenPay and get a 10% bonus on your funds.
http://pyramining.com/referral/zre9ysgqt
http://pyramining.com/referral/ans9km72g
http://pyramining.com/referral/f3k4xebzp
http://pyramining.com/referral/nc3ag2sdb
gmaxwell
Moderator
Legendary
*
expert
Offline Offline

Activity: 4158
Merit: 8382



View Profile WWW
August 30, 2012, 03:58:23 AM
 #6

Followed the instructions in that thread which amounts to escaping all your quotes in the debug console and it's the same issue but at lea
I don't think this is an issue with the debug console.  I tried it from the command line both with and without escaping the quotes and I'm still getting the same issue.

Works fine for me:
Code:
$ ./bitcoind createrawtransaction '[{"txid":"eb63d5d53cd906b5cf75a014e1bcf1c0198ae58d378d45dbfa15045ac89a38ac","vout":0}]' '{"1GMaxweLLbo8mdXvnnC19Wt2wigiYUKgEB":23.35}'
0100000001ac389ac85a0415fadb458d378de58a19c0f1bce114a075cfb506d93cd5d563eb0000000000ffffffff01c0452d8b000000001976a914a86e8ee2a05a44613904e18132e49b2448adc4e688ac00000000
Feel free to sign and submit if you have any doubt. Tongue (though I don't seem to have that input in my mempool or blockchain)
marcus_of_augustus
Legendary
*
Offline Offline

Activity: 3920
Merit: 2348


Eadem mutata resurgo


View Profile
August 30, 2012, 04:43:22 AM
 #7

Tagged.

Diapolo
Hero Member
*****
Offline Offline

Activity: 769
Merit: 500



View Profile WWW
August 30, 2012, 05:01:31 AM
 #8

If you are using Windows replace the '-char with \".

Dia

Liked my former work for Bitcoin Core? Drop me a donation via:
1PwnvixzVAKnAqp8LCV8iuv7ohzX2pbn5x
bitcoin:1PwnvixzVAKnAqp8LCV8iuv7ohzX2pbn5x?label=Diapolo
isis (OP)
Full Member
***
Offline Offline

Activity: 154
Merit: 102


View Profile
August 30, 2012, 01:41:55 PM
 #9

Followed the instructions in that thread which amounts to escaping all your quotes in the debug console and it's the same issue but at lea
I don't think this is an issue with the debug console.  I tried it from the command line both with and without escaping the quotes and I'm still getting the same issue.

Works fine for me:
Code:
$ ./bitcoind createrawtransaction '[{"txid":"eb63d5d53cd906b5cf75a014e1bcf1c0198ae58d378d45dbfa15045ac89a38ac","vout":0}]' '{"1GMaxweLLbo8mdXvnnC19Wt2wigiYUKgEB":23.35}'
0100000001ac389ac85a0415fadb458d378de58a19c0f1bce114a075cfb506d93cd5d563eb0000000000ffffffff01c0452d8b000000001976a914a86e8ee2a05a44613904e18132e49b2448adc4e688ac00000000
Feel free to sign and submit if you have any doubt. Tongue (though I don't seem to have that input in my mempool or blockchain)


There are some significant differences between what I pasted and this one.
First is the use of ' to wrap the parameters.  Second is the quoting of both the keys and the values in the txid/vout pairs whereas I only had the keys quoted.  Finally you've quoted the send to address.

Nevertheless even a copy and paste of your command straight into the command prompt, or the debug console doesn't work here, same JSON parsing error in both instances.  

I also tried to replace ' with \" to see if that would work and it's the same error.

I'm curious, are you running the RC1 or something built from sources?  

Here are my relevant system specs.
Windows Vista SP2 64bit
Bitcoin version v0.7.0rc1-beta

Interested in OpenPay?
https://github.com/openpay
Donate to show your appreciation and support the effort!

1LMDCSAwjhT2Vp1sSf62dybEYW3MYpsoZj

Pyramining Links - Help OpenPay and get a 10% bonus on your funds.
http://pyramining.com/referral/zre9ysgqt
http://pyramining.com/referral/ans9km72g
http://pyramining.com/referral/f3k4xebzp
http://pyramining.com/referral/nc3ag2sdb
gmaxwell
Moderator
Legendary
*
expert
Offline Offline

Activity: 4158
Merit: 8382



View Profile WWW
August 30, 2012, 02:53:28 PM
 #10

There are some significant differences between what I pasted and this one.
First is the use of ' to wrap the parameters.  Second is the quoting of both the keys and the values in the txid/vout pairs whereas I only had the keys quoted.  Finally you've quoted the send to address.
Yes, and I asked you to see the other thread for the workaround quoting pattern for the debug console. Diapolo provided the quoting style for windows here— you didn't specify what OS you were on before.  I tested that on RC1 just for you.
Gavin Andresen
Legendary
*
qt
Offline Offline

Activity: 1652
Merit: 2216


Chief Scientist


View Profile WWW
August 30, 2012, 04:02:58 PM
 #11

Disclaimer: I don't do Windows.

But according to a quick google search, caret is the Windows cmd.exe escape character, and [] and {} are NOT special characters to cmd.exe.

So maybe this?

Code:
bitcoind.exe createrawtransaction [{^"txid^":^"eb63d5d53cd906b5cf75a014e1bcf1c0198ae58d378d45dbfa15045ac89a38ac^",^"vout^":0}] {^"1GMaxweLLbo8mdXvnnC19Wt2wigiYUKgEB^":23.35}

How often do you get the chance to work on a potentially world-changing project?
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1075


Ian Knowles - CIYAM Lead Developer


View Profile WWW
August 30, 2012, 04:10:40 PM
 #12

So maybe this?

Code:
C:\Bin>args  [{^"txid^":^"eb63d5d53cd906b5cf75a014e1bcf1c0198ae58d378d45dbfa15045ac89a38ac^",^"vout^":0}] {^"1GMaxweLLbo8md
XvnnC19Wt2wigiYUKgEB^":23.35}
arg[ 0 ] = 'C:\Bin\args.exe'
arg[ 1 ] = '[{txid:eb63d5d53cd906b5cf75a014e1bcf1c0198ae58d378d45dbfa15045ac89a38ac,vout:0}]'
arg[ 2 ] = '{1GMaxweLLbo8mdXvnnC19Wt2wigiYUKgEB:23.35}'

Tested the argument parsing using a small test program I wrote for Windows - it looks to me like that should do the trick.

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

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
Gavin Andresen
Legendary
*
qt
Offline Offline

Activity: 1652
Merit: 2216


Chief Scientist


View Profile WWW
August 30, 2012, 04:12:48 PM
 #13

mmm, no.

To be valid JSON, arg[1] must be:
Code:
[{"txid":"eb63d5d53cd906b5cf75a014e1bcf1c0198ae58d378d45dbfa15045ac89a38ac","vout":0}]

WTF is Windows doing with the arguments?

How often do you get the chance to work on a potentially world-changing project?
isis (OP)
Full Member
***
Offline Offline

Activity: 154
Merit: 102


View Profile
August 30, 2012, 04:13:10 PM
 #14

Disclaimer: I don't do Windows.

But according to a quick google search, caret is the Windows cmd.exe escape character, and [] and {} are NOT special characters to cmd.exe.

So maybe this?

Code:
bitcoind.exe createrawtransaction [{^"txid^":^"eb63d5d53cd906b5cf75a014e1bcf1c0198ae58d378d45dbfa15045ac89a38ac^",^"vout^":0}] {^"1GMaxweLLbo8mdXvnnC19Wt2wigiYUKgEB^":23.35}


Frankly I'm not a big windows fan either, but it's what I've got to work with for the time being.
That was a great suggestion, but it didn't work either
Code:
bitcoind.exe createrawtransaction [{^"txid^":^"eb63d5d53cd906b5cf75a014e1bcf1c0198ae58d378d45dbfa15045ac89a38ac^",^"vout^":0}]{^"1GMaxweLLbo8mdXvnnC19Wt2wigiYUKgEB^":23.35}
Produces the same...
Code:
error: Error parsing JSON:[{txid:eb63d5d53cd906b5cf75a014e1bcf1c0198ae58d378d45d
bfa15045ac89a38ac,vout:0}]

Interested in OpenPay?
https://github.com/openpay
Donate to show your appreciation and support the effort!

1LMDCSAwjhT2Vp1sSf62dybEYW3MYpsoZj

Pyramining Links - Help OpenPay and get a 10% bonus on your funds.
http://pyramining.com/referral/zre9ysgqt
http://pyramining.com/referral/ans9km72g
http://pyramining.com/referral/f3k4xebzp
http://pyramining.com/referral/nc3ag2sdb
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1075


Ian Knowles - CIYAM Lead Developer


View Profile WWW
August 30, 2012, 04:17:31 PM
Merited by ABCbits (5)
 #15

WTF is Windows doing with the arguments?

Okay - well to get my program to do that I changed the input to this:

Code:
C:\bin>args "[{\"txid\":\"eb63d5d53cd906b5cf75a014e1bcf1c0198ae58d378d45dbfa15045ac89a38ac\",\"vout\":0}]" "{\"1GMaxweLLbo8mdXvnnC19
Wt2wigiYUKgEB\":23.35}"
arg[ 0 ] = 'C:\bin\args.exe'
arg[ 1 ] = '[{"txid":"eb63d5d53cd906b5cf75a014e1bcf1c0198ae58d378d45dbfa15045ac89a38ac","vout":0}]'
arg[ 2 ] = '{"1GMaxweLLbo8mdXvnnC19Wt2wigiYUKgEB":23.35}'

(without a doubt quote characters are a huge PITA with Windows console and batch file calls)

Also this is the source of the "args" program I am using:
Code:
#include <iostream>

using namespace std;

int main( int argc, char* argv[ ] )
{
   for( int i = 0; i < argc; i++ )
      cout << "arg[ " << i << " ] = '" << argv[ i ] << "'\n";
}

(I wrote this program due to many such issues I've encountered before)

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

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
isis (OP)
Full Member
***
Offline Offline

Activity: 154
Merit: 102


View Profile
August 30, 2012, 04:38:21 PM
 #16

WTF is Windows doing with the arguments?

Okay - well to get my program to do that I changed the input to this:

Code:
C:\bin>args "[{\"txid\":\"eb63d5d53cd906b5cf75a014e1bcf1c0198ae58d378d45dbfa15045ac89a38ac\",\"vout\":0}]" "{\"1GMaxweLLbo8mdXvnnC19
Wt2wigiYUKgEB\":23.35}"
arg[ 0 ] = 'C:\bin\args.exe'
arg[ 1 ] = '[{"txid":"eb63d5d53cd906b5cf75a014e1bcf1c0198ae58d378d45dbfa15045ac89a38ac","vout":0}]'
arg[ 2 ] = '{"1GMaxweLLbo8mdXvnnC19Wt2wigiYUKgEB":23.35}'

(without a doubt quote characters are a huge PITA with Windows console and batch file calls)

Also this is the source of the "args" program I am using:
Code:
#include <iostream>

using namespace std;

int main( int argc, char* argv[ ] )
{
   for( int i = 0; i < argc; i++ )
      cout << "arg[ " << i << " ] = '" << argv[ i ] << "'\n";
}

(I wrote this program due to many such issues I've encountered before)


That one worked, thank you!

Interested in OpenPay?
https://github.com/openpay
Donate to show your appreciation and support the effort!

1LMDCSAwjhT2Vp1sSf62dybEYW3MYpsoZj

Pyramining Links - Help OpenPay and get a 10% bonus on your funds.
http://pyramining.com/referral/zre9ysgqt
http://pyramining.com/referral/ans9km72g
http://pyramining.com/referral/f3k4xebzp
http://pyramining.com/referral/nc3ag2sdb
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1075


Ian Knowles - CIYAM Lead Developer


View Profile WWW
August 30, 2012, 05:14:50 PM
 #17

That one worked, thank you!

Most welcome - as stated quote stuff with Windows console/batch really sucks bad (that's why I wrote the utility to help me with such problems).

Smiley

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

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
shamoons
Full Member
***
Offline Offline

Activity: 165
Merit: 100



View Profile
July 25, 2013, 02:13:02 PM
 #18

mmm, no.

To be valid JSON, arg[1] must be:
Code:
[{"txid":"eb63d5d53cd906b5cf75a014e1bcf1c0198ae58d378d45dbfa15045ac89a38ac","vout":0}]

WTF is Windows doing with the arguments?

How are you deciding the txid?
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1075


Ian Knowles - CIYAM Lead Developer


View Profile WWW
July 25, 2013, 02:18:26 PM
Merited by ABCbits (2)
 #19

How are you deciding the txid?

The txid for each "input" comes from the UTXOs (i.e. "listunspent") and the txid of the final raw tx is returned to you by bitcoind when it is successfully sent.

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

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
alexrossi
Legendary
*
Offline Offline

Activity: 3724
Merit: 1739


Join the world-leading crypto sportsbook NOW!


View Profile
December 23, 2013, 08:11:56 PM
 #20

WTF is Windows doing with the arguments?

Okay - well to get my program to do that I changed the input to this:

Code:
C:\bin>args "[{\"txid\":\"eb63d5d53cd906b5cf75a014e1bcf1c0198ae58d378d45dbfa15045ac89a38ac\",\"vout\":0}]" "{\"1GMaxweLLbo8mdXvnnC19
Wt2wigiYUKgEB\":23.35}"
arg[ 0 ] = 'C:\bin\args.exe'
arg[ 1 ] = '[{"txid":"eb63d5d53cd906b5cf75a014e1bcf1c0198ae58d378d45dbfa15045ac89a38ac","vout":0}]'
arg[ 2 ] = '{"1GMaxweLLbo8mdXvnnC19Wt2wigiYUKgEB":23.35}'

(without a doubt quote characters are a huge PITA with Windows console and batch file calls)

Also this is the source of the "args" program I am using:
Code:
#include <iostream>

using namespace std;

int main( int argc, char* argv[ ] )
{
   for( int i = 0; i < argc; i++ )
      cout << "arg[ " << i << " ] = '" << argv[ i ] << "'\n";
}

(I wrote this program due to many such issues I've encountered before)


Worked also for me!!! many thanks  Smiley

  ▄▄███████▄███████▄▄▄
 █████████████
▀▀▀▀▀▀████▄▄
███████████████
       ▀▀███▄
███████████████
          ▀███
 █████████████
             ███
███████████▀▀               ███
███                         ███
███                         ███
 ███                       ███
  ███▄                   ▄███
   ▀███▄▄             ▄▄███▀
     ▀▀████▄▄▄▄▄▄▄▄▄████▀▀
         ▀▀▀███████▀▀▀
░░░████▄▄▄▄
░▄▄░
▄▄███████▄▀█████▄▄
██▄████▌▐█▌█████▄██
████▀▄▄▄▌███░▄▄▄▀████
██████▄▄▄█▄▄▄██████
█░███████░▐█▌░███████░█
▀▀██▀░██░▐█▌░██░▀██▀▀
▄▄▄░█▀░█░██░▐█▌░██░█░▀█░▄▄▄
██▀░░░░▀██░▐█▌░██▀░░░░▀██
▀██
█████▄███▀▀██▀▀███▄███████▀
▀███████████████████████▀
▀▀▀▀███████████▀▀▀▀
▄▄██████▄▄
▀█▀
█  █▀█▀
  ▄█  ██  █▄  ▄
█ ▄█ █▀█▄▄█▀█ █▄ █
▀▄█ █ ███▄▄▄▄███ █ █▄▀
▀▀ █    ▄▄▄▄    █ ▀▀
   ██████   █
█     ▀▀     █
▀▄▀▄▀▄▀▄▀▄▀▄
▄ ██████▀▀██████ ▄
▄████████ ██ ████████▄
▀▀███████▄▄███████▀▀
▀▀▀████████▀▀▀
█████████████LEADING CRYPTO SPORTSBOOK & CASINO█████████████
MULTI
CURRENCY
1500+
CASINO GAMES
CRYPTO EXCLUSIVE
CLUBHOUSE
FAST & SECURE
PAYMENTS
.
..PLAY NOW!..
Pages: [1] 2 »  All
  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!