aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2018-12-19 16:30:49 -0500
committerAndrew Chow <achow101-github@achow101.com>2019-05-13 22:49:34 -0400
commit662d1171d9e29964b039ba4c5bc8a2304426c003 (patch)
treef50d9a669fc5c0d492a94de74c647f892c35580e /test
parent667a8617418d837092de5b37568d60b372519462 (diff)
downloadbitcoin-662d1171d9e29964b039ba4c5bc8a2304426c003.tar.xz
Add option to create an encrypted wallet
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/wallet_createwallet.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/functional/wallet_createwallet.py b/test/functional/wallet_createwallet.py
index 8ec4b98b6e..fc7969ad19 100755
--- a/test/functional/wallet_createwallet.py
+++ b/test/functional/wallet_createwallet.py
@@ -96,5 +96,28 @@ class CreateWalletTest(BitcoinTestFramework):
assert_raises_rpc_error(-4, "Error: This wallet has no available keys", w5.getnewaddress)
assert_raises_rpc_error(-4, "Error: This wallet has no available keys", w5.getrawchangeaddress)
+ self.log.info('New blank and encrypted wallets can be created')
+ self.nodes[0].createwallet(wallet_name='wblank', disable_private_keys=False, blank=True, passphrase='thisisapassphrase')
+ wblank = node.get_wallet_rpc('wblank')
+ assert_raises_rpc_error(-13, "Error: Please enter the wallet passphrase with walletpassphrase first.", wblank.signmessage, "needanargument", "test")
+ wblank.walletpassphrase('thisisapassphrase', 10)
+ assert_raises_rpc_error(-4, "Error: This wallet has no available keys", wblank.getnewaddress)
+ assert_raises_rpc_error(-4, "Error: This wallet has no available keys", wblank.getrawchangeaddress)
+
+ self.log.info('Test creating a new encrypted wallet.')
+ # Born encrypted wallet is created (has keys)
+ self.nodes[0].createwallet(wallet_name='w6', disable_private_keys=False, blank=False, passphrase='thisisapassphrase')
+ w6 = node.get_wallet_rpc('w6')
+ assert_raises_rpc_error(-13, "Error: Please enter the wallet passphrase with walletpassphrase first.", w6.signmessage, "needanargument", "test")
+ w6.walletpassphrase('thisisapassphrase', 10)
+ w6.signmessage(w6.getnewaddress('', 'legacy'), "test")
+ w6.keypoolrefill(1)
+ # There should only be 1 key
+ walletinfo = w6.getwalletinfo()
+ assert_equal(walletinfo['keypoolsize'], 1)
+ assert_equal(walletinfo['keypoolsize_hd_internal'], 1)
+ # Empty passphrase, error
+ assert_raises_rpc_error(-16, 'Cannot encrypt a wallet with a blank password', self.nodes[0].createwallet, 'w7', False, False, '')
+
if __name__ == '__main__':
CreateWalletTest().main()