Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
// SPDX-License-Identifier: Apache-2.0

import { BlockStreamTestnetRequestStrategy, MempoolTestnetRequestStrategy } from '@subwallet/extension-base/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet';
import { SubWalletMainnetRequestStrategy } from '@subwallet/extension-base/services/chain-service/handler/bitcoin/strategy/SubWalletMainnet';
import { BitcoinApiStrategy } from '@subwallet/extension-base/services/chain-service/handler/bitcoin/strategy/types';
import { createPromiseHandler, PromiseHandler } from '@subwallet/extension-base/utils/promise';
Expand All @@ -13,6 +12,7 @@ import { _BitcoinApi, _ChainConnectionStatus } from '../../types';
// const isBlockStreamProvider = (apiUrl: string): boolean => apiUrl === 'https://blockstream-testnet.openbit.app' || apiUrl === 'https://electrs.openbit.app';
// const BLOCKSTREAM_TESTNET_API_URL = 'https://blockstream.info/testnet/api/';
// const MEMPOOL_TESTNET_V4_API_URL = 'https://mempool.space/testnet4/api/';
const BLOCKSTREAM_TESTNET_API_URL = 'https://blockstream-testnet-v3.koni.studio';

export class BitcoinApi implements _BitcoinApi {
chainSlug: string;
Expand Down Expand Up @@ -43,14 +43,10 @@ export class BitcoinApi implements _BitcoinApi {
}

private createApiStrategy (apiUrl: string): BitcoinApiStrategy {
const _apiUrl = 'https://blockstream.info/testnet/api/'; // todo: for test
const isTestnet = apiUrl.includes('testnet');
const isBlockstreamUrl = apiUrl.includes('blockstream');

if (isTestnet) {
return isBlockstreamUrl
? new BlockStreamTestnetRequestStrategy(_apiUrl)
: new MempoolTestnetRequestStrategy(_apiUrl);
return new SubWalletMainnetRequestStrategy(BLOCKSTREAM_TESTNET_API_URL);
}

return new SubWalletMainnetRequestStrategy(apiUrl);
Expand Down