Author

Topic: Proper API Parameter Formatting (Read 1440 times)

member
Activity: 95
Merit: 11
September 13, 2012, 12:01:46 PM
#9
at command line:

did senrawtransaction with existing tx and got error "already in block...."

sent my signed tx and got:

error: {"code":-22,"message":"TX rejected"}

so I guess something is wrong..... everything seems ok?

for reference here is the final signed tx which can be decoded using decoderawtransaction and everything looks ok?

Code:
0100000001f334b858fdee8ae33b6a56010b31aa4c192b5c6b01c4950421d70bbb0620c834010000008c4930460221009efd04aaf24cebbe2d063226955e44391cde6c45c40e51ec8288d0c36f7cbcfa022100daec10ba35b2bf86aff4eb0f6674747bc2da1f0e601f40e96897b6243b24700501410482fc9dccc054288979532fe8432a730c89ed0895be480e181292ffef27ea8c032bc9786baf46585def16ce336aa7cbe51367bd1d0964736935fffc28bf4650f8ffffffff02a0860100000000001976a9146deb5c5ff3eeda25ef41a190d029d7331df6faa788ace00f9700000000001976a91408510f40444f0210b4d2df6e650c3e7004a938df88ac00000000

Also decoding existing transaction and compare with my transaction at command line, seems ok.

using print_r however:

existing transaction has element [hex] at the beginning of the array, this is the hex of the signed transaction it appears, whereas my tx starts with [txid] (no this is just the [verbose=1] returns the object, with its own reference in the first array element).
member
Activity: 95
Merit: 11
September 13, 2012, 11:16:04 AM
#8
did send $origrawtx where outputs are from, no response from API, no error.

Should at least get an error no?
member
Activity: 95
Merit: 11
September 13, 2012, 11:11:11 AM
#7
After further testing:
my $signedHEX returns fine from decoderawtransaction

possible bug?

will try sending already confirmed transactions so see if I can at least get an error.

Any help appreciated.
member
Activity: 95
Merit: 11
September 12, 2012, 10:45:07 PM
#6
Thanks to for all the help, been fun learning the API

only 1 problem remains, I can't get sendrawtransaction to work.  I can get raw hex (as ouputed from signrawtransaction) as follows:
Code:
$bitcoin = "" //connect to server

$signedtx = $bitcoin->signrawtransaction($inputs,$outputs);
Outputs
Code:
Array
(
   [hex] => 0100..........
   [complete] => 1
)

After some trouble I even dump into non array...
Code:
$signedHEX = $signedtx['hex'];
however still no luck with:
Code:
$senttx = $bitcoin->sendrawtransaction($signedHEX);

var dumps show both the array and the var both string(518)

all my other code runs, just this one line...
legendary
Activity: 1072
Merit: 1181
September 11, 2012, 06:12:43 AM
#5
Yes, transaction inputs always spend one previous transaction output completely.

Change addresses is something that doesn't exist at the protocol level (arguably, even addresses don't). it's just an artefact of how wallets work.

If you use the raw transaction API, you can implement wallets that work any way you like - including ones that return change back to the original output address. In general, this is not a good idea in my opinion, as it decreases privacy (it makes it obvious which output is change and which is real payment) and encourages address reuse, but it may come in handy in certain situations.
member
Activity: 95
Merit: 11
September 11, 2012, 05:22:21 AM
#4
Thanks! am dl'ing now.

While I'm waiting (re dl'ing the blockchain, was having problems with dbase errors) I am wondering exactly how bitcoin transactions are formatted.

Does the entire output of a transaction have to be spent when using it as an input for a new transaction? If so can the address of that original output be an output on the subsequent transaction ie. returning the change to the original address?

Working with offline wallet concept so will be generating and signing raw transactions through the API.
member
Activity: 95
Merit: 11
September 11, 2012, 01:54:53 AM
#2
Yeah so clearly obviously I need version 7..... bitcoin.org is 6.3 so i guess its compiling time??
member
Activity: 95
Merit: 11
September 11, 2012, 01:42:38 AM
#1
Working on a little PHP project I got going here. As a hobbyist I'm not a pro by any means, and I was unable to find specific information on this.

Starting with the example code from the Wiki:
Code:
$bitcoin = new jsonRPCClient('http://user:[email protected]:8332/');
 
  print_r($bitcoin->getinfo()); echo "\n";

Obviously works as does, for example:

Code:
print_r($bitcoin->getaddressesbyaccount('user')); echo "\n";

However this doesnt work?:
Code:
print_r($bitcoin->getrawmempool()); echo "\n";

JSON is new for me so is it something about the formatting of the parameters being passed to the API?
But getrawmempool needs no other paramaters just as getinfo doesn't... or does it? Maybe its my client?

Also other API calls seem to be hit and miss, so clearly I'm missing something important and probably obvious... would love a little help Smiley

Client Info:
Code:
Array
(
    [version] => 60300
    [protocolversion] => 60001
    [walletversion] => 10500
    [balance] => 2.6432
    [blocks] => 198267
    [connections] => 8
    [proxy] =>
    [difficulty] => 2694047.952955
    [testnet] =>
    [keypoololdest] => 1312129826
    [keypoolsize] => 101
    [paytxfee] => 0
    [errors] =>
)
Jump to: