Bitcoin Forum
November 13, 2018, 07:27:27 PM *
News: Latest Bitcoin Core release: 0.17.0 [Torrent].
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: ”Argument list too long“ for decoderawtransaction  (Read 914 times)
mhps
Hero Member
*****
Offline Offline

Activity: 516
Merit: 500


View Profile
June 24, 2016, 05:47:55 AM
 #1

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?

BTC 1HxvAEC4nj37hyenz9DwsyrMMnkwzpbzno PPC PU6zS8RRBWP2UxhuRFengGsu8n4tEYB5xV XPM AJAgBpPjGQoL38mrtW91dVqhbMHqu25vfG
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1542137247
Hero Member
*
Offline Offline

Posts: 1542137247

View Profile Personal Message (Offline)

Ignore
1542137247
Reply with quote  #2

1542137247
Report to moderator
1542137247
Hero Member
*
Offline Offline

Posts: 1542137247

View Profile Personal Message (Offline)

Ignore
1542137247
Reply with quote  #2

1542137247
Report to moderator
1542137247
Hero Member
*
Offline Offline

Posts: 1542137247

View Profile Personal Message (Offline)

Ignore
1542137247
Reply with quote  #2

1542137247
Report to moderator
cr1776
Legendary
*
Offline Offline

Activity: 2058
Merit: 1011


View Profile
June 24, 2016, 11:54:02 AM
 #2

What does
getconf ARG_MAX

Show?


There may not be another solution except recompiling since I don't think xargs would help here.
mhps
Hero Member
*****
Offline Offline

Activity: 516
Merit: 500


View Profile
June 25, 2016, 04:05:16 AM
 #3

What does
getconf ARG_MAX

Show?
Quote

2097152

Quote
I don't think xargs would help here.

I tried. It didn't help.

BTC 1HxvAEC4nj37hyenz9DwsyrMMnkwzpbzno PPC PU6zS8RRBWP2UxhuRFengGsu8n4tEYB5xV XPM AJAgBpPjGQoL38mrtW91dVqhbMHqu25vfG
theymos
Administrator
Legendary
*
expert
Offline Offline

Activity: 3206
Merit: 3916


View Profile
June 25, 2016, 05:08:55 AM
Merited by TheArchaeologist (1)
 #4

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.

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
mhps
Hero Member
*****
Offline Offline

Activity: 516
Merit: 500


View Profile
June 28, 2016, 08:37:00 AM
 #5

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.

BTC 1HxvAEC4nj37hyenz9DwsyrMMnkwzpbzno PPC PU6zS8RRBWP2UxhuRFengGsu8n4tEYB5xV XPM AJAgBpPjGQoL38mrtW91dVqhbMHqu25vfG
hassan_pf
Newbie
*
Offline Offline

Activity: 1
Merit: 0


View Profile
August 19, 2018, 06:10:00 AM
 #6

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
gmaxwell
Moderator
Legendary
*
qt
Offline Offline

Activity: 2562
Merit: 1669



View Profile
August 19, 2018, 05:39:51 PM
 #7

bitcoin-cli has the -stdin argument for this reason. (both too long inputs and keeping passwords off command lines...)

Bitcoin will not be compromised
TheArchaeologist
Member
**
Offline Offline

Activity: 84
Merit: 73

Learn from the Past!


View Profile WWW
August 21, 2018, 08:13:11 AM
 #8

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.
TheArchaeologist
Member
**
Offline Offline

Activity: 84
Merit: 73

Learn from the Past!


View Profile WWW
August 21, 2018, 08:20:02 AM
 #9

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?
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!