@@ -907,61 +907,8 @@ Value sendmany(const Array& params, bool fHelp)
907
907
return wtx.GetHash ().GetHex ();
908
908
}
909
909
910
- //
911
- // Used by addmultisigaddress / createmultisig:
912
- //
913
- static CScript _createmultisig (const Array& params)
914
- {
915
- int nRequired = params[0 ].get_int ();
916
- const Array& keys = params[1 ].get_array ();
917
-
918
- // Gather public keys
919
- if (nRequired < 1 )
920
- throw runtime_error (" a multisignature address must require at least one key to redeem" );
921
- if ((int )keys.size () < nRequired)
922
- throw runtime_error (
923
- strprintf (" not enough keys supplied "
924
- " (got %" PRIszu" keys, but need at least %d to redeem)" , keys.size (), nRequired));
925
- std::vector<CPubKey> pubkeys;
926
- pubkeys.resize (keys.size ());
927
- for (unsigned int i = 0 ; i < keys.size (); i++)
928
- {
929
- const std::string& ks = keys[i].get_str ();
930
-
931
- // Case 1: Bitcoin address and we have full public key:
932
- CBitcoinAddress address (ks);
933
- if (pwalletMain && address.IsValid ())
934
- {
935
- CKeyID keyID;
936
- if (!address.GetKeyID (keyID))
937
- throw runtime_error (
938
- strprintf (" %s does not refer to a key" ,ks.c_str ()));
939
- CPubKey vchPubKey;
940
- if (!pwalletMain->GetPubKey (keyID, vchPubKey))
941
- throw runtime_error (
942
- strprintf (" no full public key for address %s" ,ks.c_str ()));
943
- if (!vchPubKey.IsFullyValid ())
944
- throw runtime_error (" Invalid public key: " +ks);
945
- pubkeys[i] = vchPubKey;
946
- }
947
-
948
- // Case 2: hex public key
949
- else if (IsHex (ks))
950
- {
951
- CPubKey vchPubKey (ParseHex (ks));
952
- if (!vchPubKey.IsFullyValid ())
953
- throw runtime_error (" Invalid public key: " +ks);
954
- pubkeys[i] = vchPubKey;
955
- }
956
- else
957
- {
958
- throw runtime_error (" Invalid public key: " +ks);
959
- }
960
- }
961
- CScript result;
962
- result.SetMultisig (nRequired, pubkeys);
963
- return result;
964
- }
910
+ // Defined in rpcmisc.cpp
911
+ extern CScript _createmultisig (const Array& params);
965
912
966
913
Value addmultisigaddress (const Array& params, bool fHelp )
967
914
{
@@ -1006,49 +953,6 @@ Value addmultisigaddress(const Array& params, bool fHelp)
1006
953
return CBitcoinAddress (innerID).ToString ();
1007
954
}
1008
955
1009
- Value createmultisig (const Array& params, bool fHelp )
1010
- {
1011
- if (fHelp || params.size () < 2 || params.size () > 2 )
1012
- {
1013
- string msg = " createmultisig nrequired [\" key\" ,...]\n "
1014
- " \n Creates a multi-signature address with n signature of m keys required.\n "
1015
- " It returns a json object with the address and redeemScript.\n "
1016
-
1017
- " \n Arguments:\n "
1018
- " 1. nrequired (numeric, required) The number of required signatures out of the n keys or addresses.\n "
1019
- " 2. \" keys\" (string, required) A json array of keys which are bitcoin addresses or hex-encoded public keys\n "
1020
- " [\n "
1021
- " \" key\" (string) bitcoin address or hex-encoded public key\n "
1022
- " ,...\n "
1023
- " ]\n "
1024
-
1025
- " \n Result:\n "
1026
- " {\n "
1027
- " \" address\" :\" multisigaddress\" , (string) The value of the new multisig address.\n "
1028
- " \" redeemScript\" :\" script\" (string) The string value of the hex-encoded redemption script.\n "
1029
- " }\n "
1030
-
1031
- " \n Examples:\n "
1032
- " \n Create a multisig address from 2 addresses\n "
1033
- + HelpExampleCli (" createmultisig" , " 2 \" [\\\" 16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\" ,\\\" 171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\" ]\" " ) +
1034
- " \n As a json rpc call\n "
1035
- + HelpExampleRpc (" icreatemultisig" , " 2, \" [\\\" 16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\" ,\\\" 171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\" ]\" " )
1036
- ;
1037
- throw runtime_error (msg);
1038
- }
1039
-
1040
- // Construct using pay-to-script-hash:
1041
- CScript inner = _createmultisig (params);
1042
- CScriptID innerID = inner.GetID ();
1043
- CBitcoinAddress address (innerID);
1044
-
1045
- Object result;
1046
- result.push_back (Pair (" address" , address.ToString ()));
1047
- result.push_back (Pair (" redeemScript" , HexStr (inner.begin (), inner.end ())));
1048
-
1049
- return result;
1050
- }
1051
-
1052
956
1053
957
struct tallyitem
1054
958
{
0 commit comments