wallet: bitcoind fails to auto-load a non-empty external-signer wallet #21919

issue hebasto opened this issue on May 11, 2021
  1. hebasto commented at 1:25 PM on May 11, 2021: member

    When a non-empty wallet with the WALLET_FLAG_EXTERNAL_SIGNER flag is supposed to be auto-loaded, i.e., it is mentioned in the settings.json file, and binaries are built with the --disable-external-signer configure option, the bitcoind fails:

    ...
    2021-05-11T12:07:20Z [init] Using SQLite Version 3.31.1
    2021-05-11T12:07:20Z [init] Using wallet /home/hebasto/.bitcoin/testnet3/wallets/coldcard_t
    2021-05-11T12:07:20Z [init] init message: Loading wallet…
    2021-05-11T12:07:20Z [init] [coldcard_t] LoadDescriptorScriptPubKeyMan: Compiled without external signing support (required for external signing)
    2021-05-11T12:07:20Z [init] [coldcard_t] LoadDescriptorScriptPubKeyMan: Compiled without external signing support (required for external signing)
    2021-05-11T12:07:20Z [init] [coldcard_t] LoadDescriptorScriptPubKeyMan: Compiled without external signing support (required for external signing)
    2021-05-11T12:07:20Z [init] [coldcard_t] LoadDescriptorScriptPubKeyMan: Compiled without external signing support (required for external signing)
    2021-05-11T12:07:20Z [init] [coldcard_t] LoadDescriptorScriptPubKeyMan: Compiled without external signing support (required for external signing)
    2021-05-11T12:07:20Z [init] [coldcard_t] LoadDescriptorScriptPubKeyMan: Compiled without external signing support (required for external signing)
    2021-05-11T12:07:20Z [init] [coldcard_t] Setting spkMan to active: id = c2fe2eddfccf102a74da940e282062adc8c13fbd28d00477644d3fcd1f6efe5d, type = 0, internal = 0
    2021-05-11T12:07:20Z [init] [coldcard_t] Releasing wallet
    2021-05-11T12:07:20Z [init] 
    
    ************************
    EXCEPTION: St12out_of_range       
    map::at       
    bitcoin in AppInit()       
    
    
    
    ************************
    EXCEPTION: St12out_of_range       
    map::at       
    bitcoin in AppInit()       
    
    2021-05-11T12:07:20Z [init] Shutdown: In progress...
    2021-05-11T12:07:20Z [scheduler] scheduler thread exit
    2021-05-11T12:07:21Z [shutoff] FlushStateToDisk: write coins cache to disk (0 coins, 0kB) started
    2021-05-11T12:07:21Z [shutoff] FlushStateToDisk: write coins cache to disk (0 coins, 0kB) completed (0.00s)
    2021-05-11T12:07:21Z [shutoff] FlushStateToDisk: write coins cache to disk (0 coins, 0kB) started
    2021-05-11T12:07:21Z [shutoff] FlushStateToDisk: write coins cache to disk (0 coins, 0kB) completed (0.00s)
    2021-05-11T12:07:21Z [shutoff] [w20191120] Releasing wallet
    2021-05-11T12:07:21Z [shutoff] [watch-only] Releasing wallet
    2021-05-11T12:07:21Z [shutoff] [default wallet] Releasing wallet
    2021-05-11T12:07:21Z [shutoff] Shutdown: done
    

    The reason is the CWallet::Create throws an exception that is not caught in https://github.com/bitcoin/bitcoin/blob/e175a20769b5a7b98ee3082d89f9d4f31a4503d6/src/wallet/load.cpp#L117-L120

    With the following diff

    --- a/src/wallet/load.cpp
    +++ b/src/wallet/load.cpp
    @@ -117,6 +117,9 @@ bool LoadWallets(interfaces::Chain& chain)
         } catch (const std::runtime_error& e) {
             chain.initError(Untranslated(e.what()));
             return false;
    +    } catch (const std::exception& e) {
    +        chain.initError(Untranslated(e.what()));
    +        return false;
         }
     }
     
    

    the bitcoind output is:

    ...
    2021-05-11T12:18:21Z [init] Using SQLite Version 3.31.1
    2021-05-11T12:18:21Z [init] Using wallet /home/hebasto/.bitcoin/testnet3/wallets/coldcard_t
    2021-05-11T12:18:21Z [init] init message: Loading wallet…
    2021-05-11T12:18:21Z [init] [coldcard_t] LoadDescriptorScriptPubKeyMan: Compiled without external signing support (required for external signing)
    2021-05-11T12:18:21Z [init] [coldcard_t] LoadDescriptorScriptPubKeyMan: Compiled without external signing support (required for external signing)
    2021-05-11T12:18:21Z [init] [coldcard_t] LoadDescriptorScriptPubKeyMan: Compiled without external signing support (required for external signing)
    2021-05-11T12:18:21Z [init] [coldcard_t] LoadDescriptorScriptPubKeyMan: Compiled without external signing support (required for external signing)
    2021-05-11T12:18:21Z [init] [coldcard_t] LoadDescriptorScriptPubKeyMan: Compiled without external signing support (required for external signing)
    2021-05-11T12:18:21Z [init] [coldcard_t] LoadDescriptorScriptPubKeyMan: Compiled without external signing support (required for external signing)
    2021-05-11T12:18:21Z [init] [coldcard_t] Setting spkMan to active: id = c2fe2eddfccf102a74da940e282062adc8c13fbd28d00477644d3fcd1f6efe5d, type = 0, internal = 0
    2021-05-11T12:18:21Z [init] [coldcard_t] Releasing wallet
    2021-05-11T12:18:21Z [init] Error: map::at
    Error: map::at
    2021-05-11T12:18:21Z [init] Shutdown: In progress...
    2021-05-11T12:18:22Z [scheduler] scheduler thread exit
    2021-05-11T12:18:22Z [shutoff] FlushStateToDisk: write coins cache to disk (0 coins, 0kB) started
    2021-05-11T12:18:22Z [shutoff] FlushStateToDisk: write coins cache to disk (0 coins, 0kB) completed (0.00s)
    2021-05-11T12:18:22Z [shutoff] FlushStateToDisk: write coins cache to disk (0 coins, 0kB) started
    2021-05-11T12:18:22Z [shutoff] FlushStateToDisk: write coins cache to disk (0 coins, 0kB) completed (0.00s)
    2021-05-11T12:18:23Z [shutoff] [w20191120] Releasing wallet
    2021-05-11T12:18:23Z [shutoff] [watch-only] Releasing wallet
    2021-05-11T12:18:23Z [shutoff] [default wallet] Releasing wallet
    2021-05-11T12:18:23Z [shutoff] Shutdown: done
    

    Noted while reviewing https://github.com/bitcoin-core/gui/pull/4.

  2. hebasto added the label Bug on May 11, 2021
  3. hebasto added the label Wallet on May 11, 2021
  4. Rspigler commented at 9:45 PM on May 11, 2021: contributor

    Doesn't it need to be built with --enable-external-signer in order to load the wallet?

  5. hebasto commented at 9:33 AM on May 12, 2021: member

    Doesn't it need to be built with --enable-external-signer in order to load the wallet?

    If so, it is a UX flaw because the --enable-external-signer should not be required if a user is going to check his wallet without signing new transactions.

  6. Rspigler commented at 7:40 PM on May 12, 2021: contributor

    Hm, I don't know @Sjors

  7. Sjors commented at 7:45 PM on May 12, 2021: member

    Presumably this applies to any mandatory wallet flag that's not supported? See also https://github.com/bitcoin-core/gui/pull/236

    I've had to delete settings.json countless times :-)

    The flag is mandatory. Although in this case there's no harm in loading it, see #21928. But in general it's not safe to open a wallet with a mandatory flag we don't understand.

  8. Sjors commented at 4:27 PM on May 14, 2021: member

    I added a commit that makes this behave better in #21935.

  9. meshcollider commented at 9:04 PM on June 9, 2021: contributor

    Fixed in #22173

  10. meshcollider closed this on Jun 9, 2021

  11. fanquake referenced this in commit 7c561bea52 on Jun 17, 2021
  12. DrahtBot locked this on Aug 18, 2022

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-17 00:14 UTC

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