aboutsummaryrefslogtreecommitdiff
path: root/src/rpcwallet.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2013-12-13 16:21:38 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2013-12-13 16:34:57 +0100
commit723a03d2deb742e5462218ffdc96d3063dd979fd (patch)
tree222ca07371df465f35978fb06ec6e3e0c76ec4af /src/rpcwallet.cpp
parent452955f5be9dbd4397ca6425150923521cbee4ae (diff)
Move `createmultisig` from rpcwallet to rpcmisc
Enables it in --disable-wallet compiles.
Diffstat (limited to 'src/rpcwallet.cpp')
-rw-r--r--src/rpcwallet.cpp100
1 files changed, 2 insertions, 98 deletions
diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp
index a81c9bbc4c..eea75ce972 100644
--- a/src/rpcwallet.cpp
+++ b/src/rpcwallet.cpp
@@ -907,61 +907,8 @@ Value sendmany(const Array& params, bool fHelp)
return wtx.GetHash().GetHex();
}
-//
-// Used by addmultisigaddress / createmultisig:
-//
-static CScript _createmultisig(const Array& params)
-{
- int nRequired = params[0].get_int();
- const Array& keys = params[1].get_array();
-
- // Gather public keys
- if (nRequired < 1)
- throw runtime_error("a multisignature address must require at least one key to redeem");
- if ((int)keys.size() < nRequired)
- throw runtime_error(
- strprintf("not enough keys supplied "
- "(got %"PRIszu" keys, but need at least %d to redeem)", keys.size(), nRequired));
- std::vector<CPubKey> pubkeys;
- pubkeys.resize(keys.size());
- for (unsigned int i = 0; i < keys.size(); i++)
- {
- const std::string& ks = keys[i].get_str();
-
- // Case 1: Bitcoin address and we have full public key:
- CBitcoinAddress address(ks);
- if (pwalletMain && address.IsValid())
- {
- CKeyID keyID;
- if (!address.GetKeyID(keyID))
- throw runtime_error(
- strprintf("%s does not refer to a key",ks.c_str()));
- CPubKey vchPubKey;
- if (!pwalletMain->GetPubKey(keyID, vchPubKey))
- throw runtime_error(
- strprintf("no full public key for address %s",ks.c_str()));
- if (!vchPubKey.IsFullyValid())
- throw runtime_error(" Invalid public key: "+ks);
- pubkeys[i] = vchPubKey;
- }
-
- // Case 2: hex public key
- else if (IsHex(ks))
- {
- CPubKey vchPubKey(ParseHex(ks));
- if (!vchPubKey.IsFullyValid())
- throw runtime_error(" Invalid public key: "+ks);
- pubkeys[i] = vchPubKey;
- }
- else
- {
- throw runtime_error(" Invalid public key: "+ks);
- }
- }
- CScript result;
- result.SetMultisig(nRequired, pubkeys);
- return result;
-}
+// Defined in rpcmisc.cpp
+extern CScript _createmultisig(const Array& params);
Value addmultisigaddress(const Array& params, bool fHelp)
{
@@ -1006,49 +953,6 @@ Value addmultisigaddress(const Array& params, bool fHelp)
return CBitcoinAddress(innerID).ToString();
}
-Value createmultisig(const Array& params, bool fHelp)
-{
- if (fHelp || params.size() < 2 || params.size() > 2)
- {
- string msg = "createmultisig nrequired [\"key\",...]\n"
- "\nCreates a multi-signature address with n signature of m keys required.\n"
- "It returns a json object with the address and redeemScript.\n"
-
- "\nArguments:\n"
- "1. nrequired (numeric, required) The number of required signatures out of the n keys or addresses.\n"
- "2. \"keys\" (string, required) A json array of keys which are bitcoin addresses or hex-encoded public keys\n"
- " [\n"
- " \"key\" (string) bitcoin address or hex-encoded public key\n"
- " ,...\n"
- " ]\n"
-
- "\nResult:\n"
- "{\n"
- " \"address\":\"multisigaddress\", (string) The value of the new multisig address.\n"
- " \"redeemScript\":\"script\" (string) The string value of the hex-encoded redemption script.\n"
- "}\n"
-
- "\nExamples:\n"
- "\nCreate a multisig address from 2 addresses\n"
- + HelpExampleCli("createmultisig", "2 \"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") +
- "\nAs a json rpc call\n"
- + HelpExampleRpc("icreatemultisig", "2, \"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"")
- ;
- throw runtime_error(msg);
- }
-
- // Construct using pay-to-script-hash:
- CScript inner = _createmultisig(params);
- CScriptID innerID = inner.GetID();
- CBitcoinAddress address(innerID);
-
- Object result;
- result.push_back(Pair("address", address.ToString()));
- result.push_back(Pair("redeemScript", HexStr(inner.begin(), inner.end())));
-
- return result;
-}
-
struct tallyitem
{