diff --git a/dex/testing/btc/README.md b/dex/testing/btc/README.md index 24272c5510..2898706524 100644 --- a/dex/testing/btc/README.md +++ b/dex/testing/btc/README.md @@ -1,7 +1,7 @@ # BTC Simnet Test Harness -The harness script will create three connected regnet nodes and wallets, and +The harness script will create two connected regnet nodes with four wallets, and then mine some blocks and send some BTC around. The result is a set of wallets -named **alpha**, **beta**, and **gamma**, each with slightly different +named **alpha**, **beta**, **gamma**, and **delta**, each with slightly different properties. **Beta** is purely a mining node/wallet and has never sent a transaction. Beta @@ -11,15 +11,17 @@ does have some mature coinbase transaction outputs to spend. so has some change outputs that are not coinbase and have varying number of confirmations. -**Gamma** is another wallet on the alpha node. Gamma is encrypted, so requires -unlocking for sensitive operations. Gamma has no coinbase-spending outputs, -but has a number of UTXOs of varying size and confirmation count. -**The gamma wallet password is "abc"**. +**Gamma** is another wallet on the alpha node. Gamma has no coinbase-spending +outputs, but has a number of UTXOs of varying size and confirmation count. + +**Delta** is another wallet on the beta node, similar to gamma. + +**The wallet password is "abc"** for encrypted wallets. ## Dependencies You must have [bitcoind and bitcoin-cli](https://github.com/bitcoin/bitcoin/releases) -in `PATH` to use the harness. bitcoin v26.0.0+ is recommended. +in `PATH` to use the harness. Bitcoin Core v26.0.0+ is recommended. v30+ is fully supported. It also requires tmux. @@ -29,8 +31,8 @@ The `./harness.sh` script will drop you into a tmux window in a directory called `harness-ctl`. Inside of this directory are a number of scripts to allow you to perform RPC calls against each wallet. -`./alpha`, `./beta`, and `./gamma` are just `bitcoin-cli` configured for their -respective wallets. +`./alpha`, `./beta`, `./gamma`, and `./delta` are just `bitcoin-cli` configured +for their respective wallets. Try `./gamma getbalance`, for example. `./reorg` will step through a script that causes the alpha node to undergo a @@ -38,6 +40,19 @@ Try `./gamma getbalance`, for example. `./quit` shuts down the nodes and closes the tmux session. +## Regenerating Descriptor Files + +If you need to regenerate the `desc-*.json` files (e.g., after changing wallet +configuration), use the `gen-descriptors.sh` script: + +```bash +# Start a Bitcoin Core node first, then run: +./gen-descriptors.sh [RPC_PORT] +``` + +This will create new descriptor files and output the corresponding addresses +to update in `harness.sh`. + ## Dev Stuff If things aren't looking right, you may need to look at the node windows to diff --git a/dex/testing/btc/desc-alpha.json b/dex/testing/btc/desc-alpha.json new file mode 100644 index 0000000000..8c79a63025 --- /dev/null +++ b/dex/testing/btc/desc-alpha.json @@ -0,0 +1 @@ +[{"desc":"pkh(tprv8ZgxMBicQKsPd6K7HPaoxQmGnC43xV2qw9U5SsuvaS9A5JKj3yxSCTxjUyhLWMyEiN89msKcjiftHB6Rz8v7fvfLKuU52rCYy9EvYeC7MXV/44h/1h/0h/0/*)#qc049l39","timestamp":"now","active":true,"internal":false,"range":[0,999],"next":0},{"desc":"pkh(tprv8ZgxMBicQKsPd6K7HPaoxQmGnC43xV2qw9U5SsuvaS9A5JKj3yxSCTxjUyhLWMyEiN89msKcjiftHB6Rz8v7fvfLKuU52rCYy9EvYeC7MXV/44h/1h/0h/1/*)#3v25c2pa","timestamp":"now","active":true,"internal":true,"range":[0,999],"next":0},{"desc":"sh(wpkh(tprv8ZgxMBicQKsPd6K7HPaoxQmGnC43xV2qw9U5SsuvaS9A5JKj3yxSCTxjUyhLWMyEiN89msKcjiftHB6Rz8v7fvfLKuU52rCYy9EvYeC7MXV/49h/1h/0h/0/*))#edynh5ze","timestamp":"now","active":true,"internal":false,"range":[0,999],"next":0},{"desc":"sh(wpkh(tprv8ZgxMBicQKsPd6K7HPaoxQmGnC43xV2qw9U5SsuvaS9A5JKj3yxSCTxjUyhLWMyEiN89msKcjiftHB6Rz8v7fvfLKuU52rCYy9EvYeC7MXV/49h/1h/0h/1/*))#lwvkvefd","timestamp":"now","active":true,"internal":true,"range":[0,999],"next":0},{"desc":"tr(tprv8ZgxMBicQKsPd6K7HPaoxQmGnC43xV2qw9U5SsuvaS9A5JKj3yxSCTxjUyhLWMyEiN89msKcjiftHB6Rz8v7fvfLKuU52rCYy9EvYeC7MXV/86h/1h/0h/0/*)#f8rt6k6w","timestamp":"now","active":true,"internal":false,"range":[0,999],"next":0},{"desc":"tr(tprv8ZgxMBicQKsPd6K7HPaoxQmGnC43xV2qw9U5SsuvaS9A5JKj3yxSCTxjUyhLWMyEiN89msKcjiftHB6Rz8v7fvfLKuU52rCYy9EvYeC7MXV/86h/1h/0h/1/*)#cnx28r2k","timestamp":"now","active":true,"internal":true,"range":[0,999],"next":0},{"desc":"wpkh(tprv8ZgxMBicQKsPd6K7HPaoxQmGnC43xV2qw9U5SsuvaS9A5JKj3yxSCTxjUyhLWMyEiN89msKcjiftHB6Rz8v7fvfLKuU52rCYy9EvYeC7MXV/84h/1h/0h/0/*)#5e2fkn6t","timestamp":"now","active":true,"internal":false,"range":[0,999],"next":0},{"desc":"wpkh(tprv8ZgxMBicQKsPd6K7HPaoxQmGnC43xV2qw9U5SsuvaS9A5JKj3yxSCTxjUyhLWMyEiN89msKcjiftHB6Rz8v7fvfLKuU52rCYy9EvYeC7MXV/84h/1h/0h/1/*)#9d0gtx2n","timestamp":"now","active":true,"internal":true,"range":[0,999],"next":0}] diff --git a/dex/testing/btc/desc-beta.json b/dex/testing/btc/desc-beta.json index a2465861ab..665512d029 100644 --- a/dex/testing/btc/desc-beta.json +++ b/dex/testing/btc/desc-beta.json @@ -1 +1 @@ -[{"desc":"pkh(tprv8ZgxMBicQKsPeEJskbB5M2i3VL5wHcbZWiHV9bqsaWWFbYGVSzu6GYpkHtXrVD9QAe773xwYcjfb1jZMcShNofV18USL6h9e6rqSLdekxkp/44'/1'/0'/0/*)#xep6cuqj","timestamp":1655751807,"active":true,"internal":false,"range":[0,999],"next":1},{"desc":"sh(wpkh(tprv8ZgxMBicQKsPeEJskbB5M2i3VL5wHcbZWiHV9bqsaWWFbYGVSzu6GYpkHtXrVD9QAe773xwYcjfb1jZMcShNofV18USL6h9e6rqSLdekxkp/49'/1'/0'/0/*))#amcg4nny","timestamp":1655751807,"active":true,"internal":false,"range":[0,999],"next":0},{"desc":"wpkh(tprv8ZgxMBicQKsPeEJskbB5M2i3VL5wHcbZWiHV9bqsaWWFbYGVSzu6GYpkHtXrVD9QAe773xwYcjfb1jZMcShNofV18USL6h9e6rqSLdekxkp/84'/1'/0'/0/*)#y3dnm4x9","timestamp":1655751807,"active":true,"internal":false,"range":[0,999],"next":1},{"desc":"tr(tprv8ZgxMBicQKsPeEJskbB5M2i3VL5wHcbZWiHV9bqsaWWFbYGVSzu6GYpkHtXrVD9QAe773xwYcjfb1jZMcShNofV18USL6h9e6rqSLdekxkp/86'/1'/0'/0/*)#dx02vsaf","timestamp":1655751807,"active":true,"internal":false,"range":[0,999],"next":0},{"desc":"pkh(tprv8ZgxMBicQKsPeEJskbB5M2i3VL5wHcbZWiHV9bqsaWWFbYGVSzu6GYpkHtXrVD9QAe773xwYcjfb1jZMcShNofV18USL6h9e6rqSLdekxkp/44'/1'/0'/1/*)#hdym9fs2","timestamp":1655751807,"active":true,"internal":true,"range":[0,999],"next":0},{"desc":"sh(wpkh(tprv8ZgxMBicQKsPeEJskbB5M2i3VL5wHcbZWiHV9bqsaWWFbYGVSzu6GYpkHtXrVD9QAe773xwYcjfb1jZMcShNofV18USL6h9e6rqSLdekxkp/49'/1'/0'/1/*))#mcsdw7cs","timestamp":1655751807,"active":true,"internal":true,"range":[0,999],"next":0},{"desc":"wpkh(tprv8ZgxMBicQKsPeEJskbB5M2i3VL5wHcbZWiHV9bqsaWWFbYGVSzu6GYpkHtXrVD9QAe773xwYcjfb1jZMcShNofV18USL6h9e6rqSLdekxkp/84'/1'/0'/1/*)#49gjxqka","timestamp":1655751807,"active":true,"internal":true,"range":[0,999],"next":0},{"desc":"tr(tprv8ZgxMBicQKsPeEJskbB5M2i3VL5wHcbZWiHV9bqsaWWFbYGVSzu6GYpkHtXrVD9QAe773xwYcjfb1jZMcShNofV18USL6h9e6rqSLdekxkp/86'/1'/0'/1/*)#uj2t39d3","timestamp":1655751807,"active":true,"internal":true,"range":[0,999],"next":0}] +[{"desc":"pkh(tprv8ZgxMBicQKsPeyeXQGRzVYafa4YWL47Rc2fBzCCB9CQoLh4iXLV5jJLX6brunv2Qo4fgP61wqtQbAU6iWydfhqeFudM8d511SHF197Mh6Wi/44h/1h/0h/0/*)#v08w9npt","timestamp":"now","active":true,"internal":false,"range":[0,999],"next":0},{"desc":"pkh(tprv8ZgxMBicQKsPeyeXQGRzVYafa4YWL47Rc2fBzCCB9CQoLh4iXLV5jJLX6brunv2Qo4fgP61wqtQbAU6iWydfhqeFudM8d511SHF197Mh6Wi/44h/1h/0h/1/*)#amz0cx3n","timestamp":"now","active":true,"internal":true,"range":[0,999],"next":0},{"desc":"sh(wpkh(tprv8ZgxMBicQKsPeyeXQGRzVYafa4YWL47Rc2fBzCCB9CQoLh4iXLV5jJLX6brunv2Qo4fgP61wqtQbAU6iWydfhqeFudM8d511SHF197Mh6Wi/49h/1h/0h/0/*))#zgm8ymm0","timestamp":"now","active":true,"internal":false,"range":[0,999],"next":0},{"desc":"sh(wpkh(tprv8ZgxMBicQKsPeyeXQGRzVYafa4YWL47Rc2fBzCCB9CQoLh4iXLV5jJLX6brunv2Qo4fgP61wqtQbAU6iWydfhqeFudM8d511SHF197Mh6Wi/49h/1h/0h/1/*))#ytnzlksm","timestamp":"now","active":true,"internal":true,"range":[0,999],"next":0},{"desc":"tr(tprv8ZgxMBicQKsPeyeXQGRzVYafa4YWL47Rc2fBzCCB9CQoLh4iXLV5jJLX6brunv2Qo4fgP61wqtQbAU6iWydfhqeFudM8d511SHF197Mh6Wi/86h/1h/0h/0/*)#fe6yrppt","timestamp":"now","active":true,"internal":false,"range":[0,999],"next":0},{"desc":"tr(tprv8ZgxMBicQKsPeyeXQGRzVYafa4YWL47Rc2fBzCCB9CQoLh4iXLV5jJLX6brunv2Qo4fgP61wqtQbAU6iWydfhqeFudM8d511SHF197Mh6Wi/86h/1h/0h/1/*)#cdl9753n","timestamp":"now","active":true,"internal":true,"range":[0,999],"next":0},{"desc":"wpkh(tprv8ZgxMBicQKsPeyeXQGRzVYafa4YWL47Rc2fBzCCB9CQoLh4iXLV5jJLX6brunv2Qo4fgP61wqtQbAU6iWydfhqeFudM8d511SHF197Mh6Wi/84h/1h/0h/0/*)#n23jpl8l","timestamp":"now","active":true,"internal":false,"range":[0,999],"next":0},{"desc":"wpkh(tprv8ZgxMBicQKsPeyeXQGRzVYafa4YWL47Rc2fBzCCB9CQoLh4iXLV5jJLX6brunv2Qo4fgP61wqtQbAU6iWydfhqeFudM8d511SHF197Mh6Wi/84h/1h/0h/1/*)#z75nu2h8","timestamp":"now","active":true,"internal":true,"range":[0,999],"next":0}] diff --git a/dex/testing/btc/desc-delta.json b/dex/testing/btc/desc-delta.json new file mode 100644 index 0000000000..8d332bbdb7 --- /dev/null +++ b/dex/testing/btc/desc-delta.json @@ -0,0 +1 @@ +[{"desc":"pkh(tprv8ZgxMBicQKsPdhobdXkAnzvpwgaiM4jzWvV22Ne35bK1hGJ9yR9uwgmYWEg31KTADZwrHbuDTb3bKDkQ9DQuAhvNnYYLL4HqBrSp1M3eQWt/44h/1h/0h/0/*)#y0c0vkn6","timestamp":"now","active":true,"internal":false,"range":[0,999],"next":0},{"desc":"pkh(tprv8ZgxMBicQKsPdhobdXkAnzvpwgaiM4jzWvV22Ne35bK1hGJ9yR9uwgmYWEg31KTADZwrHbuDTb3bKDkQ9DQuAhvNnYYLL4HqBrSp1M3eQWt/44h/1h/0h/1/*)#4maw3rrz","timestamp":"now","active":true,"internal":true,"range":[0,999],"next":0},{"desc":"sh(wpkh(tprv8ZgxMBicQKsPdhobdXkAnzvpwgaiM4jzWvV22Ne35bK1hGJ9yR9uwgmYWEg31KTADZwrHbuDTb3bKDkQ9DQuAhvNnYYLL4HqBrSp1M3eQWt/49h/1h/0h/0/*))#r4ec7vhq","timestamp":"now","active":true,"internal":false,"range":[0,999],"next":0},{"desc":"sh(wpkh(tprv8ZgxMBicQKsPdhobdXkAnzvpwgaiM4jzWvV22Ne35bK1hGJ9yR9uwgmYWEg31KTADZwrHbuDTb3bKDkQ9DQuAhvNnYYLL4HqBrSp1M3eQWt/49h/1h/0h/1/*))#9k3a9pu5","timestamp":"now","active":true,"internal":true,"range":[0,999],"next":0},{"desc":"tr(tprv8ZgxMBicQKsPdhobdXkAnzvpwgaiM4jzWvV22Ne35bK1hGJ9yR9uwgmYWEg31KTADZwrHbuDTb3bKDkQ9DQuAhvNnYYLL4HqBrSp1M3eQWt/86h/1h/0h/0/*)#5l3xshvg","timestamp":"now","active":true,"internal":false,"range":[0,999],"next":0},{"desc":"tr(tprv8ZgxMBicQKsPdhobdXkAnzvpwgaiM4jzWvV22Ne35bK1hGJ9yR9uwgmYWEg31KTADZwrHbuDTb3bKDkQ9DQuAhvNnYYLL4HqBrSp1M3eQWt/86h/1h/0h/1/*)#9t58dzus","timestamp":"now","active":true,"internal":true,"range":[0,999],"next":0},{"desc":"wpkh(tprv8ZgxMBicQKsPdhobdXkAnzvpwgaiM4jzWvV22Ne35bK1hGJ9yR9uwgmYWEg31KTADZwrHbuDTb3bKDkQ9DQuAhvNnYYLL4HqBrSp1M3eQWt/84h/1h/0h/0/*)#pj6g5485","timestamp":"now","active":true,"internal":false,"range":[0,999],"next":0},{"desc":"wpkh(tprv8ZgxMBicQKsPdhobdXkAnzvpwgaiM4jzWvV22Ne35bK1hGJ9yR9uwgmYWEg31KTADZwrHbuDTb3bKDkQ9DQuAhvNnYYLL4HqBrSp1M3eQWt/84h/1h/0h/1/*)#sxlffqhv","timestamp":"now","active":true,"internal":true,"range":[0,999],"next":0}] diff --git a/dex/testing/btc/desc-gamma.json b/dex/testing/btc/desc-gamma.json index c3646e33d8..80ba70afb2 100644 --- a/dex/testing/btc/desc-gamma.json +++ b/dex/testing/btc/desc-gamma.json @@ -1 +1 @@ -[{"desc":"pkh(tprv8ZgxMBicQKsPf7ZAtR3ggoFn1RhD7i5GupkFVfsKCSCBEgb2scmPUmFMf2dMx5djtHDit3aWTAPQGnkR9QNx2uiB8kMSVgjDoD1p7ynHtyz/44'/1'/0'/0/*)#wg4x3eld","timestamp":1655755384,"active":true,"internal":false,"range":[0,999],"next":0},{"desc":"sh(wpkh(tprv8ZgxMBicQKsPf7ZAtR3ggoFn1RhD7i5GupkFVfsKCSCBEgb2scmPUmFMf2dMx5djtHDit3aWTAPQGnkR9QNx2uiB8kMSVgjDoD1p7ynHtyz/49'/1'/0'/0/*))#8r2f8dxp","timestamp":1655755384,"active":true,"internal":false,"range":[0,999],"next":0},{"desc":"wpkh(tprv8ZgxMBicQKsPf7ZAtR3ggoFn1RhD7i5GupkFVfsKCSCBEgb2scmPUmFMf2dMx5djtHDit3aWTAPQGnkR9QNx2uiB8kMSVgjDoD1p7ynHtyz/84'/1'/0'/0/*)#2mqfus42","timestamp":1655755384,"active":true,"internal":false,"range":[0,999],"next":0},{"desc":"tr(tprv8ZgxMBicQKsPf7ZAtR3ggoFn1RhD7i5GupkFVfsKCSCBEgb2scmPUmFMf2dMx5djtHDit3aWTAPQGnkR9QNx2uiB8kMSVgjDoD1p7ynHtyz/86'/1'/0'/0/*)#ege8qf0x","timestamp":1655755384,"active":true,"internal":false,"range":[0,999],"next":0},{"desc":"pkh(tprv8ZgxMBicQKsPf7ZAtR3ggoFn1RhD7i5GupkFVfsKCSCBEgb2scmPUmFMf2dMx5djtHDit3aWTAPQGnkR9QNx2uiB8kMSVgjDoD1p7ynHtyz/44'/1'/0'/1/*)#lus8vv04","timestamp":1655755384,"active":true,"internal":true,"range":[0,999],"next":0},{"desc":"sh(wpkh(tprv8ZgxMBicQKsPf7ZAtR3ggoFn1RhD7i5GupkFVfsKCSCBEgb2scmPUmFMf2dMx5djtHDit3aWTAPQGnkR9QNx2uiB8kMSVgjDoD1p7ynHtyz/49'/1'/0'/1/*))#pqzvuqd4","timestamp":1655755385,"active":true,"internal":true,"range":[0,999],"next":0},{"desc":"wpkh(tprv8ZgxMBicQKsPf7ZAtR3ggoFn1RhD7i5GupkFVfsKCSCBEgb2scmPUmFMf2dMx5djtHDit3aWTAPQGnkR9QNx2uiB8kMSVgjDoD1p7ynHtyz/84'/1'/0'/1/*)#m09gp99j","timestamp":1655755385,"active":true,"internal":true,"range":[0,999],"next":0},{"desc":"tr(tprv8ZgxMBicQKsPf7ZAtR3ggoFn1RhD7i5GupkFVfsKCSCBEgb2scmPUmFMf2dMx5djtHDit3aWTAPQGnkR9QNx2uiB8kMSVgjDoD1p7ynHtyz/86'/1'/0'/1/*)#guuxaul7","timestamp":1655755385,"active":true,"internal":true,"range":[0,999],"next":0}] +[{"desc":"pkh(tprv8ZgxMBicQKsPdLVb1ZPPcJp5LpsPaC9opAiqLoCFmqoiHN2YiyJUTfAAro8mfpeieCWRb1hVP4SbqejtNgnj5MqyJpPB3qJ47h7bZEtkZoK/44h/1h/0h/0/*)#aa0p74f6","timestamp":"now","active":true,"internal":false,"range":[0,999],"next":0},{"desc":"pkh(tprv8ZgxMBicQKsPdLVb1ZPPcJp5LpsPaC9opAiqLoCFmqoiHN2YiyJUTfAAro8mfpeieCWRb1hVP4SbqejtNgnj5MqyJpPB3qJ47h7bZEtkZoK/44h/1h/0h/1/*)#vf2qrqez","timestamp":"now","active":true,"internal":true,"range":[0,999],"next":0},{"desc":"sh(wpkh(tprv8ZgxMBicQKsPdLVb1ZPPcJp5LpsPaC9opAiqLoCFmqoiHN2YiyJUTfAAro8mfpeieCWRb1hVP4SbqejtNgnj5MqyJpPB3qJ47h7bZEtkZoK/49h/1h/0h/0/*))#tvht38gv","timestamp":"now","active":true,"internal":false,"range":[0,999],"next":0},{"desc":"sh(wpkh(tprv8ZgxMBicQKsPdLVb1ZPPcJp5LpsPaC9opAiqLoCFmqoiHN2YiyJUTfAAro8mfpeieCWRb1hVP4SbqejtNgnj5MqyJpPB3qJ47h7bZEtkZoK/49h/1h/0h/1/*))#d0lw22rc","timestamp":"now","active":true,"internal":true,"range":[0,999],"next":0},{"desc":"tr(tprv8ZgxMBicQKsPdLVb1ZPPcJp5LpsPaC9opAiqLoCFmqoiHN2YiyJUTfAAro8mfpeieCWRb1hVP4SbqejtNgnj5MqyJpPB3qJ47h7bZEtkZoK/86h/1h/0h/0/*)#x5hnk8ty","timestamp":"now","active":true,"internal":false,"range":[0,999],"next":0},{"desc":"tr(tprv8ZgxMBicQKsPdLVb1ZPPcJp5LpsPaC9opAiqLoCFmqoiHN2YiyJUTfAAro8mfpeieCWRb1hVP4SbqejtNgnj5MqyJpPB3qJ47h7bZEtkZoK/86h/1h/0h/1/*)#hqjjtjmu","timestamp":"now","active":true,"internal":true,"range":[0,999],"next":0},{"desc":"wpkh(tprv8ZgxMBicQKsPdLVb1ZPPcJp5LpsPaC9opAiqLoCFmqoiHN2YiyJUTfAAro8mfpeieCWRb1hVP4SbqejtNgnj5MqyJpPB3qJ47h7bZEtkZoK/84h/1h/0h/0/*)#w5pp088a","timestamp":"now","active":true,"internal":false,"range":[0,999],"next":0},{"desc":"wpkh(tprv8ZgxMBicQKsPdLVb1ZPPcJp5LpsPaC9opAiqLoCFmqoiHN2YiyJUTfAAro8mfpeieCWRb1hVP4SbqejtNgnj5MqyJpPB3qJ47h7bZEtkZoK/84h/1h/0h/1/*)#lqyqjjh9","timestamp":"now","active":true,"internal":true,"range":[0,999],"next":0}] diff --git a/dex/testing/btc/gen-descriptors.sh b/dex/testing/btc/gen-descriptors.sh new file mode 100755 index 0000000000..ecabf55b79 --- /dev/null +++ b/dex/testing/btc/gen-descriptors.sh @@ -0,0 +1,121 @@ +#!/usr/bin/env bash +# Generate descriptor JSON files for BTC testing harness using Bitcoin Core RPC. +# This script creates desc-{alpha,beta,gamma,delta}.json with correct checksums. +# +# Prerequisites: +# - Bitcoin Core running on regtest (run harness.sh first, or start manually) +# - bitcoin-cli available in PATH +# - python3 available in PATH +# +# Usage: ./gen-descriptors.sh [RPC_PORT] +# RPC_PORT defaults to 20556 (alpha node) + +set -e + +RPC_PORT="${1:-20556}" +RPC_USER="user" +RPC_PASS="pass" + +CLI="bitcoin-cli -regtest=1 -rpcport=${RPC_PORT} -rpcuser=${RPC_USER} -rpcpassword=${RPC_PASS}" + +echo "=== BTC Descriptor Generator ===" +echo "Using RPC port: ${RPC_PORT}" +echo "" + +# Check if Bitcoin Core is running +if ! ${CLI} getblockchaininfo &>/dev/null; then + echo "ERROR: Bitcoin Core not running on port ${RPC_PORT}" + echo "Please start the harness first or run bitcoind manually:" + echo " bitcoind -regtest -rpcport=${RPC_PORT} -rpcuser=${RPC_USER} -rpcpassword=${RPC_PASS}" + exit 1 +fi + +echo "Bitcoin Core is running. Generating descriptors..." +echo "" + +# Function to generate descriptor file for a wallet +generate_wallet_descriptors() { + local wallet_name="$1" + local output_file="$2" + local temp_wallet="_gen_${wallet_name}_$$" + + echo "Generating descriptors for ${wallet_name}..." + + # Create temporary descriptor wallet + ${CLI} createwallet "${temp_wallet}" false false "" false true >/dev/null 2>&1 || { + # Wallet might already exist, try to load it + ${CLI} loadwallet "${temp_wallet}" >/dev/null 2>&1 || true + } + + # Export descriptors with private keys + local descriptors=$(${CLI} -rpcwallet="${temp_wallet}" listdescriptors true) + + # Get the first bech32 address (wpkh - BIP84) + local address=$(${CLI} -rpcwallet="${temp_wallet}" getnewaddress "" "bech32") + + # Convert to importdescriptors format + echo "${descriptors}" | python3 -c " +import json, sys +data = json.load(sys.stdin) +result = [] +for d in data['descriptors']: + result.append({ + 'desc': d['desc'], + 'timestamp': 'now', + 'active': d['active'], + 'internal': d['internal'], + 'range': d['range'], + 'next': d.get('next', 0) + }) +print(json.dumps(result, separators=(',',':'))) +" > "${output_file}" + + echo " -> ${output_file}" + echo " -> Address: ${address}" + + # Unload and delete temporary wallet + ${CLI} unloadwallet "${temp_wallet}" >/dev/null 2>&1 || true + + # Return address via global variable (bash limitation) + GENERATED_ADDRESS="${address}" +} + +# Generate descriptors for all wallets (macOS bash 3.x compatible) +generate_wallet_descriptors "alpha" "desc-alpha.json" +ALPHA_ADDR="${GENERATED_ADDRESS}" + +generate_wallet_descriptors "beta" "desc-beta.json" +BETA_ADDR="${GENERATED_ADDRESS}" + +generate_wallet_descriptors "gamma" "desc-gamma.json" +GAMMA_ADDR="${GENERATED_ADDRESS}" + +generate_wallet_descriptors "delta" "desc-delta.json" +DELTA_ADDR="${GENERATED_ADDRESS}" + +echo "" +echo "==========================================" +echo "GENERATED FILES:" +echo "==========================================" +ls -la desc-*.json +echo "" + +echo "==========================================" +echo "UPDATE harness.sh WITH THESE VALUES:" +echo "==========================================" +echo "" +echo "export ALPHA_MINING_ADDR=\"${ALPHA_ADDR}\"" +echo "export BETA_MINING_ADDR=\"${BETA_ADDR}\"" +echo "export GAMMA_ADDRESS=\"${GAMMA_ADDR}\"" +echo "export DELTA_ADDRESS=\"${DELTA_ADDR}\"" +echo "" + +echo "==========================================" +echo "IMPORTANT NOTES:" +echo "==========================================" +echo "1. Commit the generated desc-*.json files to the repository" +echo "2. Update harness.sh with the addresses above" +echo "3. Remove any existing harnesschain.tar.gz" +echo "4. Bump HARNESS_VER in harness.sh" +echo "" +echo "Done!" diff --git a/dex/testing/btc/harness.sh b/dex/testing/btc/harness.sh index 757acb5f8d..bbc4c18b47 100755 --- a/dex/testing/btc/harness.sh +++ b/dex/testing/btc/harness.sh @@ -9,28 +9,26 @@ export BETA_LISTEN_PORT="20576" export ALPHA_RPC_PORT="20556" export BETA_RPC_PORT="20557" export WALLET_PASSWORD="abc" -# For a descriptor wallet (no seed), a [wallet_name]-desc.json file is used with +# For a descriptor wallet, a [wallet_name]-desc.json file is used with # importdescriptors to set the wallet keys. -export ALPHA_WALLET_SEED="cMndqchcXSCUQDDZQSKU2cUHbPb5UfFL9afspxsBELeE6qx6ac9n" -export ALPHA_MINING_ADDR="bcrt1qy7agjj62epx0ydnqskgwlcfwu52xjtpj36hr0d" -export BETA_MINING_ADDR="bcrt1q8hzxze4zrjtpm27lrlanc20uhtswteye8ad7gx" +# Note: Legacy wallet seeds removed for Bitcoin Core v30+ compatibility. +# Use gen-descriptors.sh to regenerate descriptor files if needed. +export ALPHA_MINING_ADDR="bcrt1qly8tvjf0ss0l596k296uanmqe9h2u38cjrju0n" +export BETA_MINING_ADDR="bcrt1qcf5c4rtdlkmavg7spmh0h23k5egyqdqe9fg2d2" # Gamma is a named wallet in the alpha wallet directory. -export GAMMA_ADDRESS="bcrt1qt2xf2s5dkm4t34zm69w9my2dhwmnskwv4st3ly" +export GAMMA_ADDRESS="bcrt1q2zv5qg4j2khhmz2v0hqxduyw547a39w40jvg4h" # Delta is a named wallet in the beta wallet directory. -export DELTA_WALLET_SEED="cURsyTZ8icuTHwWxSfTC2Geu2F6dMRtnzt1gvSaxHdc9Zf6eviJN" -export DELTA_ADDRESS="bcrt1q4clywna5re22qh9mexqty8u8mqvhjh8cwhp5ms" +export DELTA_ADDRESS="bcrt1qp04ul2s506fjcq5p2wf0lkq5qln85clryxks2l" export EXTRA_ARGS="--blockfilterindex --peerblockfilters --rpcbind=0.0.0.0 --rpcallowip=0.0.0.0/0" export CREATE_DEFAULT_WALLET="1" -export VERSION_26_TEMP_DEPRICATED_DBD="1" - # The new-wallet script creates a new wallet with keys (not blank), and no # passphrase. $1 is the node to create the wallet on, $2 is the wallet # passphrase, and $3 (optional) is true/false for a descriptor wallet. # For reference, possible arguments to createwallet are: # "wallet_name" ( disable_private_keys blank(boolean) "passphrase" avoid_reuse descriptors load_on_startup external_signer ) -export NEW_WALLET_CMD="./\$1 -named createwallet wallet_name=\$2 descriptors=\${3:-false} load_on_startup=true" +export NEW_WALLET_CMD="./\$1 -named createwallet wallet_name=\$2 descriptors=\${3:-true} load_on_startup=true" # Run the harness -export HARNESS_VER="1" # for outdated chain archive detection +export HARNESS_VER="3" # descriptor wallets with correct checksums ./base-harness.sh