|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +########################### STAGE 1: setup #################################### |
| 4 | + |
| 5 | +# 1. Install dependencies locally and setup regtest environment |
| 6 | +just non_nix_init |
| 7 | +# 2. Check bitcoind is running on regtest |
| 8 | +just cli getblockchaininfo |
| 9 | +# 3. Check bdk-cli wallet was created correctly |
| 10 | +just regtest-bdk balance |
| 11 | +# 4. Check sp-cli wallet was created correctly |
| 12 | +just regtest-sp balance |
| 13 | +# 5. Synchronize bdk-cli wallet |
| 14 | +just regtest-bdk sync |
| 15 | + |
| 16 | +###################### STAGE 2: fund bdk-cli wallet ########################### |
| 17 | + |
| 18 | +# 6. Get a new address from bdk-cli wallet |
| 19 | +REGTEST_ADDRESS=$(just regtest-bdk unused_address | jq -r '.address' | tr -d '\n') |
| 20 | +# 7. Mine a few more blocks to fund the wallet |
| 21 | +just mine 1 $REGTEST_ADDRESS |
| 22 | +# 8. Mine some of them to the internal wallet to confirm the bdk-cli balance |
| 23 | +just mine 101 |
| 24 | +# 9. Synchronize bdk-cli wallet |
| 25 | +just regtest-bdk sync |
| 26 | +# 10. Check balance |
| 27 | +just regtest-bdk balance |
| 28 | + |
| 29 | +################ STAGE 3: create a silent payment output ###################### |
| 30 | + |
| 31 | +# 11. Get a silent payment code from sp-cli2 wallet |
| 32 | +SP_CODE=$(just regtest-sp code | jq -r '.silent_payment_code' | tr -d '\n') |
| 33 | +# 12. Create a transaction spending bdk-cli wallet UTXOs to a the previous silent payment code |
| 34 | +RAW_TX=$(just regtest-bdk create_sp_tx --to-sp $SP_CODE:10000 --fee_rate 5 | jq -r '.raw_tx' | tr -d '\n') |
| 35 | +TXID=$(just regtest-bdk broadcast --tx $RAW_TX | jq -r '.txid' | tr -d '\n') |
| 36 | +# 14. Mine a new block |
| 37 | +just mine 1 |
| 38 | +# 15. Once the new transaction has been mined, synchronize bdk-cli wallet again |
| 39 | +just regtest-bdk sync |
| 40 | + |
| 41 | +# ################## STAGE 4: find a silent payment output ###################### |
| 42 | + |
| 43 | +# 16. Now synchronize sp-cli2 wallet using frigate ephemeral scanning |
| 44 | +FRIGATE_HOST="127.0.0.1:57001" |
| 45 | +START_HEIGHT=1 |
| 46 | +just regtest-sp scan-frigate --url $FRIGATE_HOST --start $START_HEIGHT |
| 47 | +# 17. Check balance on sp-cli2 wallet |
| 48 | +just regtest-sp balance |
| 49 | +# 18. Check balance on bdk-cli wallet |
| 50 | +just regtest-bdk balance |
| 51 | + |
| 52 | +# At this point we will able to see SP outputs paid to out wallet! |
0 commit comments