aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2019-01-25 14:38:34 -0500
committerAndrew Chow <achow101-github@achow101.com>2019-01-31 14:29:28 -0500
commite6c58d3b014ab8ef5cca4be68764af4b79685fcb (patch)
tree9039a4523e7f7f6035271a849c0385e2e3c18dfe /test
parentb5c5021b644731d14a6ef04961320a99466f035a (diff)
Do not import private keys to wallets with private keys disabled
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/wallet_disableprivatekeys.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/functional/wallet_disableprivatekeys.py b/test/functional/wallet_disableprivatekeys.py
index 34ff525255..e55bb82e76 100755
--- a/test/functional/wallet_disableprivatekeys.py
+++ b/test/functional/wallet_disableprivatekeys.py
@@ -7,6 +7,7 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
+ assert_equal,
assert_raises_rpc_error,
)
@@ -31,5 +32,15 @@ class DisablePrivateKeysTest(BitcoinTestFramework):
assert_raises_rpc_error(-4,"Error: Private keys are disabled for this wallet", w1.getrawchangeaddress)
w1.importpubkey(w2.getaddressinfo(w2.getnewaddress())['pubkey'])
+ self.log.info('Test that private keys cannot be imported')
+ addr = w2.getnewaddress('', 'legacy')
+ privkey = w2.dumpprivkey(addr)
+ assert_raises_rpc_error(-4, 'Cannot import private keys to a wallet with private keys disabled', w1.importprivkey, privkey)
+ result = w1.importmulti([{'scriptPubKey': {'address': addr}, 'timestamp': 'now', 'keys': [privkey]}])
+ assert(not result[0]['success'])
+ assert('warning' not in result[0])
+ assert_equal(result[0]['error']['code'], -4)
+ assert_equal(result[0]['error']['message'], 'Cannot import private keys to a wallet with private keys disabled')
+
if __name__ == '__main__':
DisablePrivateKeysTest().main()