@ -15,6 +15,10 @@ from test_framework.util import (
)
)
from test_framework . wallet_util import bytes_to_wif , generate_wif_key
from test_framework . wallet_util import bytes_to_wif , generate_wif_key
EMPTY_PASSPHRASE_MSG = " Empty string given as passphrase, wallet will not be encrypted. "
LEGACY_WALLET_MSG = " Wallet created successfully. The legacy wallet type is being deprecated and support for creating and opening legacy wallets will be removed in the future. "
class CreateWalletTest ( BitcoinTestFramework ) :
class CreateWalletTest ( BitcoinTestFramework ) :
def add_options ( self , parser ) :
def add_options ( self , parser ) :
self . add_wallet_options ( parser )
self . add_wallet_options ( parser )
@ -159,7 +163,9 @@ class CreateWalletTest(BitcoinTestFramework):
assert_equal ( walletinfo [ ' keypoolsize_hd_internal ' ] , keys )
assert_equal ( walletinfo [ ' keypoolsize_hd_internal ' ] , keys )
# Allow empty passphrase, but there should be a warning
# Allow empty passphrase, but there should be a warning
resp = self . nodes [ 0 ] . createwallet ( wallet_name = ' w7 ' , disable_private_keys = False , blank = False , passphrase = ' ' )
resp = self . nodes [ 0 ] . createwallet ( wallet_name = ' w7 ' , disable_private_keys = False , blank = False , passphrase = ' ' )
assert ' Empty string given as passphrase, wallet will not be encrypted. ' in resp [ ' warning ' ]
assert_equal ( resp [ " warning " ] , EMPTY_PASSPHRASE_MSG if self . options . descriptors else f " { EMPTY_PASSPHRASE_MSG } \n { LEGACY_WALLET_MSG } " )
assert_equal ( resp [ " warnings " ] , [ EMPTY_PASSPHRASE_MSG ] if self . options . descriptors else [ EMPTY_PASSPHRASE_MSG , LEGACY_WALLET_MSG ] )
w7 = node . get_wallet_rpc ( ' w7 ' )
w7 = node . get_wallet_rpc ( ' w7 ' )
assert_raises_rpc_error ( - 15 , ' Error: running with an unencrypted wallet, but walletpassphrase was called. ' , w7 . walletpassphrase , ' ' , 60 )
assert_raises_rpc_error ( - 15 , ' Error: running with an unencrypted wallet, but walletpassphrase was called. ' , w7 . walletpassphrase , ' ' , 60 )
@ -174,8 +180,19 @@ class CreateWalletTest(BitcoinTestFramework):
if self . is_bdb_compiled ( ) :
if self . is_bdb_compiled ( ) :
self . log . info ( " Test legacy wallet deprecation " )
self . log . info ( " Test legacy wallet deprecation " )
res = self . nodes [ 0 ] . createwallet ( wallet_name = " legacy_w0 " , descriptors = False , passphrase = None )
result = self . nodes [ 0 ] . createwallet ( wallet_name = " legacy_w0 " , descriptors = False , passphrase = None )
assert_equal ( res [ " warning " ] , " Wallet created successfully. The legacy wallet type is being deprecated and support for creating and opening legacy wallets will be removed in the future. " )
assert_equal ( result , {
" name " : " legacy_w0 " ,
" warning " : LEGACY_WALLET_MSG ,
" warnings " : [ LEGACY_WALLET_MSG ] ,
} )
result = self . nodes [ 0 ] . createwallet ( wallet_name = " legacy_w1 " , descriptors = False , passphrase = " " )
assert_equal ( result , {
" name " : " legacy_w1 " ,
" warning " : f " { EMPTY_PASSPHRASE_MSG } \n { LEGACY_WALLET_MSG } " ,
" warnings " : [ EMPTY_PASSPHRASE_MSG , LEGACY_WALLET_MSG ] ,
} )
if __name__ == ' __main__ ' :
if __name__ == ' __main__ ' :
CreateWalletTest ( ) . main ( )
CreateWalletTest ( ) . main ( )