Skip to content

Commit

Permalink
feat(sdk): support signet (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevzzsk authored May 24, 2024
1 parent 1aadf2c commit d3950a8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions packages/sdk/src/addresses/formats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ export const addressFormats = {
p2wpkh: /^(tb1[qp]|bcrt1[qp])[a-zA-HJ-NP-Z0-9]{14,74}$/,
p2tr: /^(tb1p|bcrt1p)[a-zA-HJ-NP-Z0-9]{14,74}$/
},
signet: {
p2pkh: /^[mn][a-km-zA-HJ-NP-Z1-9]{25,34}$/,
p2sh: /^[2][a-km-zA-HJ-NP-Z1-9]{25,34}$/,
p2wpkh: /^(tb1[qp]|bcrt1[qp])[a-zA-HJ-NP-Z0-9]{14,74}$/,
p2tr: /^(tb1p|bcrt1p)[a-zA-HJ-NP-Z0-9]{14,74}$/
},
regtest: {
p2pkh: /^[mn][a-km-zA-HJ-NP-Z1-9]{25,34}$/,
p2sh: /^[2][a-km-zA-HJ-NP-Z1-9]{25,34}$/,
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/api/jsonrpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const rpc = {
},
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))
} as const

Expand Down
5 changes: 5 additions & 0 deletions packages/sdk/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ export const apiConfig = {
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/"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/config/types.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export type Network = "mainnet" | "testnet" | "regtest"
export type Network = "mainnet" | "testnet" | "regtest" | "signet"
5 changes: 4 additions & 1 deletion packages/sdk/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import {

export function getNetwork(value: Network) {
if (value === "mainnet") {
return bitcoin.networks["bitcoin"]
return bitcoin.networks.bitcoin
}
if (value === "signet") {
return bitcoin.networks.testnet
}

return bitcoin.networks[value]
Expand Down

0 comments on commit d3950a8

Please sign in to comment.