Skip to content

Special characters in wallet_name #21510

@ghost

Description

I am testing few things with different strings in wallet_name containing special characters because of few related issues and PRs mentioned in the end.

Expected behavior

Ideally few special chars should not be allowed and if allowed the wallet should be created only in wallets directory unless a path is mentioned with other argument. Right now same argument is used for name and path. Maybe there can be better solutions but Bitcoin Core's weird behavior with wallet names in some cases can be fixed.

Actual behavior

I tried creating few wallets with random strings as wallet_name. Some of them are not even visible in listwalletdir or Bitcoin-Qt->File->Open Wallet

To reproduce

import random 
import string
from bitcoinrpc.authproxy import AuthServiceProxy

rpc_port = 18444
rpc_user = 'user3'
rpc_password = 'pass3'

def wallet_name(size): 
	
	generate_wallet = ''.join([random.choice(string.punctuation + string.ascii_letters) 
						 for n in range(size)]) 
						
	return generate_wallet
 

rpc_connection = AuthServiceProxy("http://%s:%s@127.0.0.1:%s"%(rpc_user,rpc_password,rpc_port))

for i in range(100):
    wallet = wallet_name(20)
    print(wallet)
    try:
        result = rpc_connection.createwallet(wallet)        
    except:
        pass    

The above code will try to create 100 wallets with random strings containing special characters. Not every string tried (and printed) will be used for creating a wallet, exceptions are ignored and next string is tried.

Once few wallets are created with random strings, we can check the wallet folders in testnet3\wallets which is different from the wallets that we see in results of listwalletdir or Bitcoin-Qt->File->Open Wallet

System information

Bitcoin Core v0.21.0

Windows 10

Related issues: #21501 #19928 #20128
Related PRs: #20080 #20393 #20741

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions