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

issue hebasto openend 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:

     0...
     12021-05-11T12:07:20Z [init] Using SQLite Version 3.31.1
     22021-05-11T12:07:20Z [init] Using wallet /home/hebasto/.bitcoin/testnet3/wallets/coldcard_t
     32021-05-11T12:07:20Z [init] init message: Loading wallet…
     42021-05-11T12:07:20Z [init] [coldcard_t] LoadDescriptorScriptPubKeyMan: Compiled without external signing support (required for external signing)
     52021-05-11T12:07:20Z [init] [coldcard_t] LoadDescriptorScriptPubKeyMan: Compiled without external signing support (required for external signing)
     62021-05-11T12:07:20Z [init] [coldcard_t] LoadDescriptorScriptPubKeyMan: Compiled without external signing support (required for external signing)
     72021-05-11T12:07:20Z [init] [coldcard_t] LoadDescriptorScriptPubKeyMan: Compiled without external signing support (required for external signing)
     82021-05-11T12:07:20Z [init] [coldcard_t] LoadDescriptorScriptPubKeyMan: Compiled without external signing support (required for external signing)
     92021-05-11T12:07:20Z [init] [coldcard_t] LoadDescriptorScriptPubKeyMan: Compiled without external signing support (required for external signing)
    102021-05-11T12:07:20Z [init] [coldcard_t] Setting spkMan to active: id = c2fe2eddfccf102a74da940e282062adc8c13fbd28d00477644d3fcd1f6efe5d, type = 0, internal = 0
    112021-05-11T12:07:20Z [init] [coldcard_t] Releasing wallet
    122021-05-11T12:07:20Z [init] 
    13
    14************************
    15EXCEPTION: St12out_of_range       
    16map::at       
    17bitcoin in AppInit()       
    18
    19
    20
    21************************
    22EXCEPTION: St12out_of_range       
    23map::at       
    24bitcoin in AppInit()       
    25
    262021-05-11T12:07:20Z [init] Shutdown: In progress...
    272021-05-11T12:07:20Z [scheduler] scheduler thread exit
    282021-05-11T12:07:21Z [shutoff] FlushStateToDisk: write coins cache to disk (0 coins, 0kB) started
    292021-05-11T12:07:21Z [shutoff] FlushStateToDisk: write coins cache to disk (0 coins, 0kB) completed (0.00s)
    302021-05-11T12:07:21Z [shutoff] FlushStateToDisk: write coins cache to disk (0 coins, 0kB) started
    312021-05-11T12:07:21Z [shutoff] FlushStateToDisk: write coins cache to disk (0 coins, 0kB) completed (0.00s)
    322021-05-11T12:07:21Z [shutoff] [w20191120] Releasing wallet
    332021-05-11T12:07:21Z [shutoff] [watch-only] Releasing wallet
    342021-05-11T12:07:21Z [shutoff] [default wallet] Releasing wallet
    352021-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

     0--- a/src/wallet/load.cpp
     1+++ b/src/wallet/load.cpp
     2@@ -117,6 +117,9 @@ bool LoadWallets(interfaces::Chain& chain)
     3     } catch (const std::runtime_error& e) {
     4         chain.initError(Untranslated(e.what()));
     5         return false;
     6+    } catch (const std::exception& e) {
     7+        chain.initError(Untranslated(e.what()));
     8+        return false;
     9     }
    10 }
    11 
    

    the bitcoind output is:

     0...
     12021-05-11T12:18:21Z [init] Using SQLite Version 3.31.1
     22021-05-11T12:18:21Z [init] Using wallet /home/hebasto/.bitcoin/testnet3/wallets/coldcard_t
     32021-05-11T12:18:21Z [init] init message: Loading wallet…
     42021-05-11T12:18:21Z [init] [coldcard_t] LoadDescriptorScriptPubKeyMan: Compiled without external signing support (required for external signing)
     52021-05-11T12:18:21Z [init] [coldcard_t] LoadDescriptorScriptPubKeyMan: Compiled without external signing support (required for external signing)
     62021-05-11T12:18:21Z [init] [coldcard_t] LoadDescriptorScriptPubKeyMan: Compiled without external signing support (required for external signing)
     72021-05-11T12:18:21Z [init] [coldcard_t] LoadDescriptorScriptPubKeyMan: Compiled without external signing support (required for external signing)
     82021-05-11T12:18:21Z [init] [coldcard_t] LoadDescriptorScriptPubKeyMan: Compiled without external signing support (required for external signing)
     92021-05-11T12:18:21Z [init] [coldcard_t] LoadDescriptorScriptPubKeyMan: Compiled without external signing support (required for external signing)
    102021-05-11T12:18:21Z [init] [coldcard_t] Setting spkMan to active: id = c2fe2eddfccf102a74da940e282062adc8c13fbd28d00477644d3fcd1f6efe5d, type = 0, internal = 0
    112021-05-11T12:18:21Z [init] [coldcard_t] Releasing wallet
    122021-05-11T12:18:21Z [init] Error: map::at
    13Error: map::at
    142021-05-11T12:18:21Z [init] Shutdown: In progress...
    152021-05-11T12:18:22Z [scheduler] scheduler thread exit
    162021-05-11T12:18:22Z [shutoff] FlushStateToDisk: write coins cache to disk (0 coins, 0kB) started
    172021-05-11T12:18:22Z [shutoff] FlushStateToDisk: write coins cache to disk (0 coins, 0kB) completed (0.00s)
    182021-05-11T12:18:22Z [shutoff] FlushStateToDisk: write coins cache to disk (0 coins, 0kB) started
    192021-05-11T12:18:22Z [shutoff] FlushStateToDisk: write coins cache to disk (0 coins, 0kB) completed (0.00s)
    202021-05-11T12:18:23Z [shutoff] [w20191120] Releasing wallet
    212021-05-11T12:18:23Z [shutoff] [watch-only] Releasing wallet
    222021-05-11T12:18:23Z [shutoff] [default wallet] Releasing wallet
    232021-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: 2024-07-03 13:13 UTC

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