Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/rawtransaction.cpp
Show First 20 Lines • Show All 1,115 Lines • ▼ Show 20 Lines | static UniValue signrawtransactionwithkey(const Config &config, | ||||
if (!DecodeHexTx(mtx, request.params[0].get_str())) { | if (!DecodeHexTx(mtx, request.params[0].get_str())) { | ||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); | throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); | ||||
} | } | ||||
CBasicKeyStore keystore; | CBasicKeyStore keystore; | ||||
const UniValue &keys = request.params[1].get_array(); | const UniValue &keys = request.params[1].get_array(); | ||||
for (size_t idx = 0; idx < keys.size(); ++idx) { | for (size_t idx = 0; idx < keys.size(); ++idx) { | ||||
UniValue k = keys[idx]; | UniValue k = keys[idx]; | ||||
CBitcoinSecret vchSecret; | CKey key = DecodeSecret(k.get_str()); | ||||
if (!vchSecret.SetString(k.get_str())) { | |||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | |||||
"Invalid private key"); | |||||
} | |||||
CKey key = vchSecret.GetKey(); | |||||
if (!key.IsValid()) { | if (!key.IsValid()) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
"Private key outside allowed range"); | "Invalid private key"); | ||||
} | } | ||||
keystore.AddKey(key); | keystore.AddKey(key); | ||||
} | } | ||||
return SignTransaction(mtx, request.params[2], &keystore, true, | return SignTransaction(mtx, request.params[2], &keystore, true, | ||||
request.params[3]); | request.params[3]); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 360 Lines • Show Last 20 Lines |