diff --git a/packages/sdk/src/api/jsonrpc.ts b/packages/sdk/src/api/jsonrpc.ts index d1059968..be637a9d 100644 --- a/packages/sdk/src/api/jsonrpc.ts +++ b/packages/sdk/src/api/jsonrpc.ts @@ -69,10 +69,19 @@ export const rpc = { get id() { return Math.floor(Math.random() * 100000) }, - mainnet: new JsonRpc(getRpcUrl(apiConfig.apis.mainnet.batter)), - testnet: new JsonRpc(getRpcUrl(apiConfig.apis.testnet.batter)), - signet: new JsonRpc(getRpcUrl(apiConfig.apis.signet.batter)), - regtest: new JsonRpc(getRpcUrl(apiConfig.apis.regtest.batter)) + bitcoin: { + mainnet: new JsonRpc(getRpcUrl(apiConfig.apis.bitcoin.mainnet.batter)), + testnet: new JsonRpc(getRpcUrl(apiConfig.apis.bitcoin.testnet.batter)), + signet: new JsonRpc(getRpcUrl(apiConfig.apis.bitcoin.signet.batter)), + regtest: new JsonRpc(getRpcUrl(apiConfig.apis.bitcoin.regtest.batter)) + }, + "fractal-bitcoin": { + mainnet: new JsonRpc(getRpcUrl(apiConfig.apis["fractal-bitcoin"].mainnet.batter)), + testnet: new JsonRpc(getRpcUrl(apiConfig.apis["fractal-bitcoin"].testnet.batter)), + // unused + signet: new JsonRpc(getRpcUrl(apiConfig.apis["fractal-bitcoin"].signet.batter)), + regtest: new JsonRpc(getRpcUrl(apiConfig.apis["fractal-bitcoin"].regtest.batter)) + } } as const /* diff --git a/packages/sdk/src/config/index.ts b/packages/sdk/src/config/index.ts index 51f96ae6..1e1946e4 100644 --- a/packages/sdk/src/config/index.ts +++ b/packages/sdk/src/config/index.ts @@ -1,25 +1,49 @@ export const apiConfig = { version: "0.0.0.10", apis: { - mainnet: { - batter: "https://mainnet.ordit.io/", - orderbook: "1H4vvBnr62YWQmvNSt8Z4pDw3Vcv1n5xz7", - ipfs: "http://ipfs-gateway.ordit.io/" + bitcoin: { + mainnet: { + batter: "https://mainnet.ordit.io/", + orderbook: "1H4vvBnr62YWQmvNSt8Z4pDw3Vcv1n5xz7", + ipfs: "http://ipfs-gateway.ordit.io/" + }, + regtest: { + batter: "https://regtest.ordit.io/", + orderbook: "bcrt1q2ys7qws8g072dqe3psp92pqz93ac6wmztexkh5", + ipfs: "http://ipfs-gateway.ordit.io/" + }, + testnet: { + batter: "https://testnet.ordit.io/", + orderbook: "tb1qfnw26753j7kqu3q099sd48htvtk5wm4e0enmru", + ipfs: "http://ipfs-gateway.ordit.io/" + }, + signet: { + batter: "https://signet.ordit.io/", + orderbook: "tb1qfnw26753j7kqu3q099sd48htvtk5wm4e0enmru", + ipfs: "http://ipfs-gateway.ordit.io/" + } }, - regtest: { - batter: "https://regtest.ordit.io/", - orderbook: "bcrt1q2ys7qws8g072dqe3psp92pqz93ac6wmztexkh5", - ipfs: "http://ipfs-gateway.ordit.io/" - }, - testnet: { - batter: "https://testnet.ordit.io/", - orderbook: "tb1qfnw26753j7kqu3q099sd48htvtk5wm4e0enmru", - ipfs: "http://ipfs-gateway.ordit.io/" - }, - signet: { - batter: "https://signet.ordit.io/", - orderbook: "tb1qfnw26753j7kqu3q099sd48htvtk5wm4e0enmru", - ipfs: "http://ipfs-gateway.ordit.io/" + "fractal-bitcoin": { + mainnet: { + batter: "https://fractal.ordit.io/", + orderbook: "", + ipfs: "http://ipfs-gateway.ordit.io/" + }, + regtest: { + batter: "https://fractal-regtest.ordit.io/", + orderbook: "", + ipfs: "http://ipfs-gateway.ordit.io/" + }, + testnet: { + batter: "https://fractal-testnet.ordit.io/", + orderbook: "", + ipfs: "http://ipfs-gateway.ordit.io/" + }, + signet: { + batter: "https://fractal-signet.ordit.io/", + orderbook: "", + ipfs: "http://ipfs-gateway.ordit.io/" + } } } } diff --git a/packages/sdk/src/fee/FeeEstimator.ts b/packages/sdk/src/fee/FeeEstimator.ts index b1660b1d..82b76929 100644 --- a/packages/sdk/src/fee/FeeEstimator.ts +++ b/packages/sdk/src/fee/FeeEstimator.ts @@ -1,7 +1,7 @@ import { Psbt } from "bitcoinjs-lib" import { AddressFormats, getNetwork, getScriptType } from ".." -import { Network } from "../config/types" +import { Chain, Network } from "../config/types" import { MAXIMUM_FEE } from "../constants" import { OrditSDKError } from "../utils/errors" import { FeeEstimatorOptions } from "./types" @@ -14,8 +14,9 @@ export default class FeeEstimator { protected witness?: Buffer[] = [] protected virtualSize = 0 protected weight = 0 + protected chain: Chain - constructor({ feeRate, network, psbt, witness }: FeeEstimatorOptions) { + constructor({ feeRate, network, psbt, witness, chain = "bitcoin" }: FeeEstimatorOptions) { if (feeRate < 0 || !Number.isSafeInteger(feeRate)) { throw new OrditSDKError("Invalid feeRate") } @@ -23,7 +24,8 @@ export default class FeeEstimator { this.feeRate = +feeRate // convert decimal to whole number that might have passed Number.isSafeInteger check due to precision loss this.network = network this.witness = witness || [] - this.psbt = psbt || new Psbt({ network: getNetwork(this.network) }) + this.psbt = psbt || new Psbt({ network: getNetwork(chain === "fractal-bitcoin" ? "mainnet" : this.network) }) + this.chain = chain } get data() { diff --git a/packages/sdk/src/fee/types.ts b/packages/sdk/src/fee/types.ts index 66559302..a16331e3 100644 --- a/packages/sdk/src/fee/types.ts +++ b/packages/sdk/src/fee/types.ts @@ -1,10 +1,11 @@ import { Psbt } from "bitcoinjs-lib" -import { Network } from "../config/types" +import { Chain, Network } from "../config/types" export interface FeeEstimatorOptions { feeRate: number network: Network psbt?: Psbt witness?: Buffer[] + chain?: Chain } diff --git a/packages/sdk/src/inscription/collection.ts b/packages/sdk/src/inscription/collection.ts index 34ca6b3e..94b644ec 100644 --- a/packages/sdk/src/inscription/collection.ts +++ b/packages/sdk/src/inscription/collection.ts @@ -34,8 +34,6 @@ export async function publishCollection({ throw new OrditSDKError("Invalid inscriptions supplied.") } - network = chain === "fractal-bitcoin" ? "mainnet" : network - if (royalty) { // 0 = 0%, 0.1 = 10% if (isNaN(royalty.pct) || royalty.pct < 0 || royalty.pct > MAXIMUM_ROYALTY_PERCENTAGE) { @@ -64,7 +62,7 @@ export async function publishCollection({ insc: inscriptions } - return new Inscriber({ ...options, meta: collectionMeta, network }) + return new Inscriber({ ...options, meta: collectionMeta, network, chain }) } export async function mintFromCollection({ chain = "bitcoin", ...options }: MintFromCollectionOptions) { @@ -76,9 +74,7 @@ export async function mintFromCollection({ chain = "bitcoin", ...options }: Mint throw new OrditSDKError("Invalid chain supplied.") } - options.network = chain === "fractal-bitcoin" ? "mainnet" : options.network - - const datasource = options.datasource || new JsonRpcDatasource({ network: options.network }) + const datasource = options.datasource || new JsonRpcDatasource({ network: options.network, chain }) const collection = await datasource.getInscription({ id: options.collectionInscriptionId }) if (!collection) { throw new OrditSDKError("Invalid collection") @@ -143,8 +139,6 @@ export async function bulkMintFromCollection({ throw new OrditSDKError("Invalid chain supplied.") } - network = chain === "fractal-bitcoin" ? "mainnet" : network - let currentPointer = 0 const { metaList, inscriptionList } = inscriptions.reduce<{ @@ -191,6 +185,7 @@ export async function bulkMintFromCollection({ return new InscriberV2({ address, + chain, publicKey, feeRate, datasource, diff --git a/packages/sdk/src/instant-trade/InstantTradeBuyerTxBuilder.ts b/packages/sdk/src/instant-trade/InstantTradeBuyerTxBuilder.ts index 14efa813..0d8405d3 100644 --- a/packages/sdk/src/instant-trade/InstantTradeBuyerTxBuilder.ts +++ b/packages/sdk/src/instant-trade/InstantTradeBuyerTxBuilder.ts @@ -34,8 +34,6 @@ export default class InstantTradeBuyerTxBuilder extends InstantTradeBuilder { throw new OrditSDKError("Invalid chain supplied") } - network = chain === "fractal-bitcoin" ? "mainnet" : network - super({ address, datasource, diff --git a/packages/sdk/src/instant-trade/InstantTradeSellerTxBuilder.ts b/packages/sdk/src/instant-trade/InstantTradeSellerTxBuilder.ts index 2d17477c..9d828e3d 100644 --- a/packages/sdk/src/instant-trade/InstantTradeSellerTxBuilder.ts +++ b/packages/sdk/src/instant-trade/InstantTradeSellerTxBuilder.ts @@ -30,8 +30,6 @@ export default class InstantTradeSellerTxBuilder extends InstantTradeBuilder { throw new OrditSDKError("Invalid chain supplied") } - network = chain === "fractal-bitcoin" ? "mainnet" : network - super({ address, datasource, diff --git a/packages/sdk/src/modules/BaseDatasource.ts b/packages/sdk/src/modules/BaseDatasource.ts index ef9c12b2..0409da0d 100644 --- a/packages/sdk/src/modules/BaseDatasource.ts +++ b/packages/sdk/src/modules/BaseDatasource.ts @@ -12,18 +12,22 @@ import { GetUnspentsResponse, RelayOptions } from "../api/types" -import { Network } from "../config/types" +import { Network, Chain } from "../config/types" import { Transaction, UTXO, UTXOLimited } from "../transactions/types" interface BaseDatasourceOptions { network: Network + chain?: Chain } export default abstract class BaseDatasource { protected readonly network: Network - constructor({ network }: BaseDatasourceOptions) { + protected readonly chain: Chain + + constructor({ chain = "bitcoin", network }: BaseDatasourceOptions) { this.network = network + this.chain = chain } abstract getBalance({ address }: GetBalanceOptions): Promise diff --git a/packages/sdk/src/modules/JsonRpcDatasource.ts b/packages/sdk/src/modules/JsonRpcDatasource.ts index 9bbb66b9..bbcce985 100644 --- a/packages/sdk/src/modules/JsonRpcDatasource.ts +++ b/packages/sdk/src/modules/JsonRpcDatasource.ts @@ -13,7 +13,7 @@ import { GetUnspentsResponse, RelayOptions } from "../api/types" -import { Network } from "../config/types" +import { Chain, Network } from "../config/types" import { Transaction, UTXO, UTXOLimited } from "../transactions/types" import { OrditSDKError } from "../utils/errors" import { BaseDatasource, DatasourceUtility } from "." @@ -21,11 +21,12 @@ import { JsonRpcPagination } from "./types" interface JsonRpcDatasourceOptions { network: Network + chain?: Chain } export default class JsonRpcDatasource extends BaseDatasource { - constructor({ network }: JsonRpcDatasourceOptions) { - super({ network }) + constructor({ chain = "bitcoin", network }: JsonRpcDatasourceOptions) { + super({ chain, network }) } async getBalance({ address }: GetBalanceOptions) { @@ -33,7 +34,7 @@ export default class JsonRpcDatasource extends BaseDatasource { throw new OrditSDKError("Invalid request") } - return rpc[this.network].call("Address.GetBalance", { address }, rpc.id) + return rpc[this.chain][this.network].call("Address.GetBalance", { address }, rpc.id) } async getInscription({ id, decodeMetadata }: GetInscriptionOptions) { @@ -41,7 +42,7 @@ export default class JsonRpcDatasource extends BaseDatasource { throw new OrditSDKError("Invalid request") } - let inscription = await rpc[this.network].call("Ordinals.GetInscription", { id }, rpc.id) + let inscription = await rpc[this.chain][this.network].call("Ordinals.GetInscription", { id }, rpc.id) if (decodeMetadata) { inscription = DatasourceUtility.transformInscriptions([inscription])[0] } @@ -54,7 +55,7 @@ export default class JsonRpcDatasource extends BaseDatasource { throw new OrditSDKError("Invalid request") } - return rpc[this.network].call("Ordinals.GetInscriptionUtxo", { id }, rpc.id) + return rpc[this.chain][this.network].call("Ordinals.GetInscriptionUtxo", { id }, rpc.id) } async getInscriptions({ @@ -71,7 +72,7 @@ export default class JsonRpcDatasource extends BaseDatasource { }: GetInscriptionsOptions) { let inscriptions: Inscription[] = [] do { - const { inscriptions: _inscriptions, pagination } = await rpc[this.network].call<{ + const { inscriptions: _inscriptions, pagination } = await rpc[this.chain][this.network].call<{ inscriptions: Inscription[] pagination: JsonRpcPagination }>( @@ -102,7 +103,7 @@ export default class JsonRpcDatasource extends BaseDatasource { throw new OrditSDKError("Invalid request") } - return rpc[this.network].call( + return rpc[this.chain][this.network].call( "Address.GetSpendables", { address, @@ -127,7 +128,7 @@ export default class JsonRpcDatasource extends BaseDatasource { throw new OrditSDKError("Invalid request") } - const tx = await rpc[this.network].call( + const tx = await rpc[this.chain][this.network].call( "Transactions.GetTransaction", { txid: txId, @@ -165,7 +166,7 @@ export default class JsonRpcDatasource extends BaseDatasource { throw new OrditSDKError("Invalid address") } - const response = await rpc[this.network].call( + const response = await rpc[this.chain][this.network].call( "Address.GetTransactions", { address, @@ -204,7 +205,7 @@ export default class JsonRpcDatasource extends BaseDatasource { let utxos: UTXO[] = [] do { - const { unspents, pagination } = await rpc[this.network].call<{ + const { unspents, pagination } = await rpc[this.chain][this.network].call<{ unspents: UTXO[] pagination: JsonRpcPagination }>( @@ -240,6 +241,6 @@ export default class JsonRpcDatasource extends BaseDatasource { throw new OrditSDKError("Invalid max fee rate") } - return rpc[this.network].call("Transactions.Relay", { hex, maxFeeRate, validate }, rpc.id) + return rpc[this.chain][this.network].call("Transactions.Relay", { hex, maxFeeRate, validate }, rpc.id) } } diff --git a/packages/sdk/src/transactions/Inscriber.ts b/packages/sdk/src/transactions/Inscriber.ts index 8efa6e73..7f72d860 100644 --- a/packages/sdk/src/transactions/Inscriber.ts +++ b/packages/sdk/src/transactions/Inscriber.ts @@ -13,7 +13,7 @@ import { OnOffUnion, TaptreeVersion } from ".." -import { Network } from "../config/types" +import { Chain, Network } from "../config/types" import { MINIMUM_AMOUNT_IN_SATS } from "../constants" import { OrditSDKError } from "../utils/errors" import { NestedObject } from "../utils/types" @@ -65,7 +65,8 @@ export class Inscriber extends PSBTBuilder { safeMode, meta, taptreeVersion, - datasource + datasource, + chain = "bitcoin" }: InscriberArgOptions) { super({ address, @@ -75,7 +76,8 @@ export class Inscriber extends PSBTBuilder { publicKey, outputs, autoAdjustment: false, - datasource + datasource, + chain }) if (!publicKey || !changeAddress || !mediaContent) { throw new OrditSDKError("Invalid options provided") @@ -276,7 +278,7 @@ export class Inscriber extends PSBTBuilder { this.buildTaprootTree() this.payment = bitcoin.payments.p2tr({ internalPubkey: Buffer.from(this.xKey, "hex"), - network: getNetwork(this.network), + network: getNetwork(this.chain === "fractal-bitcoin" ? "mainnet" : this.network), scriptTree: this.taprootTree, redeem: this.getReedemScript() }) @@ -295,7 +297,9 @@ export class Inscriber extends PSBTBuilder { this.recovery = true this.buildTaprootTree() - this.payment = createTransaction(Buffer.from(this.xKey, "hex"), "p2tr", this.network, { + const _network = getNetwork(this.chain === "fractal-bitcoin" ? "mainnet" : this.network) + + this.payment = createTransaction(Buffer.from(this.xKey, "hex"), "p2tr", _network, { scriptTree: this.taprootTree, redeem: this.getRecoveryRedeemScript() }) @@ -317,6 +321,7 @@ export class Inscriber extends PSBTBuilder { try { await this.fetchAndSelectSuitableUnspent({ skipStrictSatsCheck, customAmount }) } catch (error) { + console.log(error) return false } } @@ -367,6 +372,7 @@ export type InscriberArgOptions = Pick & { outputs?: Outputs encodeMetadata?: boolean datasource?: BaseDatasource + chain?: Chain } type Outputs = Array<{ address: string; value: number }> diff --git a/packages/sdk/src/transactions/InscriberV2.ts b/packages/sdk/src/transactions/InscriberV2.ts index a6ff574c..15e428e0 100644 --- a/packages/sdk/src/transactions/InscriberV2.ts +++ b/packages/sdk/src/transactions/InscriberV2.ts @@ -13,7 +13,7 @@ import { getNetwork, TaptreeVersion } from ".." -import { Network } from "../config/types" +import { Chain, Network } from "../config/types" import { MINIMUM_AMOUNT_IN_SATS } from "../constants" import { OrditSDKError } from "../utils/errors" import { PSBTBuilder } from "./PSBTBuilder" @@ -51,7 +51,8 @@ export class InscriberV2 extends PSBTBuilder { datasource, metaInscriptions, inscriptions, - isStandard + isStandard, + chain = "bitcoin" }: InscriberV2ArgOptions) { super({ address, @@ -61,7 +62,8 @@ export class InscriberV2 extends PSBTBuilder { publicKey, outputs, autoAdjustment: false, - datasource + datasource, + chain }) if (!publicKey || !changeAddress || !feeRate || !network) { throw new OrditSDKError("Invalid options provided") @@ -269,7 +271,7 @@ export class InscriberV2 extends PSBTBuilder { this.buildTaprootTree() this.payment = bitcoin.payments.p2tr({ internalPubkey: Buffer.from(this.xKey, "hex"), - network: getNetwork(this.network), + network: getNetwork(this.chain === "fractal-bitcoin" ? "mainnet" : this.network), scriptTree: this.taprootTree, redeem: this.getReedemScript() }) @@ -295,7 +297,8 @@ export class InscriberV2 extends PSBTBuilder { this.recovery = true this.buildTaprootTree() - this.payment = createTransaction(Buffer.from(this.xKey, "hex"), "p2tr", this.network, { + const _network = this.chain === "fractal-bitcoin" ? "mainnet" : this.network + this.payment = createTransaction(Buffer.from(this.xKey, "hex"), "p2tr", _network, { scriptTree: this.taprootTree, redeem: this.getRecoveryRedeemScript() }) @@ -364,6 +367,7 @@ export type InscriberV2ArgOptions = { outputs?: Outputs datasource?: BaseDatasource isStandard?: boolean + chain?: Chain } type Outputs = Array<{ address: string; value: number }> diff --git a/packages/sdk/src/transactions/PSBTBuilder.ts b/packages/sdk/src/transactions/PSBTBuilder.ts index ddcc119d..d8f847ac 100644 --- a/packages/sdk/src/transactions/PSBTBuilder.ts +++ b/packages/sdk/src/transactions/PSBTBuilder.ts @@ -12,7 +12,7 @@ import { JsonRpcDatasource, toXOnly } from ".." -import { Network } from "../config/types" +import { Chain, Network } from "../config/types" import { MINIMUM_AMOUNT_IN_SATS } from "../constants" import FeeEstimator from "../fee/FeeEstimator" import { OrditSDKError } from "../utils/errors" @@ -29,6 +29,7 @@ export interface PSBTBuilderOptions { autoAdjustment?: boolean instantTradeMode?: boolean datasource?: BaseDatasource + chain?: Chain } export type InjectableInput = { @@ -87,17 +88,19 @@ export class PSBTBuilder extends FeeEstimator { publicKey, outputs, autoAdjustment = true, - instantTradeMode = false + instantTradeMode = false, + chain = "bitcoin" }: PSBTBuilderOptions) { super({ feeRate, - network + network, + chain }) this.address = address this.changeAddress = changeAddress - this.datasource = datasource || new JsonRpcDatasource({ network: this.network }) + this.datasource = datasource || new JsonRpcDatasource({ chain: this.chain, network: this.network }) this.outputs = outputs - this.nativeNetwork = getNetwork(network) + this.nativeNetwork = getNetwork(this.chain === "fractal-bitcoin" ? "mainnet" : network) this.publicKey = publicKey this.autoAdjustment = autoAdjustment @@ -154,7 +157,7 @@ export class PSBTBuilder extends FeeEstimator { } protected initPSBT() { - this.psbt = new Psbt({ network: getNetwork(this.network) }) // create new PSBT + this.psbt = new Psbt({ network: getNetwork(this.chain === "fractal-bitcoin" ? "mainnet" : this.network) }) // create new PSBT this.psbt.setMaximumFeeRate(this.feeRate) } @@ -289,8 +292,8 @@ export class PSBTBuilder extends FeeEstimator { amount && amount > 0 ? amount : this.changeAmount < 0 - ? this.changeAmount * -1 - : this.outputAmount - this.getRetrievedUTXOsValue() + ? this.changeAmount * -1 + : this.outputAmount - this.getRetrievedUTXOsValue() if ((amount && this.getRetrievedUTXOsValue() >= amount) || amountToRequest <= 0) return diff --git a/packages/sdk/src/utils/index.ts b/packages/sdk/src/utils/index.ts index 46a2f518..12f2f01b 100644 --- a/packages/sdk/src/utils/index.ts +++ b/packages/sdk/src/utils/index.ts @@ -4,7 +4,7 @@ import * as bitcoin from "bitcoinjs-lib" import ECPairFactory from "ecpair" import { AddressFormats, AddressTypes, addressTypeToName } from "../addresses/formats" -import { Network } from "../config/types" +import { Chain, Network } from "../config/types" import { UTXO } from "../transactions/types" import { OrditSDKError } from "./errors" import { diff --git a/packages/sdk/src/utxos/UTXOManager.ts b/packages/sdk/src/utxos/UTXOManager.ts index f0d8a933..9fc7f4fa 100644 --- a/packages/sdk/src/utxos/UTXOManager.ts +++ b/packages/sdk/src/utxos/UTXOManager.ts @@ -9,8 +9,6 @@ export default class UTXOManager extends PSBTBuilder { throw new OrditSDKError("Invalid chain supplied") } - network = chain === "fractal-bitcoin" ? "mainnet" : network - super({ address, publicKey, diff --git a/packages/sdk/src/wallet/Ordit.ts b/packages/sdk/src/wallet/Ordit.ts index 01595f3d..ddf91b2e 100644 --- a/packages/sdk/src/wallet/Ordit.ts +++ b/packages/sdk/src/wallet/Ordit.ts @@ -29,6 +29,8 @@ const ECPair = ECPairFactory(ecc) const bip32 = BIP32Factory(ecc) export class Ordit { + chain: Chain = "bitcoin" + #network: Network = "testnet" // #config; #initialized = false @@ -50,7 +52,7 @@ export class Ordit { addressIndex = 0, chain = "bitcoin" }: WalletOptions) { - this.#network = chain === "fractal-bitcoin" ? "mainnet" : network + this.chain = chain const networkObj = getNetwork(network) const format = addressNameToType[type] @@ -161,17 +163,19 @@ export class Ordit { generateAddress(type: AddressFormats, account: number, addressIndex: number) { if (!this.#hdNode) throw new OrditSDKError("No HD node found. Please reinitialize with BIP39 words or seed.") + const _network = this.chain === "fractal-bitcoin" ? "mainnet" : this.#network + return getAccountDataFromHdNode({ hdNode: this.#hdNode, format: type, - network: this.#network, + network: _network, account, addressIndex }) } signPsbt(value: string, { finalize = true, extractTx = true, isRevealTx = false }: SignPSBTOptions = {}) { - const networkObj = getNetwork(this.#network) + const networkObj = getNetwork(this.chain === "fractal-bitcoin" ? "mainnet" : this.#network) let psbt: bitcoin.Psbt | null = null if (!this.#keyPair || !this.#initialized) { @@ -264,7 +268,12 @@ export class Ordit { }) as Account const signature = AddressUtils.isP2PKH(node.address!) ? sign(message, node.child.privateKey!) - : Signer.sign(node.child.toWIF(), node.address!, message, getNetwork(this.#network)) + : Signer.sign( + node.child.toWIF(), + node.address!, + message, + getNetwork(this.chain === "fractal-bitcoin" ? "mainnet" : this.#network) + ) return signature.toString("base64") }