From 70fb77d2d1681604288b6d21a0a6368941b410e6 Mon Sep 17 00:00:00 2001 From: Oliver Aemmer Date: Wed, 1 May 2024 20:18:47 +0200 Subject: [PATCH] wallet.proto: rename to Key.Type.ENCRYPTED from ENCRYPTED_SCRYPT_AES --- .../src/main/java/org/bitcoinj/wallet/BasicKeyChain.java | 6 +++--- core/src/main/proto/wallet.proto | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/bitcoinj/wallet/BasicKeyChain.java b/core/src/main/java/org/bitcoinj/wallet/BasicKeyChain.java index 6dfba880d..fea425301 100644 --- a/core/src/main/java/org/bitcoinj/wallet/BasicKeyChain.java +++ b/core/src/main/java/org/bitcoinj/wallet/BasicKeyChain.java @@ -361,7 +361,7 @@ public class BasicKeyChain implements EncryptableKeyChain { .setInitialisationVector(ByteString.copyFrom(data.initialisationVector))); // We don't allow mixing of encryption types at the moment. checkState(item.getEncryptionType() == Protos.Wallet.EncryptionType.ENCRYPTED_SCRYPT_AES); - proto.setType(Protos.Key.Type.ENCRYPTED_SCRYPT_AES); + proto.setType(Protos.Key.Type.ENCRYPTED); } else { final byte[] secret = item.getSecretBytes(); // The secret might be missing in the case of a watching wallet, or a key for which the private key @@ -401,9 +401,9 @@ public class BasicKeyChain implements EncryptableKeyChain { checkState(hashToKeys.isEmpty(), () -> "tried to deserialize into a non-empty chain"); for (Protos.Key key : keys) { - if (key.getType() != Protos.Key.Type.ORIGINAL && key.getType() != Protos.Key.Type.ENCRYPTED_SCRYPT_AES) + if (key.getType() != Protos.Key.Type.ORIGINAL && key.getType() != Protos.Key.Type.ENCRYPTED) continue; - boolean encrypted = key.getType() == Protos.Key.Type.ENCRYPTED_SCRYPT_AES; + boolean encrypted = key.getType() == Protos.Key.Type.ENCRYPTED; byte[] priv = key.hasSecretBytes() ? key.getSecretBytes().toByteArray() : null; if (!key.hasPublicKey()) throw new UnreadableWalletException("Public key missing"); diff --git a/core/src/main/proto/wallet.proto b/core/src/main/proto/wallet.proto index 2fee59800..df2042a19 100644 --- a/core/src/main/proto/wallet.proto +++ b/core/src/main/proto/wallet.proto @@ -86,11 +86,18 @@ message DeterministicKey { */ message Key { enum Type { + option allow_alias = true; /** Unencrypted - Original bitcoin secp256k1 curve */ ORIGINAL = 1; + /** + * Encrypted - Original bitcoin secp256k1 curve + * Details of the encryption are declared via Wallet.EncryptionType enum + */ + ENCRYPTED = 2; + /** Encrypted with Scrypt and AES - Original bitcoin secp256k1 curve */ - ENCRYPTED_SCRYPT_AES = 2; + ENCRYPTED_SCRYPT_AES = 2 [deprecated = true]; /** * Not really a key, but rather contains the mnemonic phrase for a deterministic key hierarchy in the private_key field.