Wallet encryption RPC
Summary
Section titled “Summary”This page maps BitcoinII Core v31.1.0 wallet encryption/access RPC behavior centered on src/wallet/rpc/encrypt.cpp.
The current MoreBC2 disposable-wallet runtime work did not encrypt a wallet, unlock one, change a passphrase, or relock an encrypted wallet. These commands therefore remain source-reviewed and deliberately untested in the current evidence set.
Commands reviewed
Section titled “Commands reviewed”walletpassphrasewalletpassphrasechangewalletlockencryptwallet
walletpassphrase
Section titled “walletpassphrase”Source-reviewed behavior includes:
- requires an encrypted wallet;
- rejects invalid/empty passphrase input and negative timeout;
- bounds very large timeout values;
- attempts wallet unlock;
- updates keypool/access state as appropriate;
- records a relock time;
- schedules later wallet locking;
- allows a later unlock request to supersede an earlier scheduled relock.
A timed unlock is sensitive wallet state, not a harmless read-only action.
walletpassphrasechange
Section titled “walletpassphrasechange”Source-reviewed behavior includes:
- requires an already encrypted wallet;
- rejects empty old/new passphrases;
- avoids conflicting passphrase-dependent rescan state;
- attempts the passphrase change under wallet locking.
MoreBC2 has not runtime-tested passphrase change or recovery from an incorrect passphrase on v31.
walletlock
Section titled “walletlock”walletlock removes wallet decryption access from memory and clears relock-time state in the reviewed path.
It has not been exercised in the current disposable-wallet runtime record.
encryptwallet
Section titled “encryptwallet”Source-reviewed behavior includes:
- rejects wallets without private keys;
- rejects already encrypted wallets;
- rejects empty passphrases;
- avoids conflicting passphrase-dependent rescan state;
- routes through the wallet encryption path;
- returns backup-related guidance after first-time encryption.
The existing source guidance that a new backup is required after encryption is important: encryption is not complete operational assurance unless backup and restore have also been tested for the specific wallet workflow.
Current runtime boundary
Section titled “Current runtime boundary”September v31.1.0 wallet evidence establishes:
- creation of fresh disposable descriptor wallets;
- wallet directory persistence and explicit reload after restart;
- disposable regtest address generation/funding;
- PSBT funding/signing/finalization;
- local mempool acceptance/submission.
It does not establish encrypted-wallet behavior.
No existing user wallet was unlocked or encrypted for documentation testing.
Replay-protection relevance
Section titled “Replay-protection relevance”Wallet encryption controls access to signing keys; replay protection controls the signature digest domain used when those keys sign a transaction.
A wallet can be correctly encrypted/unlocked yet still require BC2’s post-height-57750 replay domain for valid current-mainnet signing. These are separate security/correctness concerns.
See Replay protection v31 and Wallet spend and PSBT RPC.
Documentation safety rules
Section titled “Documentation safety rules”- Never ask users to paste real wallet passphrases into chat, logs, screenshots, or issue reports.
- Do not test encryption/unlock workflows on an existing user wallet.
- Use a fresh disposable wallet with no real funds.
- Test backup/restore separately before treating encryption as operationally complete.
- Record wallet type, Core version, network, timeout/relock behavior, and restart behavior.
- Keep sensitive commands out of beginner examples until the disposable workflow is verified.
Related pages
Section titled “Related pages”- Wallet RPC
- Wallet backup/import RPC
- Wallet spend and PSBT RPC
- Wallet guide
- Windows v31 PSBT validation
Open work
Section titled “Open work”Highest-value safe test:
- create a new disposable descriptor wallet;
- create and verify a backup first;
- encrypt it with a disposable test passphrase;
- test unlock timeout/relock and manual
walletlock; - test passphrase change;
- restart/reload and verify expected locked state;
- restore the disposable backup in a separate test wallet;
- destroy all disposable test artifacts/passphrases.
Primary sources
Section titled “Primary sources”Pinned/current review scope:
v31.1.0/src/wallet/rpc/encrypt.cppv31.1.0/src/wallet/wallet.*v31.1.0/src/wallet/rpc/backup.cpp
Canonical tag: https://github.com/Bitcoin-II/BitcoinII-Core/tree/v31.1.0
Verification
Section titled “Verification”Status: Reviewed / Source-only partial
Primary evidence: BitcoinII Core v31.1.0 wallet-encryption source plus adjacent September disposable-wallet runtime evidence
Notes: Encryption/passphrase/relock behavior remains untested by MoreBC2. The page is current about that limitation and preserves the no-existing-wallet safety boundary.