@dynamic-labs-wallet/btc-utils 1.0.69 → 1.0.71

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.
package/index.cjs CHANGED
@@ -1266,23 +1266,33 @@ function _instanceof$1(left, right) {
1266
1266
  return false;
1267
1267
  }
1268
1268
  var script = Buffer.isBuffer(input.witnessUtxo.script) ? input.witnessUtxo.script : Buffer.from(input.witnessUtxo.script);
1269
- var bitcoinNetwork = getBitcoinNetwork(network);
1269
+ // Callers key wallets by the identity (mainnet) address regardless of the
1270
+ // signing network, so accept the input under either encoding — the script
1271
+ // itself is network-independent.
1272
+ var networksToTry = network === core.BitcoinNetwork.MAINNET ? [
1273
+ getBitcoinNetwork(network)
1274
+ ] : [
1275
+ getBitcoinNetwork(network),
1276
+ getBitcoinNetwork(core.BitcoinNetwork.MAINNET)
1277
+ ];
1270
1278
  try {
1271
1279
  // Try P2WPKH (Native SegWit) - script is OP_0 <20-byte hash>
1272
1280
  if (script.length === 22 && script[0] === 0x00 && script[1] === 0x14) {
1273
- var p2wpkh = bitcoin__namespace.payments.p2wpkh({
1274
- output: script,
1275
- network: bitcoinNetwork
1281
+ return networksToTry.some(function(bitcoinNetwork) {
1282
+ return bitcoin__namespace.payments.p2wpkh({
1283
+ output: script,
1284
+ network: bitcoinNetwork
1285
+ }).address === address;
1276
1286
  });
1277
- return p2wpkh.address === address;
1278
1287
  }
1279
1288
  // Try P2TR (Taproot) - script is OP_1 <32-byte x-only pubkey>
1280
1289
  if (script.length === 34 && script[0] === 0x51 && script[1] === 0x20) {
1281
- var p2tr = bitcoin__namespace.payments.p2tr({
1282
- output: script,
1283
- network: bitcoinNetwork
1290
+ return networksToTry.some(function(bitcoinNetwork) {
1291
+ return bitcoin__namespace.payments.p2tr({
1292
+ output: script,
1293
+ network: bitcoinNetwork
1294
+ }).address === address;
1284
1295
  });
1285
- return p2tr.address === address;
1286
1296
  }
1287
1297
  return false;
1288
1298
  } catch (error) {
package/index.esm.js CHANGED
@@ -1246,23 +1246,33 @@ function _instanceof$1(left, right) {
1246
1246
  return false;
1247
1247
  }
1248
1248
  var script = Buffer.isBuffer(input.witnessUtxo.script) ? input.witnessUtxo.script : Buffer.from(input.witnessUtxo.script);
1249
- var bitcoinNetwork = getBitcoinNetwork(network);
1249
+ // Callers key wallets by the identity (mainnet) address regardless of the
1250
+ // signing network, so accept the input under either encoding — the script
1251
+ // itself is network-independent.
1252
+ var networksToTry = network === BitcoinNetwork.MAINNET ? [
1253
+ getBitcoinNetwork(network)
1254
+ ] : [
1255
+ getBitcoinNetwork(network),
1256
+ getBitcoinNetwork(BitcoinNetwork.MAINNET)
1257
+ ];
1250
1258
  try {
1251
1259
  // Try P2WPKH (Native SegWit) - script is OP_0 <20-byte hash>
1252
1260
  if (script.length === 22 && script[0] === 0x00 && script[1] === 0x14) {
1253
- var p2wpkh = bitcoin.payments.p2wpkh({
1254
- output: script,
1255
- network: bitcoinNetwork
1261
+ return networksToTry.some(function(bitcoinNetwork) {
1262
+ return bitcoin.payments.p2wpkh({
1263
+ output: script,
1264
+ network: bitcoinNetwork
1265
+ }).address === address;
1256
1266
  });
1257
- return p2wpkh.address === address;
1258
1267
  }
1259
1268
  // Try P2TR (Taproot) - script is OP_1 <32-byte x-only pubkey>
1260
1269
  if (script.length === 34 && script[0] === 0x51 && script[1] === 0x20) {
1261
- var p2tr = bitcoin.payments.p2tr({
1262
- output: script,
1263
- network: bitcoinNetwork
1270
+ return networksToTry.some(function(bitcoinNetwork) {
1271
+ return bitcoin.payments.p2tr({
1272
+ output: script,
1273
+ network: bitcoinNetwork
1274
+ }).address === address;
1264
1275
  });
1265
- return p2tr.address === address;
1266
1276
  }
1267
1277
  return false;
1268
1278
  } catch (error) {
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@dynamic-labs-wallet/btc-utils",
3
- "version": "1.0.69",
3
+ "version": "1.0.71",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "dependencies": {
8
- "@dynamic-labs-wallet/core": "1.0.69",
8
+ "@dynamic-labs-wallet/core": "1.0.71",
9
9
  "bitcoinjs-lib": "^7.0.0",
10
10
  "bip322-js": "^3.0.0",
11
11
  "@noble/hashes": "1.7.1",
@@ -1,5 +1,5 @@
1
1
  import type { Psbt } from 'bitcoinjs-lib';
2
- import type { BitcoinNetwork } from '@dynamic-labs-wallet/core';
2
+ import { BitcoinNetwork } from '@dynamic-labs-wallet/core';
3
3
  /**
4
4
  * Checks if a PSBT input belongs to a specific address
5
5
  * @param input - The PSBT input (from psbt.data.inputs)
@@ -1 +1 @@
1
- {"version":3,"file":"doesInputBelongToAddress.d.ts","sourceRoot":"","sources":["../../src/doesInputBelongToAddress/doesInputBelongToAddress.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGhE;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,UAC5B,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,WAC5B,MAAM,WACN,cAAc,KACtB,OAwCF,CAAC"}
1
+ {"version":3,"file":"doesInputBelongToAddress.d.ts","sourceRoot":"","sources":["../../src/doesInputBelongToAddress/doesInputBelongToAddress.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG3D;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,UAC5B,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,WAC5B,MAAM,WACN,cAAc,KACtB,OAkDF,CAAC"}