Skip to content

Commit

Permalink
Merge bitcoin#14310: [wallet] Ensure wallet is unlocked before signing
Browse files Browse the repository at this point in the history
20442f6 [wallet] remove redundand restart node (gustavonalle)
db15805 [wallet] Ensure wallet is unlocked before signing (gustavonalle)

Pull request description:

  Fixes bitcoin#14082

Tree-SHA512: 200620a2ced934f958933aba34541565a992e5033cf04c4e2be48b99e7708973c85f8274968962cec943f0c1d76fb2faa5e056469bbf59ce7f768614572322f9
  • Loading branch information
MarcoFalke committed Sep 26, 2018
2 parents cc7258b + 20442f6 commit d799efe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3109,6 +3109,8 @@ UniValue signrawtransactionwithwallet(const JSONRPCRequest& request)

// Sign the transaction
LOCK2(cs_main, pwallet->cs_wallet);
EnsureWalletIsUnlocked(pwallet);

return SignTransaction(mtx, request.params[1], pwallet, false, request.params[2]);
}

Expand Down
9 changes: 9 additions & 0 deletions test/functional/rpc_signrawtransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ def successful_signing_test(self):
# 2) No script verification error occurred
assert 'errors' not in rawTxSigned

def test_with_lock_outputs(self):
"""Test correct error reporting when trying to sign a locked output"""
self.nodes[0].encryptwallet("password")

rawTx = '020000000156b958f78e3f24e0b2f4e4db1255426b0902027cb37e3ddadb52e37c3557dddb0000000000ffffffff01c0a6b929010000001600149a2ee8c77140a053f36018ac8124a6ececc1668a00000000'

assert_raises_rpc_error(-13, "Please enter the wallet passphrase with walletpassphrase first", self.nodes[0].signrawtransactionwithwallet, rawTx)

def script_verification_error_test(self):
"""Create and sign a raw transaction with valid (vin 0), invalid (vin 1) and one missing (vin 2) input script.
Expand Down Expand Up @@ -138,6 +146,7 @@ def script_verification_error_test(self):
def run_test(self):
self.successful_signing_test()
self.script_verification_error_test()
self.test_with_lock_outputs()


if __name__ == '__main__':
Expand Down

0 comments on commit d799efe

Please sign in to comment.