forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
contrib: add script dump_to_sqlite.sh for direct SQLite3 UTXO dump
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (c) 2024 The Bitcoin Core developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
export LC_ALL=C | ||
set -e | ||
|
||
if [ $# -ne 2 ]; then | ||
echo "Usage: $0 <bitcoin-cli-path> <output-file>" | ||
exit 1 | ||
fi | ||
|
||
BITCOIN_CLI=$1 | ||
OUTPUT_FILE=$2 | ||
UTXO_TO_SQLITE=$(dirname "$0")/utxo_to_sqlite.py | ||
|
||
# create named pipe in unique temporary folder | ||
TEMPPATH=$(mktemp -d) | ||
FIFOPATH=$TEMPPATH/utxos.fifo | ||
mkfifo "$FIFOPATH" | ||
|
||
# start dumping UTXO set to the pipe in background | ||
$BITCOIN_CLI dumptxoutset "$FIFOPATH" latest & | ||
BITCOIN_CLI_PID=$! | ||
|
||
# start UTXO to SQLite conversion tool, reading from pipe | ||
$UTXO_TO_SQLITE "$FIFOPATH" "$OUTPUT_FILE" | ||
|
||
# wait and cleanup | ||
wait $BITCOIN_CLI_PID | ||
rm -r "$TEMPPATH" |