Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 0e211a2

Browse files
committed
Wallet Migration Tool: Reimplement MigrateWallet and Strip Down.
Signed-off-by: Pttn <28868425+Pttn@users.noreply.github.com>
1 parent 632cd18 commit 0e211a2

File tree

511 files changed

+8803
-382482
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

511 files changed

+8803
-382482
lines changed

Makefile.am

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ $(BITCOIN_WIN_INSTALLER): all-recursive
7272
STRIPPROG="$(STRIP)" $(INSTALL_STRIP_PROGRAM) $(BITCOIN_QT_BIN) $(top_builddir)/release
7373
STRIPPROG="$(STRIP)" $(INSTALL_STRIP_PROGRAM) $(BITCOIN_TEST_BIN) $(top_builddir)/release
7474
STRIPPROG="$(STRIP)" $(INSTALL_STRIP_PROGRAM) $(BITCOIN_CLI_BIN) $(top_builddir)/release
75-
STRIPPROG="$(STRIP)" $(INSTALL_STRIP_PROGRAM) $(BITCOIN_TX_BIN) $(top_builddir)/release
76-
STRIPPROG="$(STRIP)" $(INSTALL_STRIP_PROGRAM) $(BITCOIN_WALLET_BIN) $(top_builddir)/release
7775
@test -f $(MAKENSIS) && echo 'OutFile "$@"' | cat $(top_builddir)/share/setup.nsi - | $(MAKENSIS) -V2 - || \
7876
echo error: could not build $@
7977
@echo built $@

README.md

Lines changed: 30 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,56 @@
1-
# Riecoin Core
1+
# Riecoin Wallet Migrator
22

3-
![Riecoin Logo](https://riecoin.xyz/Logos/Riecoin128.png)
3+
This is a stripped down version of Riecoin Core for migrating Legacy to Descriptor Wallets in order to be able to use Riecoin Core 23.04+.
44

5-
This repository hosts the Riecoin Core source code. Riecoin Core connects to the Bitcoin peer-to-peer network to download and fully validate blocks and transactions. It also includes a wallet and graphical user interface, which can be optionally built.
5+
Binaries for Linux and Windows x64 are provided on the present GitHub repository.
66

7-
Guides and release notes are available on the [project's page on Riecoin.xyz](https://riecoin.xyz/RiecoinCore).
8-
9-
## Riecoin Introduction
10-
11-
Riecoin is a currency based on Bitcoin, and follows in its footsteps into becoming a world currency. The Project supports and concretizes the idea that the gigantic mining resources can also serve scientific research, thus power a world currency of greater value for the society.
12-
13-
Riecoin miners are not looking for useless hashes, but doing actual scientific number crunching, like in Folding@Home or the GIMPS (currently, they are looking for prime constellations).
14-
15-
The project broke and holds several number theory world records, and demonstrated that scientific computations can be done using the PoW concept, and at the same time power a secure and practical international currency. It effectively solves the Bitcoin's power consumption issue without resorting to ideas like PoS that enrich the richer by design and makes value out of thin air.
16-
17-
Visit [Riecoin.xyz](https://riecoin.xyz/) to learn more about Riecoin.
18-
19-
## Build Riecoin Core
20-
21-
### Recent Debian/Ubuntu
22-
23-
Here are basic build instructions to generate the Riecoin Core binaries, including the Riecoin-Qt GUI wallet.
24-
25-
First, get the build tools and dependencies, which can be done by running as root the following commands.
7+
They can also be built following similar instructions as for [Riecoin Core](https://github.com/RiecoinTeam/Riecoin/). If not using Guix, BDB should be installed and `--with-incompatible-bdb` should be used.
268

279
```bash
28-
apt install build-essential libtool autotools-dev automake pkg-config bsdmainutils python3
29-
apt install libevent-dev libboost-system-dev libboost-filesystem-dev libboost-test-dev libboost-thread-dev libminiupnpc-dev libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libgmp-dev libsqlite3-dev libqrencode-dev
10+
./autogen.sh ; ./configure --with-incompatible-bdb ; make
3011
```
3112

32-
Get the source code.
13+
## Who Needs to Migrate?
3314

34-
```bash
35-
git clone https://github.com/RiecoinTeam/Riecoin.git
36-
```
15+
Users who are
3716

38-
Then,
17+
* currently using Riecoin Core **0.21 or older**,
18+
* currently using Riecoin Core **22.03**, but **already used 0.21 or older in the past** without recreating wallets via 22.03, or generated **purposely** Legacy Wallets with 22.03,
3919

40-
```bash
41-
cd Riecoin
42-
./autogen.sh ; ./configure ; make
43-
```
44-
45-
The Riecoin-Qt binary is located in `src/qt`. You can run `strip riecoin-qt` to reduce its size a lot.
20+
will have Legacy Wallets that need to be migrated. This is certain on 0.21 and older, on 22.03, you may double check if you indeed have Legacy Wallets with the `getwalletinfo` RPC Command (it is Legacy if it shows `"format": "bdb"` or ` "descriptors": false`; if it is not the case, you actually have a Descriptor Wallet that does not need to be upgraded).
4621

47-
#### Guix Build
22+
If you are using Riecoin Core **23.04** or more recent, you are **guaranteed** to have Descriptor Wallets and **no action** is required, **regardless** of whether you used 22.03 or older in the past (either because you already migrated or did not keep old wallets and generated new ones). 23.04+ are indeed unable to open Legacy Wallets.
4823

49-
Riecoin can be built using Guix. The process is longer, but also deterministic: everyone building this way should obtain the exact same binaries. Distributed binaries are produced this way, so anyone can ensure that they were not created with an altered source code by building themselves using Guix. Read the [Guix Guide](contrib/guix/README.md) for more details and options.
24+
## How to Migrate?
5025

51-
You should have a lot of free disk space (at least 40 GB), and 16 GB of RAM or more is recommended.
26+
In all cases, make a **backup of all your wallets** just in case - as long as you saved your wallet.dats somewhere, there will always be a a way to recover your funds if something goes wrong. Don't forget to shut down Riecoin Core before making such backup.
5227

53-
Install Guix on your system, on Debian 12 this can be done as root with
28+
### Using the Wallet Migrator
5429

55-
```bash
56-
apt install guix
57-
```
30+
* Via `riecoinwm-qt`: after making a backup of your Wallets or the Riecoin Data Folder, stop any running Riecoin Core instance, then run the Qt version of the Wallet Migrator. Under the File menu, you can Open any Riecoin Wallet (if not already opened), and then click on "Migrate Wallet", again under the File Menu. If this option is disabled, it means that this Wallet is already a Descriptor Wallet and
31+
* Via `riecoinwmd`/`riecoinwm-cli`: after making a backup of your Wallets or the Riecoin Data Folder, stop any running Riecoin Core instance. Then, run the migrator daemon `riecoinwmd`, and then use the `riecoinwm-cli` binary to run the `migratewallet` command for every wallet to upgrade. Example:
5832

59-
Still as root, start the daemon,
6033

6134
```bash
62-
guix-daemon
35+
./riecoinwm-cli -rpcuser=User -rpcpassword=Password -rpcwallet=Pool migratewallet
36+
{
37+
"wallet_name": "Pool",
38+
"backup_path": "/home/user/.riecoin/wallets/Pool/Pool_1713190683.legacy.bak"
39+
}
6340
```
6441

65-
Now, get the Riecoin Core source code.
66-
67-
```bash
68-
git clone https://github.com/RiecoinTeam/Riecoin.git
69-
```
70-
71-
Start the Guix build. The environment variable will set which binaries to build (here, Linux x64, Linux Arm64, and Windows x64, but it is possible to add other architectures or Mac with an SDK).
72-
73-
```bash
74-
export HOSTS="x86_64-linux-gnu aarch64-linux-gnu x86_64-w64-mingw32"
75-
cd Riecoin
76-
./contrib/guix/guix-build
77-
```
42+
### Other Migration Options
7843

79-
It will be very long, do not be surprised if it takes an hour or more, even with a powerful machine. The binaries will be generated in a `guix-build-.../output` folder.
44+
The migration code is taken from Bitcoin 27's, and essentially remains untouched, so it should work well as it is no longer considered as experimental by the Bitcoin Developers unlike at the time Riecoin 23.04 was released (which is why the Wallet Migrator was not provided with this release). But should it still fail nevertheless due to a corrupted wallet or a bug, here are other options to perform the migration.
8045

81-
### Other OSes
46+
* Send all your funds to an exchange, delete your wallets, and proceed to the upgrade as usual. Then, create a new wallet with the new version, get a new address, send your coins back to yourself, and you are done. Riecoin Transactions Fees are negligible, though be sure to check the exchange deposit (if any) and withdrawal fees.
47+
* Alternatively, if you know how to do that, you can try to run both instances of Riecoin Core simultaneously and send directly to your own address without using an exchange.
48+
* Export the old addresses with `dumpprivkey` via the older Riecoin Core that still supports Legacy Wallets, then use 24.04+ to create a new Wallet and import Addresses with `importdescriptors`
49+
* The Base58 Wif Format has been dropped since 22.03 in favor of a straightforward Hex one, so if your `dumpprivkey` still provides WIF Keys, you need to convert them to Hex, and use the `prv` prefix.
50+
* Write your own script that automates the previous point.
8251

83-
Either build using Guix as explained above in a spare physical or virtual machine, or refer to the [Bitcoin's Documentation (build-... files)](https://github.com/bitcoin/bitcoin/tree/master/doc) and adapt the instructions for Riecoin if needed.
52+
If you are running a Riecoin Mining Pool or an Exchange that has Riecoin listed, you can always ask the Riecoin Developers for assistance
8453

8554
## License
8655

87-
Riecoin Core is released under the terms of the MIT license. See [COPYING](COPYING) for more information or see https://opensource.org/licenses/MIT.
56+
The Riecoin Wallet Migrator is released under the terms of the MIT license. See [COPYING](COPYING) for more information or see https://opensource.org/licenses/MIT.

build-aux/m4/bitcoin_find_bdb48.m4

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
dnl Copyright (c) 2013-2015 The Bitcoin Core developers
2+
dnl Distributed under the MIT software license, see the accompanying
3+
dnl file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
AC_DEFUN([BITCOIN_FIND_BDB48],[
6+
AC_ARG_VAR([BDB_CFLAGS], [C compiler flags for BerkeleyDB, bypasses autodetection])
7+
AC_ARG_VAR([BDB_LIBS], [Linker flags for BerkeleyDB, bypasses autodetection])
8+
9+
if test "$use_bdb" = "no"; then
10+
use_bdb=no
11+
elif test "$BDB_CFLAGS" = ""; then
12+
AC_MSG_CHECKING([for Berkeley DB C++ headers])
13+
BDB_CPPFLAGS=
14+
bdbpath=X
15+
bdb48path=X
16+
bdbdirlist=
17+
for _vn in 4.8 48 4 5 5.3 ''; do
18+
for _pfx in b lib ''; do
19+
bdbdirlist="$bdbdirlist ${_pfx}db${_vn}"
20+
done
21+
done
22+
for searchpath in $bdbdirlist ''; do
23+
test -n "${searchpath}" && searchpath="${searchpath}/"
24+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
25+
#include <${searchpath}db_cxx.h>
26+
]],[[
27+
#if !((DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 8) || DB_VERSION_MAJOR > 4)
28+
#error "failed to find bdb 4.8+"
29+
#endif
30+
]])],[
31+
if test "$bdbpath" = "X"; then
32+
bdbpath="${searchpath}"
33+
fi
34+
],[
35+
continue
36+
])
37+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
38+
#include <${searchpath}db_cxx.h>
39+
]],[[
40+
#if !(DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 8)
41+
#error "failed to find bdb 4.8"
42+
#endif
43+
]])],[
44+
bdb48path="${searchpath}"
45+
break
46+
],[])
47+
done
48+
if test "$bdbpath" = "X"; then
49+
use_bdb=no
50+
AC_MSG_RESULT([no])
51+
AC_MSG_WARN([libdb_cxx headers missing])
52+
AC_MSG_WARN(AC_PACKAGE_NAME[ requires this library for BDB (legacy) wallet support])
53+
AC_MSG_WARN([Passing --without-bdb will suppress this warning])
54+
elif test "$bdb48path" = "X"; then
55+
BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdbpath}],db_cxx)
56+
AC_ARG_WITH([incompatible-bdb],[AS_HELP_STRING([--with-incompatible-bdb], [allow using a bdb version other than 4.8])],[
57+
AC_MSG_WARN([Found Berkeley DB other than 4.8])
58+
AC_MSG_WARN([BDB (legacy) wallets opened by this build will not be portable!])
59+
use_bdb=yes
60+
],[
61+
AC_MSG_WARN([Found Berkeley DB other than 4.8])
62+
AC_MSG_WARN([BDB (legacy) wallets opened by this build would not be portable!])
63+
AC_MSG_WARN([If this is intended, pass --with-incompatible-bdb])
64+
AC_MSG_WARN([Passing --without-bdb will suppress this warning])
65+
use_bdb=no
66+
])
67+
else
68+
BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdb48path}],db_cxx)
69+
bdbpath="${bdb48path}"
70+
use_bdb=yes
71+
fi
72+
else
73+
BDB_CPPFLAGS=${BDB_CFLAGS}
74+
fi
75+
AC_SUBST(BDB_CPPFLAGS)
76+
77+
if test "$use_bdb" = "no"; then
78+
use_bdb=no
79+
elif test "$BDB_LIBS" = ""; then
80+
# TODO: Ideally this could find the library version and make sure it matches the headers being used
81+
for searchlib in db_cxx-4.8 db_cxx db4_cxx; do
82+
AC_CHECK_LIB([$searchlib],[main],[
83+
BDB_LIBS="-l${searchlib}"
84+
break
85+
])
86+
done
87+
if test "$BDB_LIBS" = ""; then
88+
AC_MSG_WARN([libdb_cxx headers missing])
89+
AC_MSG_WARN(AC_PACKAGE_NAME[ requires this library for BDB (legacy) wallet support])
90+
AC_MSG_WARN([Passing --without-bdb will suppress this warning])
91+
fi
92+
fi
93+
if test "$use_bdb" != "no"; then
94+
AC_DEFINE([USE_BDB], [1], [Define if BDB support should be compiled in])
95+
use_bdb=yes
96+
fi
97+
])

ci/test/00_setup_env_native_asan.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ else
1818
fi
1919

2020
export CONTAINER_NAME=ci_native_asan
21-
export PACKAGES="systemtap-sdt-dev clang-18 llvm-18 libclang-rt-18-dev python3-zmq qtbase5-dev qttools5-dev-tools libevent-dev libboost-dev libgmp-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev libqrencode-dev libsqlite3-dev ${BPFCC_PACKAGE}"
21+
export PACKAGES="systemtap-sdt-dev clang-18 llvm-18 libclang-rt-18-dev python3-zmq qtbase5-dev qttools5-dev-tools libevent-dev libboost-dev libgmp-dev libdb5.3++-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev libqrencode-dev libsqlite3-dev ${BPFCC_PACKAGE}"
2222
export NO_DEPENDS=1
2323
export GOAL="install"
24-
export BITCOIN_CONFIG="--enable-usdt --enable-zmq --with-gui=qt5 \
24+
export BITCOIN_CONFIG="--enable-usdt --enable-zmq --with-incompatible-bdb --with-gui=qt5 \
2525
CPPFLAGS='-DARENA_DEBUG -DDEBUG_LOCKORDER' \
2626
--with-sanitizers=address,float-divide-by-zero,integer,undefined \
2727
CC='clang-18 -ftrivial-auto-var-init=pattern' CXX='clang++-18 -ftrivial-auto-var-init=pattern'"

ci/test/00_setup_env_native_fuzz_with_msan.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export MSAN_AND_LIBCXX_FLAGS="${MSAN_FLAGS} ${LIBCXX_FLAGS}"
1515

1616
export CONTAINER_NAME="ci_native_fuzz_msan"
1717
export PACKAGES="ninja-build"
18-
export DEP_OPTS="DEBUG=1 NO_QT=1 CC=clang CXX=clang++ CFLAGS='${MSAN_FLAGS}' CXXFLAGS='${MSAN_AND_LIBCXX_FLAGS}'"
18+
export DEP_OPTS="DEBUG=1 NO_BDB=1 NO_QT=1 CC=clang CXX=clang++ CFLAGS='${MSAN_FLAGS}' CXXFLAGS='${MSAN_AND_LIBCXX_FLAGS}'"
1919
export GOAL="install"
2020
export BITCOIN_CONFIG="--enable-fuzz --with-sanitizers=fuzzer,memory --disable-hardening CPPFLAGS='-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE'"
2121
export USE_MEMORY_SANITIZER="true"

ci/test/00_setup_env_native_msan.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export MSAN_AND_LIBCXX_FLAGS="${MSAN_FLAGS} ${LIBCXX_FLAGS}"
1515

1616
export CONTAINER_NAME="ci_native_msan"
1717
export PACKAGES="ninja-build"
18-
export DEP_OPTS="DEBUG=1 NO_QT=1 CC=clang CXX=clang++ CFLAGS='${MSAN_FLAGS}' CXXFLAGS='${MSAN_AND_LIBCXX_FLAGS}'"
18+
export DEP_OPTS="DEBUG=1 NO_BDB=1 NO_QT=1 CC=clang CXX=clang++ CFLAGS='${MSAN_FLAGS}' CXXFLAGS='${MSAN_AND_LIBCXX_FLAGS}'"
1919
export GOAL="install"
2020
export BITCOIN_CONFIG="--with-sanitizers=memory --disable-hardening"
2121
export USE_MEMORY_SANITIZER="true"

ci/test/00_setup_env_native_tidy.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ export LC_ALL=C.UTF-8
1010
export CI_IMAGE_NAME_TAG="docker.io/ubuntu:24.04"
1111
export CONTAINER_NAME=ci_native_tidy
1212
export TIDY_LLVM_V="18"
13-
export PACKAGES="clang-${TIDY_LLVM_V} libclang-${TIDY_LLVM_V}-dev llvm-${TIDY_LLVM_V}-dev libomp-${TIDY_LLVM_V}-dev clang-tidy-${TIDY_LLVM_V} jq bear libevent-dev libboost-dev libgmp-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev systemtap-sdt-dev qtbase5-dev qttools5-dev qttools5-dev-tools libqrencode-dev libsqlite3-dev"
13+
export PACKAGES="clang-${TIDY_LLVM_V} libclang-${TIDY_LLVM_V}-dev llvm-${TIDY_LLVM_V}-dev libomp-${TIDY_LLVM_V}-dev clang-tidy-${TIDY_LLVM_V} jq bear libevent-dev libboost-dev libgmp-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev systemtap-sdt-dev qtbase5-dev qttools5-dev qttools5-dev-tools libqrencode-dev libsqlite3-dev libdb++-dev"
1414
export NO_DEPENDS=1
1515
export RUN_UNIT_TESTS=false
1616
export RUN_FUNCTIONAL_TESTS=false
1717
export RUN_FUZZ_TESTS=false
1818
export RUN_TIDY=true
1919
export GOAL="install"
20-
export BITCOIN_CONFIG="CC=clang-${TIDY_LLVM_V} CXX=clang++-${TIDY_LLVM_V} --disable-hardening CFLAGS='-O0 -g0' CXXFLAGS='-O0 -g0 -I/usr/lib/llvm-${TIDY_LLVM_V}/lib/clang/${TIDY_LLVM_V}/include'"
20+
export BITCOIN_CONFIG="CC=clang-${TIDY_LLVM_V} CXX=clang++-${TIDY_LLVM_V} --with-incompatible-bdb --disable-hardening CFLAGS='-O0 -g0' CXXFLAGS='-O0 -g0 -I/usr/lib/llvm-${TIDY_LLVM_V}/lib/clang/${TIDY_LLVM_V}/include'"
2121
export CCACHE_MAXSIZE=200M

ci/test/00_setup_env_native_valgrind.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ export LC_ALL=C.UTF-8
99

1010
export CI_IMAGE_NAME_TAG="docker.io/debian:bookworm"
1111
export CONTAINER_NAME=ci_native_valgrind
12-
export PACKAGES="valgrind clang llvm libclang-rt-dev python3-zmq libevent-dev libboost-dev libgmp-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev libsqlite3-dev"
12+
export PACKAGES="valgrind clang llvm libclang-rt-dev python3-zmq libevent-dev libboost-dev libgmp-dev libdb5.3++-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev libsqlite3-dev"
1313
export USE_VALGRIND=1
1414
export NO_DEPENDS=1
1515
export TEST_RUNNER_EXTRA="--exclude feature_init,rpc_bind,feature_bind_extra" # Excluded for now, see https://github.com/bitcoin/bitcoin/issues/17765#issuecomment-602068547
1616
export GOAL="install"
1717
# Temporarily pin dwarf 4, until using Valgrind 3.20 or later
18-
export BITCOIN_CONFIG="--enable-zmq --with-gui=no CC=clang CXX=clang++ CFLAGS=-gdwarf-4 CXXFLAGS=-gdwarf-4" # TODO enable GUI
18+
export BITCOIN_CONFIG="--enable-zmq --with-incompatible-bdb --with-gui=no CC=clang CXX=clang++ CFLAGS=-gdwarf-4 CXXFLAGS=-gdwarf-4" # TODO enable GUI

0 commit comments

Comments
 (0)