Browse Source

Signrawtransaction shouldn't require redeemScript for non-p2sh txins.

The redeemScript functionality broke plain offline signing, this
change makes it only look for that parameter when signing a p2sh
input.
miguelfreitas
Gregory Maxwell 12 years ago
parent
commit
21c6d3aead
  1. 8
      src/rpcrawtransaction.cpp

8
src/rpcrawtransaction.cpp

@ -421,7 +421,7 @@ Value signrawtransaction(const Array& params, bool fHelp)
Object prevOut = p.get_obj(); Object prevOut = p.get_obj();
RPCTypeCheck(prevOut, map_list_of("txid", str_type)("vout", int_type)("scriptPubKey", str_type)("redeemScript",str_type)); RPCTypeCheck(prevOut, map_list_of("txid", str_type)("vout", int_type)("scriptPubKey", str_type));
uint256 txid = ParseHashO(prevOut, "txid"); uint256 txid = ParseHashO(prevOut, "txid");
@ -450,8 +450,11 @@ Value signrawtransaction(const Array& params, bool fHelp)
// if redeemScript given and not using the local wallet (private keys // if redeemScript given and not using the local wallet (private keys
// given), add redeemScript to the tempKeystore so it can be signed: // given), add redeemScript to the tempKeystore so it can be signed:
if (fGivenKeys && scriptPubKey.IsPayToScriptHash())
{
RPCTypeCheck(prevOut, map_list_of("txid", str_type)("vout", int_type)("scriptPubKey", str_type)("redeemScript",str_type));
Value v = find_value(prevOut, "redeemScript"); Value v = find_value(prevOut, "redeemScript");
if (fGivenKeys && scriptPubKey.IsPayToScriptHash() && !(v == Value::null)) if (!(v == Value::null))
{ {
vector<unsigned char> rsData(ParseHexV(v, "redeemScript")); vector<unsigned char> rsData(ParseHexV(v, "redeemScript"));
CScript redeemScript(rsData.begin(), rsData.end()); CScript redeemScript(rsData.begin(), rsData.end());
@ -459,6 +462,7 @@ Value signrawtransaction(const Array& params, bool fHelp)
} }
} }
} }
}
const CKeyStore& keystore = (fGivenKeys ? tempKeystore : *pwalletMain); const CKeyStore& keystore = (fGivenKeys ? tempKeystore : *pwalletMain);

Loading…
Cancel
Save