Special characters in `wallet_name` #21510

issue ghost opened this issue on March 23, 2021
  1. ghost commented at 4:38 AM on March 23, 2021: none

    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 https://github.com/bitcoin/bitcoin/issues/19928 #20128 Related PRs: #20080 https://github.com/bitcoin/bitcoin/pull/20393 https://github.com/bitcoin/bitcoin/pull/20741

  2. unknown added the label Bug on Mar 23, 2021
  3. ryanofsky commented at 5:31 AM on March 23, 2021: member

    If you are calling createwallet(path) with a relative path, or absolute path inside the wallets directory and it succeeds without creating the wallet or listing it in listwalletdir, that's definitely a bug, and it would great if you could provide a specific path or narrow down which paths cause this.

    If you are calling createwallet(path) with a path outside the wallet directory, the wallet should be created, but it's expected to not be listed by listwalletdir because listwalletdir only lists the wallets in the wallets directory.

    Wallets are directories containing database and log files. Wallets don't have internal names separate from directory names because there hasn't been a need for internal names and it is potentially more confusing if wallets have two different names instead of one.

    A drawback of making wallet names directory names is that we have to follow limits of file systems. For example, we can't have two wallet names that differ only in case on case-insensitive files systems. Or we can't have wallets with special names CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, or LPT9 on windows. If you try to create wallets with forbidden names, it should fail gracefully with a clear error, and it's a bug if this isn't happening.

  4. ghost commented at 6:42 AM on March 23, 2021: none

    Before running the above mentioned python script:

    Zero wallets

    image

    Zero wallets

    image

    After running the python script:

    29 wallets

        Directory: E:\Bitcoin-Core\testnet3\wallets
    
    
    Mode                 LastWriteTime         Length Name
    ----                 -------------         ------ ----
    d-----        23-03-2021     11:35                $H);f+FxJIw`pjeFuc&!
    d-----        23-03-2021     11:36                '_N(Onr$L&W
    d-----        23-03-2021     11:35                ,NOcKVt^ZAb!xZZrlPd;
    d-----        23-03-2021     11:35                .!n#N$@j~-Fs{
    d-----        23-03-2021     11:35                .h_%)+w=iHI
    d-----        23-03-2021     11:35                dY)~eGo;L^xNFg=cSf$#
    d-----        23-03-2021     11:36                e!S$pg
    d-----        23-03-2021     11:36                fjI}x$E~Z]gXM@-ujJqA
    d-----        23-03-2021     11:35                ft#Er%CmXga
    d-----        23-03-2021     11:36                hD#HSlHa=d#]'eP.EZ+c
    d-----        23-03-2021     11:36                hf$&N
    d-----        23-03-2021     11:36                JhyPA%]@-F+hNnOhyGy&
    d-----        23-03-2021     11:35                M
    d-----        23-03-2021     11:35                mH
    d-----        23-03-2021     11:35                m_tCq
    d-----        23-03-2021     11:36                N
    d-----        23-03-2021     11:35                NJv
    d-----        23-03-2021     11:35                N}nQpHcFJpi&fq)gx=sK
    d-----        23-03-2021     11:35                Qi&`J
    d-----        23-03-2021     11:36                qynIaA]W=nHc~AebbI^X
    d-----        23-03-2021     11:36                RiS}&B{m
    d-----        23-03-2021     11:35                Ut
    d-----        23-03-2021     11:36                uThc%.wi$TK}'-rE^
    d-----        23-03-2021     11:36                W{idf.CaVc`V;gpVKYlx
    d-----        23-03-2021     11:35                XY;'w.(I}BDKU~&LYzga
    d-----        23-03-2021     11:36                yCG-EBUmSg(Dbjdl`M[+
    d-----        23-03-2021     11:36                z'G`j`JGEvaYnZZ)Nzgx
    d-----        23-03-2021     11:35                {~c
    d-----        23-03-2021     11:36                }c@S`NB)t%+HbMo(ioXV
    

    17 wallets

    image

    12 wallets which are missing from listwalletdir:

    N
    e!S$pg
    RiS}&B{m
    hf$&N
    M
    NJv
    Ut
    {~c
    m_tCq
    Qi&`J
    uThc%.wi$TK}'-rE^
    .h_%)+w=iHI
    

    Interesting that all these 12 are empty directories and there are no wallet related files inside.

    All the strings that were tried by the script for wallet_name:

    qagK@t+gt<WH+ny'Rueh
    LU-.hlUOt"skR;Zs\gHq
    vW{;qW;>j[~xMv!MXA[*
    N"tm}h$Iqh]^TE)t"uWi
    D&^"tc>ksrFr-D*D@jUf
    mH/}=[UH`i!R%s.DhZN`
    m_tCq\[{~)h*>tUxpKd#
    UI<BGE^_/eCZE#ebp{:D
    {~c/C"qkkGEV&K;'z<h&
    sl[RK`Ox"k[[Ia+.LRi@
    Qi&`J/Tt"alx\py.!dvL
    dY)~eGo;L^xNFg=cSf$#
    ]b@<yQ?fCbg;?Kf(w]LM
    *Z[?Zx#\mlH%<bt"`@#h
    .!n#N$@j~-Fs{\YPbR&w
    J{;Yzj_:IIi,j/>_@*JI
    `#IjD&<@,[knEpn)QDBl
    XCc)aI>J<;~pwpk"z[|&
    FHEcxk_lAI_|`Bjlv<*L
    _I**A_:=lvI'P=zy[vi'
    }:rSldmyS{:Jd<|cyq$N
    KC*B,]VwpA/p=<[UvY&,
    ){.HGz+"e{On@qI`rkRd
    N}nQpHcFJpi&fq)gx=sK
    NJv/?cA"m;i",CP=>^VC
    Tf];P{L"C`$_qdTJ_E$\
    'NhYfgU~@*W/{JgTcX`z
    [@z](/bitcoin-bitcoin/contributor/z/)=`(u*_;$,"Hk)+KHy(
    Ut/zCd/&=rCUY<.$Q~:C
    M\+r.x(-v<Lw|,c/=OHY
    De<WU@U?#QW!:gh"bIhS
    XY;'w.(I}BDKU~&LYzga
    TG:sU(.>a$s'T,m]`+[M
    @(<{s,&jROH"slzf*`R:
    CELB{A{ENW)t(>qULw^D
    NUBhzxuvc>MaLg;+%gGx
    >bIF`j)R\;\E:r^n\~mr
    Cz:sTWT~JXH&ep@;JLg\
    .h_%)+w=iHI\W=nqCiB:
    kV|QxW[UpPHY!tR_ff=a
    ^Y^l]H*<{:i~lZE{Rn$"
    >Lr`^~\zf{{J+;_X_N:O
    =tX`H|:wkv!YQ:.O<uNs
    zc+i-T<rcINuwSqr)k'(
    =h:TcHS}/+mMi$KH{gmZ
    ft#Er%CmXga/$AeR%]kW
    \)S$+z@,m*%B_YcJSvYi
    s#z!LpVkhqZ%@Rd<Vleu
    $H);f+FxJIw`pjeFuc&!
    ,NOcKVt^ZAb!xZZrlPd;
    hf$&N\zli(Qh"kYXEq/A
    m@ZmkBGAG+hRevg'~?Kk
    qynIaA]W=nHc~AebbI^X
    hD#HSlHa=d#]'eP.EZ+c
    RiS}&B{m/AGCf|:Po`d~
    *e!=|<A*OOqum-_IFpb^
    GCypzOzXbO<>A!~!wXeM
    L;iyHJpgTNQsIT@'"Nt$
    fjI}x$E~Z]gXM@-ujJqA
    L|+Rw|ChWG^t*^ca`PkB
    [,[xsz,Ha>x@".'W'z\(
    k*C(qt'YsdPiz<\N@XY]
    ,qPvq&guX%IBo>UGA('R
    \&!(xehWHmOye\Z?&^j_
    [=hSxy}V)bS#KPFq:u&=
    JhyPA%]@-F+hNnOhyGy&
    '_N(Onr$L&W\\)iHg/Qy
    J>Y}~>Us!BK'$#ullC`"
    vdEVV{m<~'SknPjG~$L'
    il'c>'Q\:AyWE}JqilPC
    }:&@,lrhebyLw+U"zX%h
    |Cr")k?|NiMb(#z{[b&O
    rM`btv"BY?vSOHM?(EX-
    ?QgDv>hhgl@`$KUYbxfU
    RgA,*d,f+R{#enlbk*QH
    TI_O+XQd"`lS)|eI?cKj
    oe])_Lm"-tSLhVcPxymu
    Gf~t>-Oz;iS&zeWXPm)\
    *.W*aFK~<M-BP~Suins\
    ]zO#C"ctzFJQo"C,*f,e
    >u?GDVml>YS|K'OUSwga
    `$t<YSCUWGGg[XRs\`C{
    ,<yayh:K+K};{<[j*O`B
    z'G`j`JGEvaYnZZ)Nzgx
    X.[U_Z:a#<c<{&Hl#]yY
    U+|xwfEJ[aCpXO`D:Ri!
    }c@S`NB)t%+HbMo(ioXV
    Ne+gc:W]bN/v<x}=lOZf
    vB-+coaq?Kg_.[AJGzWQ
    e!S$pg\q?#UAqpZ$EUtQ
    *>WB{s`Bd+zqHh-eCl/'
    W{idf.CaVc`V;gpVKYlx
    LV]z@|}jj>fw_QTdLuOe
    <Xi^Aq,$DRoQr_oiImrC
    yCG-EBUmSg(Dbjdl`M[+
    IE("ayHmI~wpNEIf^|rh
    MTrQ$STykE)P(]HhewH<
    N/eYg{~|"!|de\;.IinJ
    uThc%.wi$TK}'-rE^\^"
    /R`ras_wSiMztn\-E//(
    

    The error message I get if exception is printed instead of using pass:

    -1: boost::filesystem::create_directories: The filename, directory name, or volume label syntax is incorrect:
    
  5. fanquake added the label Wallet on Mar 23, 2021
  6. fanquake deleted a comment on Mar 24, 2021
  7. fanquake deleted a comment on Mar 24, 2021
  8. ghost commented at 2:09 PM on May 12, 2021: none

    Tried using Burp Suite for testing few days back: https://bitcoin.stackexchange.com/questions/105838/rate-limits-bitcoin-core-json-rpc

    Found some issues while reviewing PR today: #21907

    GUI:

    image

    CLI:

    https://pastebin.com/BnxU9QeK

    Few examples from the list:

        {
          "name": "inance"
        },
        {
          "name": "ore-Backup\\Bitcoin-Core\\testnet3\\WalletA"
        },
        {
          "name": "ore-Backup\\bitcoin-mainnet\\Test-Wallet-2"
        },
        {
          "name": "ore-Backup\\Testnet\\Bitcoin-Core\\testnet3\\WalletA"
        },
        {
          "name": "egtest\\wallets"
        },
        {
          "name": "estnet3\\wallets"
    

    Result for dir in E:\ https://pastebin.com/ieTPM6z7

  9. meshcollider closed this on Jun 9, 2021

  10. sidhujag referenced this in commit a150948159 on Jun 9, 2021
  11. DrahtBot locked this on Aug 18, 2022
  12. PastaPastaPasta referenced this in commit 436245d732 on Apr 15, 2023
  13. PastaPastaPasta referenced this in commit 165ca7a39b on Apr 15, 2023
  14. PastaPastaPasta referenced this in commit e2203f9470 on Apr 16, 2023
  15. PastaPastaPasta referenced this in commit 0cd4553927 on Apr 16, 2023
  16. UdjinM6 referenced this in commit 3aab3efaa5 on Apr 16, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me