Pages:
Author

Topic: Raw Transactions API... Am I using it correctly? (Read 4891 times)

newbie
Activity: 1
Merit: 1
I'm a DOS person, I had a lot of faffing about but this worked for me...

bitcoin-cli -regtest createrawtransaction [{\"txid\":\"c6343009c5d73572f750359480ae95170a00cfb41063f8cd70e1c14d06e8776c\",\"vout\":0}] {\"myf8U7KUzidun3WzjK2WM4nYVyE1ZkpSGH\":49.9999}

I removed single quotes around each object, and double quotes within the object had to be escaped.  Hope this helps anyone else getting JSON Parse errors on the Windows DOS command line version.  The actual ids and addresses are my own, natch, yours will differ, but the formatting should work.
legendary
Activity: 3766
Merit: 1742
Join the world-leading crypto sportsbook NOW!
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

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
legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
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.
full member
Activity: 165
Merit: 100
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?
legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
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
full member
Activity: 154
Merit: 102
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

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!
legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
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

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)
full member
Activity: 154
Merit: 102
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}]
legendary
Activity: 1652
Merit: 2301
Chief Scientist
mmm, no.

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

WTF is Windows doing with the arguments?
legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
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.
legendary
Activity: 1652
Merit: 2301
Chief Scientist
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}
staff
Activity: 4284
Merit: 8808
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.
full member
Activity: 154
Merit: 102
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
hero member
Activity: 772
Merit: 500
If you are using Windows replace the '-char with \".

Dia
legendary
Activity: 3920
Merit: 2349
Eadem mutata resurgo
Tagged.
staff
Activity: 4284
Merit: 8808
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)
full member
Activity: 154
Merit: 102
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.
full member
Activity: 154
Merit: 102
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.
staff
Activity: 4284
Merit: 8808
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.
legendary
Activity: 1652
Merit: 2301
Chief Scientist
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.
Pages:
Jump to: