You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

disablewallet.py 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env python3
  2. # Copyright (c) 2015-2016 The Bitcoin Core developers
  3. # Distributed under the MIT software license, see the accompanying
  4. # file COPYING or http://www.opensource.org/licenses/mit-license.php.
  5. """Test a node with the -disablewallet option.
  6. - Test that validateaddress RPC works when running with -disablewallet
  7. - Test that it is not possible to mine to an invalid address.
  8. """
  9. from test_framework.test_framework import BitcoinTestFramework
  10. from test_framework.util import *
  11. class DisableWalletTest (BitcoinTestFramework):
  12. def __init__(self):
  13. super().__init__()
  14. self.setup_clean_chain = True
  15. self.num_nodes = 1
  16. def setup_network(self, split=False):
  17. self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, [['-disablewallet']])
  18. self.is_network_split = False
  19. self.sync_all()
  20. def run_test (self):
  21. x = self.nodes[0].validateaddress('3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy')
  22. assert(x['isvalid'] == False)
  23. x = self.nodes[0].validateaddress('mneYUmWYsuk7kySiURxCi3AGxrAqZxLgPZ')
  24. assert(x['isvalid'] == True)
  25. # Checking mining to an address without a wallet. Generating to a valid address should succeed
  26. # but generating to an invalid address will fail.
  27. self.nodes[0].generatetoaddress(1, 'mneYUmWYsuk7kySiURxCi3AGxrAqZxLgPZ')
  28. assert_raises_jsonrpc(-5, "Invalid address", self.nodes[0].generatetoaddress, 1, '3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy')
  29. if __name__ == '__main__':
  30. DisableWalletTest ().main ()