Skip to content

Commit

Permalink
chore: Add BTC signet SPV start block height
Browse files Browse the repository at this point in the history
  • Loading branch information
duanyytop committed Jul 24, 2024
1 parent 29ec966 commit 2f59061
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ export const VERCEL_MAX_DURATION = 300;
// ref: https://mempool.space/testnet/block/000000000000000493ba5eebf0602f3e0e5381dd35f763a62ca7ea135343a0d6
export const BTC_TESTNET_SPV_START_BLOCK_HEIGHT = 2584900;

// estimate time: 2024-06-13 18:31:56
// ref: https://mempool.space/signet/block/000000b2af39a66ec81d414b102804d975c5c4527adfd9bd3cabf2b7b4634737
// Signet BTC SPV deployment time: https://pudge.explorer.nervos.org/transaction/0x61efdeddbaa0bb4132c0eb174b3e8002ff5ec430f61ba46f30768d683c516eec
export const BTC_SIGNET_SPV_START_BLOCK_HEIGHT = 199800;

// estimate time: 2024-04-02 06:20:03
// ref: https://mempool.space/block/0000000000000000000077d98a103858c7d7cbc5ba67a4135f348a436bec1748
export const BTC_MAINNET_SPV_START_BLOCK_HEIGHT = 837300;
16 changes: 14 additions & 2 deletions src/services/unlocker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ import {
import { btcTxIdFromBtcTimeLockArgs } from '@rgbpp-sdk/ckb/lib/utils/rgbpp';
import { BtcAssetsApi } from '@rgbpp-sdk/service';
import { Cradle } from '../container';
import { BTC_MAINNET_SPV_START_BLOCK_HEIGHT, BTC_TESTNET_SPV_START_BLOCK_HEIGHT, TestnetTypeMap } from '../constants';
import {
BTC_MAINNET_SPV_START_BLOCK_HEIGHT,
BTC_SIGNET_SPV_START_BLOCK_HEIGHT,
BTC_TESTNET_SPV_START_BLOCK_HEIGHT,
TestnetTypeMap,
} from '../constants';

interface IUnlocker {
getNextBatchLockCell(): Promise<IndexerCell[]>;
Expand Down Expand Up @@ -55,7 +60,14 @@ export default class Unlocker implements IUnlocker {
}

private get btcSpvStartBlockHeight() {
return this.isMainnet ? BTC_MAINNET_SPV_START_BLOCK_HEIGHT : BTC_TESTNET_SPV_START_BLOCK_HEIGHT;
const network = this.cradle.env.NETWORK;
if (network === 'mainnet') {
return BTC_MAINNET_SPV_START_BLOCK_HEIGHT;
}
if (network === 'testnet') {
return BTC_TESTNET_SPV_START_BLOCK_HEIGHT;
}
return BTC_SIGNET_SPV_START_BLOCK_HEIGHT;
}

/**
Expand Down

0 comments on commit 2f59061

Please sign in to comment.