Bitcoin Forum
June 16, 2024, 08:56:36 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: createrawtransaction using curl - is it possible?  (Read 1115 times)
ethought (OP)
Legendary
*
Offline Offline

Activity: 1316
Merit: 1000



View Profile
October 29, 2014, 06:05:52 PM
 #1

Have been trying to write a dust cleaner for altcoins in perl.

After constant 500 server errors using the perl module JSON::RPC::Client I have been trying to use curl directly to see what format the request needs to be in.

However I cannot get createrawtransaction to work with curl either.

I have tried just about every different formatting combination I can think of, for example:

curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "createrawtransaction", "params": [ "[{\"vout\":1,\"txid\":\"0bfa637d84586fc0acee31409fed3f771c78458bad195eb6f2d16ff5d4eaef07\"},{\"vout\":0,"txid":\"0ec54adfbd8d83f10c5ffb9429431129cf0f6f9ffb096f3c255458032ece5280\"}]","{\"DGV3v6MWakbBzmir9gDNnaU8yV7KGPUTi4\":0.19}" ] }' -H 'content-type: text/plain;' http://user:pass@127.0.0.1:6666/

Other calls (using perl or curl) do not result in errors for example listtransactions, getinfo, validateaddress etc.

I have read quite a few posts on stackexchange and bitcoinexchange asking if this can be done... There are no answers.

So can it be done? If so, where am I going wrong?

dserrano5
Legendary
*
Offline Offline

Activity: 1974
Merit: 1029



View Profile
October 29, 2014, 07:53:42 PM
 #2

After constant 500 server errors using the perl module JSON::RPC::Client I have been trying to use curl directly to see what format the request needs to be in.

However I cannot get createrawtransaction to work with curl either.

I perform a createrawtransaction with J::R::C here. Maybe by comparing the code you'll be able to figure out what you're doing wrong.
shorena
Copper Member
Legendary
*
Offline Offline

Activity: 1498
Merit: 1520


No I dont escrow anymore.


View Profile WWW
October 29, 2014, 08:06:27 PM
 #3

I dont know anything about curl but your rawtx is broken...

Code:
createrawtransaction
"[
{\"vout\":1,\"txid\":\"0bfa637d84586fc0acee31409fed3f771c78458bad195eb6f2d16ff5d4eaef07\"},
{\"vout\":0,"txid":\"0ec54adfbd8d83f10c5ffb9429431129cf0f6f9ffb096f3c255458032ece5280\"}
]",
"{\"DGV3v6MWakbBzmir9gDNnaU8yV7KGPUTi4\":0.19}"

results in
Code:
Error: Error parsing JSON:[
{"vout":1,"txid":"0bfa637d84586fc0acee31409fed3f771c78458bad195eb6f2d16ff5d4eaef07"},
{"vout":0,txid:"0ec54adfbd8d83f10c5ffb9429431129cf0f6f9ffb096f3c255458032ece5280"}
],

while
Code:
createrawtransaction
"[
{\"txid\":\"0bfa637d84586fc0acee31409fed3f771c78458bad195eb6f2d16ff5d4eaef07\",\"vout\":1},
{\"txid\":\"0ec54adfbd8d83f10c5ffb9429431129cf0f6f9ffb096f3c255458032ece5280\",\"vout\":0}
]"
"{\"DGV3v6MWakbBzmir9gDNnaU8yV7KGPUTi4\":0.19}"

results in

Code:

21:05:31
Invalid Bitcoin address: DGV3v6MWakbBzmir9gDNnaU8yV7KGPUTi4 (code -5)

which is to be expected since I though this was about bitcoin -_-

Hope it helps anyway.

Im not really here, its just your imagination.
ethought (OP)
Legendary
*
Offline Offline

Activity: 1316
Merit: 1000



View Profile
October 30, 2014, 05:08:16 PM
 #4

I perform a createrawtransaction with J::R::C here. Maybe by comparing the code you'll be able to figure out what you're doing wrong.

Thank you very much!! I got it working thanks to your example.

One thing that took me a while to figure out even after using your example was not to use dump() to check the input. I knew dump() can change JSON encoded strings. However it seems dumping the $ins and $outs prior to passing to $rpc->createrawtransaction([$ins, $outs]); changes them somehow also. I removed all dump() instances and it worked!!

Pages: [1]
  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!