isis (OP)
|
|
August 29, 2012, 08:50:21 PM |
|
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. 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. 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!
|
|
|
|
Gavin Andresen
Legendary
Offline
Activity: 1652
Merit: 2301
Chief Scientist
|
|
August 29, 2012, 08:53:50 PM |
|
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: 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
Offline
Activity: 4284
Merit: 8808
|
|
August 29, 2012, 09:28:35 PM |
|
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)
|
|
August 30, 2012, 03:27:49 AM |
|
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.
|
|
|
|
isis (OP)
|
|
August 30, 2012, 03:44:52 AM |
|
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.
|
|
|
|
gmaxwell
Moderator
Legendary
Offline
Activity: 4284
Merit: 8808
|
|
August 30, 2012, 03:58:23 AM |
|
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: $ ./bitcoind createrawtransaction '[{"txid":"eb63d5d53cd906b5cf75a014e1bcf1c0198ae58d378d45dbfa15045ac89a38ac","vout":0}]' '{"1GMaxweLLbo8mdXvnnC19Wt2wigiYUKgEB":23.35}' 0100000001ac389ac85a0415fadb458d378de58a19c0f1bce114a075cfb506d93cd5d563eb0000000000ffffffff01c0452d8b000000001976a914a86e8ee2a05a44613904e18132e49b2448adc4e688ac00000000
Feel free to sign and submit if you have any doubt. (though I don't seem to have that input in my mempool or blockchain)
|
|
|
|
marcus_of_augustus
Legendary
Offline
Activity: 3920
Merit: 2349
Eadem mutata resurgo
|
|
August 30, 2012, 04:43:22 AM |
|
Tagged.
|
|
|
|
Diapolo
|
|
August 30, 2012, 05:01:31 AM |
|
If you are using Windows replace the '-char with \".
Dia
|
|
|
|
isis (OP)
|
|
August 30, 2012, 01:41:55 PM |
|
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: $ ./bitcoind createrawtransaction '[{"txid":"eb63d5d53cd906b5cf75a014e1bcf1c0198ae58d378d45dbfa15045ac89a38ac","vout":0}]' '{"1GMaxweLLbo8mdXvnnC19Wt2wigiYUKgEB":23.35}' 0100000001ac389ac85a0415fadb458d378de58a19c0f1bce114a075cfb506d93cd5d563eb0000000000ffffffff01c0452d8b000000001976a914a86e8ee2a05a44613904e18132e49b2448adc4e688ac00000000
Feel free to sign and submit if you have any doubt. (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
|
|
|
|
gmaxwell
Moderator
Legendary
Offline
Activity: 4284
Merit: 8808
|
|
August 30, 2012, 02:53:28 PM |
|
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
Offline
Activity: 1652
Merit: 2301
Chief Scientist
|
|
August 30, 2012, 04:02:58 PM |
|
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? 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
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
|
|
August 30, 2012, 04:10:40 PM |
|
So maybe this?
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.
|
|
|
|
Gavin Andresen
Legendary
Offline
Activity: 1652
Merit: 2301
Chief Scientist
|
|
August 30, 2012, 04:12:48 PM |
|
mmm, no. To be valid JSON, arg[1] must be: [{"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)
|
|
August 30, 2012, 04:13:10 PM |
|
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? 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 bitcoind.exe createrawtransaction [{^"txid^":^"eb63d5d53cd906b5cf75a014e1bcf1c0198ae58d378d45dbfa15045ac89a38ac^",^"vout^":0}]{^"1GMaxweLLbo8mdXvnnC19Wt2wigiYUKgEB^":23.35}
Produces the same... error: Error parsing JSON:[{txid:eb63d5d53cd906b5cf75a014e1bcf1c0198ae58d378d45d bfa15045ac89a38ac,vout:0}]
|
|
|
|
CIYAM
Legendary
Offline
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
|
|
August 30, 2012, 04:17:31 PM |
|
WTF is Windows doing with the arguments?
Okay - well to get my program to do that I changed the input to this: 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: #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)
|
|
|
|
isis (OP)
|
|
August 30, 2012, 04:38:21 PM |
|
WTF is Windows doing with the arguments?
Okay - well to get my program to do that I changed the input to this: 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: #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!
|
|
|
|
CIYAM
Legendary
Offline
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
|
|
August 30, 2012, 05:14:50 PM |
|
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).
|
|
|
|
shamoons
|
|
July 25, 2013, 02:13:02 PM |
|
mmm, no. To be valid JSON, arg[1] must be: [{"txid":"eb63d5d53cd906b5cf75a014e1bcf1c0198ae58d378d45dbfa15045ac89a38ac","vout":0}]
WTF is Windows doing with the arguments? How are you deciding the txid?
|
|
|
|
CIYAM
Legendary
Offline
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
|
|
July 25, 2013, 02:18:26 PM |
|
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.
|
|
|
|
alexrossi
Legendary
Offline
Activity: 3892
Merit: 1748
Join the world-leading crypto sportsbook NOW!
|
|
December 23, 2013, 08:11:56 PM |
|
WTF is Windows doing with the arguments?
Okay - well to get my program to do that I changed the input to this: 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: #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
|
|
|
|
|