Skip to content

Commit

Permalink
Add support for regtest network
Browse files Browse the repository at this point in the history
  • Loading branch information
lmuntaner committed Sep 6, 2024
1 parent 90d1109 commit 35af68b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/ckbtc/src/types/bitcoin.params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import type {
network,
} from "../../candid/bitcoin";

export type BitcoinNetwork = "testnet" | "mainnet";
export type BitcoinNetwork = "testnet" | "mainnet" | "regtest";

const mapBitcoinNetwork = (network: BitcoinNetwork): network =>
network === "testnet" ? { testnet: null } : { mainnet: null };
const mapBitcoinNetwork: Record<BitcoinNetwork, network> = {
mainnet: { mainnet: null },
testnet: { testnet: null },
regtest: { regtest: null },
};

export type GetUtxosParams = Omit<get_utxos_request, "network" | "filter"> & {
network: BitcoinNetwork;
Expand Down Expand Up @@ -45,6 +48,6 @@ export const toGetBalanceParams = ({
...rest
}: GetBalanceParams): get_balance_request => ({
min_confirmations: toNullable(minConfirmations),
network: mapBitcoinNetwork(network),
network: mapBitcoinNetwork[network],
...rest,
});

0 comments on commit 35af68b

Please sign in to comment.