Merge bitcoin/bitcoin#32675: test: wallet: cover wallet passphrase with a null char

7cfbb8575e1ffbad5c48e2c461b45dd6ac63d064 test: wallet: cover wallet passphrase with a null char (brunoerg)

Pull request description:

  This PR adds test coverage for the `walletpassphrase`/`walletpassphrasechange` RPC when the passphrase is incorrect due to a null character.

  For reference: https://github.com/bitcoin/bitcoin/pull/27068 introduced the usage of `SecureString` to allow null characters.

ACKs for top commit:
  maflcko:
    lgtm ACK 7cfbb8575e1ffbad5c48e2c461b45dd6ac63d064
  achow101:
    ACK 7cfbb8575e1ffbad5c48e2c461b45dd6ac63d064
  w0xlt:
    Code review ACK 7cfbb8575e
  BrandonOdiwuor:
    Code Review ACK 7cfbb8575e1ffbad5c48e2c461b45dd6ac63d064
  theStack:
    ACK 7cfbb8575e1ffbad5c48e2c461b45dd6ac63d064
  pablomartin4btc:
    cr ACK 7cfbb8575e1ffbad5c48e2c461b45dd6ac63d064

Tree-SHA512: ecdb48662ceb6c55c4b301ca7f537c3159ece7b66ee40ea977583ffb74bd3d06e334ab3a5639a9cde3aa6443129f412f9aea0ee5a8b73b31dba0728d0890b7f1
This commit is contained in:
Ava Chow 2025-06-06 15:12:01 -07:00
commit 2053c43684
No known key found for this signature in database
GPG Key ID: 17565732E08E5E41

View File

@ -95,6 +95,9 @@ class WalletEncryptionTest(BitcoinTestFramework):
self.nodes[0].walletpassphrasechange(passphrase2, passphrase_with_nulls)
# walletpassphrasechange should not stop at null characters
assert_raises_rpc_error(-14, "wallet passphrase entered was incorrect", self.nodes[0].walletpassphrase, passphrase_with_nulls.partition("\0")[0], 10)
assert_raises_rpc_error(-14, "The wallet passphrase entered was incorrect", self.nodes[0].walletpassphrasechange, passphrase_with_nulls.partition("\0")[0], "abc")
assert_raises_rpc_error(-14, "wallet passphrase entered is incorrect. It contains a null character (ie - a zero byte)", self.nodes[0].walletpassphrase, passphrase_with_nulls + "\0", 10)
assert_raises_rpc_error(-14, "The old wallet passphrase entered is incorrect. It contains a null character (ie - a zero byte)", self.nodes[0].walletpassphrasechange, passphrase_with_nulls + "\0", "abc")
with WalletUnlock(self.nodes[0], passphrase_with_nulls):
sig = self.nodes[0].signmessage(address, msg)
assert self.nodes[0].verifymessage(address, sig, msg)