From e8f84afd3eaeb26bd671485c81eb03a0bb8ccf0c Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Thu, 1 Feb 2024 01:17:56 +0700 Subject: [PATCH] refactor: move BIP39 related code to wallet --- src/Makefile.am | 6 +++--- src/Makefile.test.include | 4 ++-- src/{ => wallet}/bip39.cpp | 4 ++-- src/{ => wallet}/bip39.h | 6 +++--- src/{ => wallet}/bip39_english.h | 6 +++--- src/wallet/hdchain.cpp | 2 +- src/wallet/init.cpp | 2 +- src/{ => wallet}/test/bip39_tests.cpp | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) rename src/{ => wallet}/bip39.cpp (98%) rename src/{ => wallet}/bip39.h (94%) rename src/{ => wallet}/bip39_english.h (99%) rename src/{ => wallet}/test/bip39_tests.cpp (98%) diff --git a/src/Makefile.am b/src/Makefile.am index cbaf065b37..e0258a6775 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -138,8 +138,6 @@ BITCOIN_CORE_H = \ base58.h \ batchedlogger.h \ bech32.h \ - bip39.h \ - bip39_english.h \ blockencodings.h \ bloom.h \ cachemap.h \ @@ -364,6 +362,8 @@ BITCOIN_CORE_H = \ validationinterface.h \ versionbits.h \ wallet/bdb.h \ + wallet/bip39.h \ + wallet/bip39_english.h \ wallet/coincontrol.h \ wallet/coinselection.h \ wallet/context.h \ @@ -540,6 +540,7 @@ libbitcoin_wallet_a_SOURCES = \ coinjoin/client.cpp \ coinjoin/interfaces.cpp \ coinjoin/util.cpp \ + wallet/bip39.cpp \ wallet/coincontrol.cpp \ wallet/context.cpp \ wallet/crypter.cpp \ @@ -708,7 +709,6 @@ libbitcoin_common_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) libbitcoin_common_a_SOURCES = \ base58.cpp \ bech32.cpp \ - bip39.cpp \ bloom.cpp \ chainparams.cpp \ coins.cpp \ diff --git a/src/Makefile.test.include b/src/Makefile.test.include index 75227a8f81..a7cd3ceb0b 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -46,8 +46,8 @@ FUZZ_SUITE_LD_COMMON = \ $(LIBTEST_FUZZ) \ $(LIBTEST_UTIL) \ $(LIBBITCOIN_CONSENSUS) \ - $(LIBBITCOIN_CRYPTO) \ $(LIBBITCOIN_WALLET) \ + $(LIBBITCOIN_CRYPTO) \ $(LIBBITCOIN_CLI) \ $(LIBDASHBLS) \ $(BDB_LIBS) \ @@ -83,7 +83,6 @@ BITCOIN_TESTS =\ test/base64_tests.cpp \ test/bech32_tests.cpp \ test/bip32_tests.cpp \ - test/bip39_tests.cpp \ test/block_reward_reallocation_tests.cpp \ test/blockchain_tests.cpp \ test/blockencodings_tests.cpp \ @@ -181,6 +180,7 @@ BITCOIN_TESTS =\ if ENABLE_WALLET BITCOIN_TESTS += \ + wallet/test/bip39_tests.cpp \ wallet/test/coinjoin_tests.cpp \ wallet/test/psbt_wallet_tests.cpp \ wallet/test/wallet_tests.cpp \ diff --git a/src/bip39.cpp b/src/wallet/bip39.cpp similarity index 98% rename from src/bip39.cpp rename to src/wallet/bip39.cpp index 0cae4f43ea..2cf0eb79c7 100644 --- a/src/bip39.cpp +++ b/src/wallet/bip39.cpp @@ -24,8 +24,8 @@ // Source: // https://github.com/trezor/trezor-crypto -#include -#include +#include +#include #include #include #include diff --git a/src/bip39.h b/src/wallet/bip39.h similarity index 94% rename from src/bip39.h rename to src/wallet/bip39.h index 30f3a6880e..b8bf2262ae 100644 --- a/src/bip39.h +++ b/src/wallet/bip39.h @@ -21,8 +21,8 @@ * OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef BITCOIN_BIP39_H -#define BITCOIN_BIP39_H +#ifndef BITCOIN_WALLET_BIP39_H +#define BITCOIN_WALLET_BIP39_H #include @@ -36,4 +36,4 @@ public: static void ToSeed(SecureString mnemonic, SecureString passphrase, SecureVector& seedRet); }; -#endif // BITCOIN_BIP39_H +#endif // BITCOIN_WALLET_BIP39_H diff --git a/src/bip39_english.h b/src/wallet/bip39_english.h similarity index 99% rename from src/bip39_english.h rename to src/wallet/bip39_english.h index 961157479c..19547f512f 100644 --- a/src/bip39_english.h +++ b/src/wallet/bip39_english.h @@ -21,8 +21,8 @@ * OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef BITCOIN_BIP39_ENGLISH_H -#define BITCOIN_BIP39_ENGLISH_H +#ifndef BITCOIN_WALLET_BIP39_ENGLISH_H +#define BITCOIN_WALLET_BIP39_ENGLISH_H const char * const wordlist[] = { "abandon", @@ -2076,4 +2076,4 @@ const char * const wordlist[] = { 0, }; -#endif // BITCOIN_BIP39_ENGLISH_H +#endif // BITCOIN_WALLET_BIP39_ENGLISH_H diff --git a/src/wallet/hdchain.cpp b/src/wallet/hdchain.cpp index 436529494c..b4fca803a3 100644 --- a/src/wallet/hdchain.cpp +++ b/src/wallet/hdchain.cpp @@ -3,7 +3,7 @@ #include -#include +#include #include #include #include diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp index e7a9800749..15bd3a1dc5 100644 --- a/src/wallet/init.cpp +++ b/src/wallet/init.cpp @@ -20,12 +20,12 @@ #ifdef USE_BDB #include #endif +#include #include #include #include #include -#include #include #include diff --git a/src/test/bip39_tests.cpp b/src/wallet/test/bip39_tests.cpp similarity index 98% rename from src/test/bip39_tests.cpp rename to src/wallet/test/bip39_tests.cpp index 34796df99b..2eb63d66e7 100644 --- a/src/test/bip39_tests.cpp +++ b/src/wallet/test/bip39_tests.cpp @@ -4,7 +4,7 @@ #include -#include +#include #include #include #include