I am using bitcoind 0.8.5 with JSON to try and implement multisignature addresses locally on my server. But when I try and create one from my code, it keeps returning FALSE.

$create_multisig = $bitcoin->createmultisig (2, '[ "02e280809f7a7e0fabb7404d68ef89b66e9cf63ecfffd37ef2c78d06c51d2247f6", "02f22be70ae35432c82e7b05846eeab1fec5b09ebe523bb98d6d6bbf1ff29d96c3"]');


I have tried variations of the quotes, I tried putting the public keys into variables, etc.. Can somebody tell me what I am doing wrong here? It won't create the multisignature address.


$pubkey_str = "";

$pubkey_str .= "\"02e280809f7a7e0fabb7404d68ef89b66e9cf63ecfffd37ef2c78d06c51d2247f6\",";

$pubkey_str .= "\"02f22be70ae35432c82e7b05846eeab1fec5b09ebe523bb98d6d6bbf1ff29d96c3\",";

$pubkey_str = substr($pubkey_str, 0, (strlen($pubkey_str)-1));

$pubkey_input = "'[$pubkey_str]'";


$create_multisig = $bitcoin->addmultisigaddress (2, $pubkey_input);


And the resulting output

string(141) "'["02e280809f7a7e0fabb7404d68ef89b66e9cf63ecfffd37ef2c78d06c51d2247f6","02f22be70ae35432c82e7b05846eeab1fec5b09ebe523bb98d6d6bbf1ff29d96c3"]'"



I lost my guest session but I figured out the problem.

jsonRPCClient was not providing me any useful information as an output so serching Stack Exchange I was able to find somebody who changed the JSON library to output a useful error code.

    Add *'ignore_errors' => true* to the $opts array
    Change the error line that throws Request error to read throw new Exception('Request error: '.$response['error']['code'].' - '.$response['error']['message']);.

Then the output said that I was inputting a string and I should be inputting an array. So all I had to do, was put all the public keys into an array and plug it into the createmultisig function.

$pubkey_str = array();

$pubkey_str[] = "02e280809f7a7e0fabb7404d68ef89b66e9cf63ecfffd37ef2c78d06c51d2247f6";

$pubkey_str[] = "02f22be70ae35432c82e7b05846eeab1fec5b09ebe523bb98d6d6bbf1ff29d96c3";

$create_multisig = $bitcoin->createmultisig (2,$pubkey_str);

and this was the output

array(2) { ["address"]=> string(35) "2MtXTzX7pASPKr8VKmkyWKRNFt2o1oFxi9K" ["redeemScript"]=> string(142) "522102e280809f7a7e0fabb7404d68ef89b66e9cf63ecfffd37ef2c78d06c51d2247f62102f22be70ae35432c82e7b05846eeab1fec5b09ebe523bb98d6d6bbf1ff29d96c352ae"

Which is exactly what I expected. So maybe it was a stupid mistake on my behalf, but hopefully other people can benefit from it.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.