Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: mhps on June 24, 2016, 05:47:55 AM



Title: ”Argument list too long“ for decoderawtransaction
Post by: mhps on June 24, 2016, 05:47:55 AM
hi,

I get an ”Argument list too long“ shell error when running

$BITCOIND decoderawtransaction $foo

where $foo is a raw tx that is 158kb long from getrawtransaction, on Ubuntu linux. How to get around it w/o recompiling the kernel?


Title: Re: ”Argument list too long“ for decoderawtransaction
Post by: cr1776 on June 24, 2016, 11:54:02 AM
What does
getconf ARG_MAX

Show?


There may not be another solution except recompiling since I don't think xargs would help here.


Title: Re: ”Argument list too long“ for decoderawtransaction
Post by: theymos on June 25, 2016, 05:08:55 AM
The bottom of help decoderawtransaction shows you how to execute the command using JSON-RPC via curl:

Code:
curl --user myusername --data-binary \
'{"jsonrpc": "1.0", "id":"curltest", "method": "decoderawtransaction", "params": ["hexstring"] }' -H 'content-type: text/plain;'\
 http://127.0.0.1:8332/

You can put the {"jsonrpc":... stuff into a file (omit the single quotes) named for example TEMPFILE and then change the command to:
Code:
curl --user myusername --data-binary @TEMPFILE -H 'content-type: text/plain;' http://127.0.0.1:8332/

This requires that you set an RPC user and password in your bitcoin.conf. Change "myusername" above to your actual RPC user.

Since the data is in a file and never passed through the shell, I think that this should work, though I haven't tested it.


Title: Re: ”Argument list too long“ for decoderawtransaction
Post by: mhps on June 28, 2016, 08:37:00 AM
I think that this should work, though I haven't tested it.

Thanks. It works!  I removed the -H part to get json format output, where the decoded raw tx is in the "result" field.
I also changed -data-binary to -data so that it doesn't matter if the hex tx has a \n in it.


Title: Re: ”Argument list too long“ for decoderawtransaction
Post by: hassan_pf on August 19, 2018, 06:10:00 AM
Can I add password in it , so that it don't prompt for password . i know its not safe , but i need to add password


Title: Re: ”Argument list too long“ for decoderawtransaction
Post by: gmaxwell on August 19, 2018, 05:39:51 PM
bitcoin-cli has the -stdin argument for this reason. (both too long inputs and keeping passwords off command lines...)


Title: Re: ”Argument list too long“ for decoderawtransaction
Post by: TheArchaeologist on August 21, 2018, 08:13:11 AM
Can I add password in it , so that it don't prompt for password . i know its not safe , but i need to add password

If you are asking to run rpc calls without supplying the needed rpc-user and password each time add them to your bitcoin.conf file:
Code:
rpcuser=hassan_pf
rpcpassword=nobodyknows
This is the preferred way since it won't show up in your bash history (opposed to using them as arguments when calling bitcoin-cli)

However if you are looking for a way to unlock your wallet so you can spent coins you should use the walletpassphrase argument. The insecure way of doing this is:
Code:
bitcoin-cli walletpassphrase <mysecretpassphrase> <unlock time in seconds>

So if you want to unlock your wallet with passphrase "secretenough" for 5 minutes you should do:
Code:
bitcoin-cli walletpassphrase secretenough 300

However this means your passphrase is also stored in your bash history, something you might not want. As gmaxwell was referring to you can use the -stdin argument if you don't want this to happen. The way this works is:

Code:
bitcoin-cli -stdin walletpassphrase
Once entered pass every argument you want to supply on a seperate line like this:
Code:
secretenough
300
 
Use CTRL-D after supplying all the arguments. This will unlock your wallet without the passphrase getting written to your bash history.


Title: Re: ”Argument list too long“ for decoderawtransaction
Post by: TheArchaeologist on August 21, 2018, 08:20:02 AM
hi,

I get an ”Argument list too long“ shell error when running

$BITCOIND decoderawtransaction $foo

where $foo is a raw tx that is 158kb long from getrawtransaction, on Ubuntu linux. How to get around it w/o recompiling the kernel?

So what happpens if you do:
Code:
$BITCOIND -stdin decoderawtransaction
$foo
And CTRL-D afterwards?