Skip to content

Commit fb1230e

Browse files
committed
chore: README
1 parent 3826b1e commit fb1230e

File tree

1 file changed

+69
-9
lines changed

1 file changed

+69
-9
lines changed

signet-ts-client-scripts/README.md

Lines changed: 69 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,30 @@ Test client for the Signet pallet on Substrate/Polkadot. Validates signature gen
88
- Running Substrate node with Signet pallet deployed (port 8000)
99
- Access to the Signet signature server
1010
- For ERC20 vault tests: Funded Ethereum Sepolia account with ETH and USDC
11+
- For Bitcoin vault tests: Docker for running Bitcoin regtest
1112

1213
## Setup
1314

14-
### 1. Start the Signature Server
15+
### 1. Start Bitcoin Regtest (for Bitcoin vault tests)
16+
```bash
17+
# Clone the Bitcoin regtest repository
18+
git clone https://github.com/Pessina/bitcoin-regtest.git
19+
cd bitcoin-regtest
20+
21+
# Start Bitcoin Core in regtest mode
22+
yarn docker:dev
23+
```
24+
25+
The Bitcoin regtest node will be available at `http://localhost:18443`.
26+
27+
### 2. Start the Signature Server
1528

1629
Clone and run the signature server that responds to Substrate signature requests. Add .env to the root of the repository:
1730

1831
```bash
19-
# Clone the server repository
20-
git clone https://github.com/sig-net/solana-signet-program
21-
cd chain-signatures-solana/clients/response-server
32+
# Clone the server repository (substrate-new branch)
33+
git clone -b substrate-new https://github.com/sig-net/solana-signet-program.git
34+
cd solana-signet-program/clients/response-server
2235

2336
# Install dependencies
2437
yarn install
@@ -35,6 +48,9 @@ PRIVATE_KEY_TESTNET=0x... # Your private key for signing
3548
# Ethereum Configuration (for vault monitoring)
3649
SEPOLIA_RPC_URL=https://sepolia.infura.io/v3/your_infura_key_here
3750
51+
# Bitcoin Configuration (for Bitcoin vault monitoring)
52+
BITCOIN_NETWORK=regtest
53+
3854
# Dummy solana key
3955
SOLANA_PRIVATE_KEY='[16,151,155,240,122,151,187,95,145,26,179,205,196,113,3,62,17,105,18,240,197,176,45,90,176,108,30,106,182,43,7,104,80,202,59,51,239,219,236,17,39,204,155,35,175,195,17,172,201,196,134,125,25,214,148,76,102,47,123,37,203,86,159,147]'
4056
EOF
@@ -47,14 +63,15 @@ The server will:
4763
- Connect to your Substrate node
4864
- Automatically respond to signature requests
4965
- Monitor Ethereum transactions and report results back to Substrate
66+
- Monitor Bitcoin transactions on regtest and report results back to Substrate
5067

51-
### 2. Install Test Client Dependencies
68+
### 3. Install Test Client Dependencies
5269

5370
```bash
5471
yarn install
5572
```
5673

57-
### 3. Ensure Substrate Node is Running
74+
### 4. Ensure Substrate Node is Running
5875

5976
The tests expect a Substrate node with the Signet pallet at `ws://localhost:8000`. If using Chopsticks:
6077

@@ -64,7 +81,7 @@ npx @acala-network/chopsticks@latest --config=hydradx \
6481
--db=:memory:
6582
```
6683

67-
### 4. Fund Ethereum Account for Vault Tests
84+
### 5. Fund Ethereum Account for Vault Tests
6885

6986
The ERC20 vault test requires a funded account on Sepolia. The test derives an Ethereum address from your Substrate account and expects it to have:
7087

@@ -82,6 +99,7 @@ yarn test
8299
# Run specific test suite
83100
yarn test signet.test.ts
84101
yarn test erc20vault.test.ts
102+
yarn test btc-vault.test.ts
85103

86104
# Run with watch mode
87105
yarn test:watch
@@ -108,6 +126,22 @@ yarn test:watch
108126
- Claim deposited tokens in Substrate vault
109127
- **Multi-token Support**: Vault supports any ERC20 token (decimal-agnostic)
110128

129+
### Bitcoin Vault Integration (`btc-vault.test.ts`)
130+
- **Vault Initialization**: Initialize vault with MPC signer address hash
131+
- **UTXO Management**: Automatically discover and select UTXOs for spending
132+
- **Deposit Flow**:
133+
- Fund Bitcoin address derived from Substrate account
134+
- Build PSBT (Partially Signed Bitcoin Transaction) with vault output
135+
- Request per-input MPC signatures for each PSBT input
136+
- Finalize and broadcast signed transaction to regtest
137+
- Wait for confirmation
138+
- **Result Monitoring**: MPC server observes transaction confirmation on Bitcoin
139+
- **Claim Flow**:
140+
- Receive transaction output from MPC
141+
- Verify MPC signature on result
142+
- Claim deposited sats in Substrate vault
143+
- **Per-Input Signing**: Each UTXO input receives an individual signature with unique request ID
144+
111145
## Expected Output
112146

113147
### Basic Signature Test
@@ -168,6 +202,28 @@ Tests: 1 passed, 1 total
168202
Time: 48.056 s
169203
```
170204

205+
### Bitcoin Vault Test
206+
```
207+
PASS ./btc-vault-perinput.test.ts (131.227 s)
208+
BTC Vault Integration
209+
✓ should complete full deposit and claim flow (125678 ms)
210+
🔑 Derived Bitcoin Address: bcrt1qmr8q7udefh6e3mld7xpahh7g652pq3zurswrxz
211+
💰 Funding bcrt1qmr8q7udefh6e3mld7xpahh7g652pq3zurswrxz with 1 BTC...
212+
📦 Found 32 UTXO(s)
213+
📊 Transaction breakdown:
214+
Inputs: 1
215+
To vault: 36879590 sats
216+
Fee: 138 sats
217+
✅ Deposit BTC included in block
218+
⏳ Waiting for MPC signature(s)...
219+
✅ Received all 1 signature(s) from MPC
220+
📡 Broadcasting transaction to regtest...
221+
✅ Transaction confirmed (1 confirmations)
222+
✅ Balance increased by: 36879590 sats
223+
Test Suites: 1 passed, 1 total
224+
Tests: 1 passed, 1 total
225+
```
226+
171227
## Configuration
172228

173229
The root public key used for derivation is hardcoded in the tests. Ensure the server's `PRIVATE_KEY_TESTNET` corresponds to:
@@ -181,8 +237,12 @@ const ROOT_PUBLIC_KEY = "0x044eef776e4f257d68983e45b340c2e9546c5df95447900b6aadf
181237
- **Timeout errors**: Ensure the signature server is running and connected to the same Substrate node
182238
- **Address mismatch**: Verify the server's private key matches the client's expected public key
183239
- **Transaction errors**: Check that the Signet pallet is initialized (tests handle this automatically)
184-
- **Vault test failures**:
240+
- **ERC20 vault test failures**:
185241
- Ensure your derived Ethereum address is funded with ETH and USDC on Sepolia
186-
- Verify the MPC server has Ethereum monitoring enabled with `SEPOLIA_RPC` configured
242+
- Verify the MPC server has Ethereum monitoring enabled with `SEPOLIA_RPC_URL` configured
187243
- Check that the vault's MPC address matches the server's signing key
244+
- **Bitcoin vault test failures**:
245+
- Ensure Bitcoin regtest is running at `http://localhost:18443`
246+
- Verify the MPC server has `BITCOIN_NETWORK=regtest` configured
247+
- The test automatically funds addresses and mines blocks, but ensure Docker has sufficient resources
188248
- **InvalidSigner errors**: The output bytes from Substrate events include SCALE encoding that must be stripped before verification

0 commit comments

Comments
 (0)