forked from nbd-wtf/bitcoin_signet
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathimport_wif_to_descriptor.sh
More file actions
executable file
·46 lines (40 loc) · 1.35 KB
/
import_wif_to_descriptor.sh
File metadata and controls
executable file
·46 lines (40 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
set -euo pipefail
WIF_PRIVKEY=$(cat ${BITCOIN_DIR}/PRIVKEY.txt)
# Step 1: Construct input descriptor with WIF
#INPUT_DESC="pk($WIF)"
#BASE_DESC="combo($WIF_PRIVKEY)"
BASE_DESC="multi(1,$WIF_PRIVKEY)"
# Step 2: Get checksum (must preserve private key in input, do NOT use returned descriptor)
CHECKSUM=$(bitcoin-cli getdescriptorinfo "$BASE_DESC" | jq -r .checksum)
# Step 3: Final descriptor with checksum
FINAL_DESC="${BASE_DESC}#${CHECKSUM}"
# Step 4: Build import JSON with rescan
IMPORT_JSON=$(cat <<EOF
[{
"desc": "$FINAL_DESC",
"timestamp": "now",
"label": "bdb-migrated-signet"
}]
EOF
)
# Step 5: Import descriptor into wallet
echo "Importing descriptor for signet multisig(1 of 1)..."
bitcoin-cli -rpcwallet=custom_signet importdescriptors "$IMPORT_JSON"
BASE_DESC="combo($WIF_PRIVKEY)"
# Step 2: Get checksum (must preserve private key in input, do NOT use returned descriptor)
CHECKSUM=$(bitcoin-cli getdescriptorinfo "$BASE_DESC" | jq -r .checksum)
# Step 3: Final descriptor with checksum
FINAL_DESC="${BASE_DESC}#${CHECKSUM}"
# Step 4: Build import JSON with rescan
IMPORT_JSON=$(cat <<EOF
[{
"desc": "$FINAL_DESC",
"timestamp": "now",
"label": "bdb-migrated-signet"
}]
EOF
)
# Step 5: Import descriptor into wallet
echo "Importing descriptor for signet combo()..."
bitcoin-cli -rpcwallet=custom_signet importdescriptors "$IMPORT_JSON"