|
|
|
|
@@ -124,25 +124,11 @@ const ADDRESS_CHARS: {
|
|
|
|
|
+ `{20,100}`
|
|
|
|
|
+ `)`,
|
|
|
|
|
},
|
|
|
|
|
bisq: {
|
|
|
|
|
base58: `(?:[bB][13]` // b or B at the start, followed by a single 1 or 3
|
|
|
|
|
+ BASE58_CHARS
|
|
|
|
|
+ `{26,33})`,
|
|
|
|
|
bech32: `(?:`
|
|
|
|
|
+ `[bB]bc1` // b or B at the start, followed by bc1
|
|
|
|
|
+ BECH32_CHARS_LW
|
|
|
|
|
+ `{20,100}`
|
|
|
|
|
+ `|`
|
|
|
|
|
+ `[bB]BC1` // b or B at the start, followed by BC1
|
|
|
|
|
+ BECH32_CHARS_UP
|
|
|
|
|
+ `{20,100}`
|
|
|
|
|
+ `)`,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
type RegexTypeNoAddrNoBlockHash = | `transaction` | `blockheight` | `date` | `timestamp`;
|
|
|
|
|
export type RegexType = `address` | `blockhash` | RegexTypeNoAddrNoBlockHash;
|
|
|
|
|
|
|
|
|
|
export const NETWORKS = [`testnet`, `signet`, `liquid`, `liquidtestnet`, `bisq`, `mainnet`] as const;
|
|
|
|
|
export const NETWORKS = [`testnet`, `signet`, `liquid`, `liquidtestnet`, `mainnet`] as const;
|
|
|
|
|
export type Network = typeof NETWORKS[number]; // Turn const array into union type
|
|
|
|
|
|
|
|
|
|
export const ADDRESS_REGEXES: [RegExp, Network][] = NETWORKS
|
|
|
|
|
@@ -164,8 +150,6 @@ function isNetworkAvailable(network: Network, env: Env): boolean {
|
|
|
|
|
return env.LIQUID_ENABLED === true;
|
|
|
|
|
case 'liquidtestnet':
|
|
|
|
|
return env.LIQUID_TESTNET_ENABLED === true;
|
|
|
|
|
case 'bisq':
|
|
|
|
|
return env.BISQ_ENABLED === true;
|
|
|
|
|
case 'mainnet':
|
|
|
|
|
return true; // There is no "MAINNET_ENABLED" flag
|
|
|
|
|
default:
|
|
|
|
|
@@ -173,7 +157,7 @@ function isNetworkAvailable(network: Network, env: Env): boolean {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function needBaseModuleChange(fromBaseModule: 'mempool' | 'liquid' | 'bisq', toNetwork: Network): boolean {
|
|
|
|
|
export function needBaseModuleChange(fromBaseModule: 'mempool' | 'liquid', toNetwork: Network): boolean {
|
|
|
|
|
if (!toNetwork) return false; // No target network means no change needed
|
|
|
|
|
if (fromBaseModule === 'mempool') {
|
|
|
|
|
return toNetwork !== 'mainnet' && toNetwork !== 'testnet' && toNetwork !== 'signet';
|
|
|
|
|
@@ -181,9 +165,6 @@ export function needBaseModuleChange(fromBaseModule: 'mempool' | 'liquid' | 'bis
|
|
|
|
|
if (fromBaseModule === 'liquid') {
|
|
|
|
|
return toNetwork !== 'liquid' && toNetwork !== 'liquidtestnet';
|
|
|
|
|
}
|
|
|
|
|
if (fromBaseModule === 'bisq') {
|
|
|
|
|
return toNetwork !== 'bisq';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function getTargetUrl(toNetwork: Network, address: string, env: Env): string {
|
|
|
|
|
@@ -194,11 +175,6 @@ export function getTargetUrl(toNetwork: Network, address: string, env: Env): str
|
|
|
|
|
targetUrl += '/address/';
|
|
|
|
|
targetUrl += address;
|
|
|
|
|
}
|
|
|
|
|
if (toNetwork === 'bisq') {
|
|
|
|
|
targetUrl = env.BISQ_WEBSITE_URL;
|
|
|
|
|
targetUrl += '/address/';
|
|
|
|
|
targetUrl += address;
|
|
|
|
|
}
|
|
|
|
|
if (toNetwork === 'mainnet' || toNetwork === 'testnet' || toNetwork === 'signet') {
|
|
|
|
|
targetUrl = env.MEMPOOL_WEBSITE_URL;
|
|
|
|
|
targetUrl += (toNetwork === 'mainnet' ? '' : `/${toNetwork}`);
|
|
|
|
|
@@ -242,9 +218,6 @@ export function getRegex(type: RegexType, network?: Network): RegExp {
|
|
|
|
|
case `liquidtestnet`:
|
|
|
|
|
leadingZeroes = 8; // We are not interested in Liquid block hashes
|
|
|
|
|
break;
|
|
|
|
|
case `bisq`:
|
|
|
|
|
leadingZeroes = 8; // Assumes at least 32 bits of difficulty
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
throw new Error(`Invalid Network ${network} (Unreachable error in TypeScript)`);
|
|
|
|
|
}
|
|
|
|
|
@@ -307,11 +280,6 @@ export function getRegex(type: RegexType, network?: Network): RegExp {
|
|
|
|
|
regex += `|`; // OR
|
|
|
|
|
regex += ADDRESS_CHARS.liquidtestnet.bech32;
|
|
|
|
|
break;
|
|
|
|
|
case `bisq`:
|
|
|
|
|
regex += ADDRESS_CHARS.bisq.base58;
|
|
|
|
|
regex += `|`; // OR
|
|
|
|
|
regex += ADDRESS_CHARS.bisq.bech32;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
throw new Error(`Invalid Network ${network} (Unreachable error in TypeScript)`);
|
|
|
|
|
}
|
|
|
|
|
|