Skip to content

Commit

Permalink
Merge ElementsProject#607: Fix default permitsigdata value not workin…
Browse files Browse the repository at this point in the history
…g on converttopsbt command

794c305 Test that default `permitsigdata` is false (Steven Roose)
c8525c9 Fix bug in converttopsbt (Steven Roose)

Pull request description:

  We're not really supporting PSBT for Elements yet. The `rpc_psbt.py` integration test is disabled because of this; that's also why we didn't catch this. It's fixed upstream.

  I added an extra test to catch the error, but it's not actually executed.

  @instagibbs, up to you to decide if it's worth having this patched right now. I cherry-picked that fix commit literally from the catchup PR I'm working on, so if we don't patch it here, it will get patched while catching up.

Tree-SHA512: 2ee9ed733659c028f349b75aba19b80cef13894eacb0d85d0ab4377ee9e07b4aa90888edb402a5c31784f5d0848a0f22a445736995d9a6fca0bbeccf15f75dcb
  • Loading branch information
instagibbs committed May 14, 2019
2 parents fa8765c + 794c305 commit 879b64b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/rpc/rawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1765,13 +1765,13 @@ UniValue converttopsbt(const JSONRPCRequest& request)

// Remove all scriptSigs and scriptWitnesses from inputs
for (CTxIn& input : tx.vin) {
if ((!input.scriptSig.empty()) && (request.params[1].isNull() || (!request.params[1].isNull() && request.params[1].get_bool()))) {
if (!input.scriptSig.empty() && !permitsigdata) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Inputs must not have scriptSigs");
}
input.scriptSig.clear();
}
for (CTxInWitness& witness: tx.witness.vtxinwit) {
if ((!witness.scriptWitness.IsNull()) && (request.params[1].isNull() || (!request.params[1].isNull() && request.params[1].get_bool()))) {
if (!witness.scriptWitness.IsNull() && !permitsigdata) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Inputs must not have scriptWitnesses");
}
}
Expand Down
1 change: 1 addition & 0 deletions test/functional/rpc_psbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def run_test(self):

# Make sure that a psbt with signatures cannot be converted
signedtx = self.nodes[0].signrawtransactionwithwallet(rawtx['hex'])
assert_raises_rpc_error(-22, "Inputs must not have scriptWitnesses", self.nodes[0].converttopsbt, signedtx['hex'], False)
assert_raises_rpc_error(-22, "Inputs must not have scriptWitnesses", self.nodes[0].converttopsbt, signedtx['hex'])

# Explicitly allow converting non-empty txs
Expand Down

0 comments on commit 879b64b

Please sign in to comment.