bip-321 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.ts +15 -6
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -232,7 +232,12 @@ export function parseBIP321(
232
232
  const decodedValue = decodeURIComponent(value);
233
233
  const validation = validateBitcoinAddress(decodedValue);
234
234
  const networkMatches =
235
- validation.valid && validation.network === expectedNetwork;
235
+ validation.valid &&
236
+ (validation.network === expectedNetwork ||
237
+ // Testnet and signet are interchangeable for onchain
238
+ (validation.network === "testnet" &&
239
+ expectedNetwork === "signet") ||
240
+ (validation.network === "signet" && expectedNetwork === "testnet"));
236
241
 
237
242
  result.paymentMethods.push({
238
243
  type: "onchain",
@@ -274,12 +279,16 @@ export function parseBIP321(
274
279
  for (const method of result.paymentMethods) {
275
280
  if (method.network && method.network !== expectedNetwork) {
276
281
  // For Ark and Silent Payments, testnet covers testnet/signet/regtest
282
+ // For onchain, testnet and signet are interchangeable
277
283
  const isTestnetCompatible =
278
- (method.type === "ark" || method.type === "silent-payment") &&
279
- method.network === "testnet" &&
280
- (expectedNetwork === "testnet" ||
281
- expectedNetwork === "signet" ||
282
- expectedNetwork === "regtest");
284
+ ((method.type === "ark" || method.type === "silent-payment") &&
285
+ method.network === "testnet" &&
286
+ (expectedNetwork === "testnet" ||
287
+ expectedNetwork === "signet" ||
288
+ expectedNetwork === "regtest")) ||
289
+ (method.type === "onchain" &&
290
+ ((method.network === "testnet" && expectedNetwork === "signet") ||
291
+ (method.network === "signet" && expectedNetwork === "testnet")));
283
292
 
284
293
  if (!isTestnetCompatible) {
285
294
  result.errors.push(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bip-321",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "A TypeScript/JavaScript library for parsing BIP-321 Bitcoin URI scheme with support for multiple payment methods",
5
5
  "type": "module",
6
6
  "main": "./index.ts",