2

The signrawtransaction rpc method calls for the following use:

signrawtransaction "hexstring" ( [{"txid":"id","vout":n,"scriptPubKey":"hex","redeemScript":"hex"},...] ["privatekey1",...] sighashtype )

Why is scriptPubKey included in here? It seems from the code that it just looks it up anyway and compared to the value given:

if (coins.IsAvailable(nOut) && coins.vout[nOut].scriptPubKey != scriptPubKey) {
    string err("Previous output scriptPubKey mismatch:\n");
    err = err + coins.vout[nOut].scriptPubKey.ToString() + "\nvs:\n"+
    scriptPubKey.ToString();
    throw JSONRPCError(RPC_DESERIALIZATION_ERROR, err);
}

My best guesses:

  • Maybe there are some cases where it won't be able to look up the scriptPubKey?
  • Maybe so this will work offline?
  • Maybe it's not actually needed, but kept for backwards compatibility?
2

Ahh, just found the answer. Should have read the help all the way through. It says:

The second optional argument (may be null) is an array of previous transaction outputs that this transaction depends on but may not yet be in the block chain.

So, it's there so that the method can be used even if the transaction it depends on doesn't exist yet. If it does exist, however, the client is smart and does extra error checking to make sure that you don't mess up.

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.