@did-btcr2/method 0.48.0 → 0.50.0

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/dist/browser.mjs CHANGED
@@ -20138,23 +20138,37 @@ function changeOutputKind(changeAddress, network) {
20138
20138
  function opReturnScript(signalBytes) {
20139
20139
  return Script.encode(["RETURN", signalBytes]);
20140
20140
  }
20141
- async function fetchSpendableUtxo(bitcoinAddress, bitcoin) {
20142
- const utxos = await bitcoin.rest.address.getUtxos(bitcoinAddress);
20141
+ var SPENDABLE_DUST_LIMIT_SATS = 546;
20142
+ function byDepthThenId(a, b) {
20143
+ if (a.status.block_height !== b.status.block_height) {
20144
+ return a.status.block_height - b.status.block_height;
20145
+ }
20146
+ const txidOrder = a.txid.localeCompare(b.txid);
20147
+ return txidOrder !== 0 ? txidOrder : a.vout - b.vout;
20148
+ }
20149
+ function selectSpendableUtxo(utxos, address) {
20143
20150
  if (!utxos.length) {
20144
20151
  throw new BeaconError(
20145
20152
  "No UTXOs found, please fund address!",
20146
20153
  "UNFUNDED_BEACON_ADDRESS",
20147
- { address: bitcoinAddress }
20154
+ { address }
20148
20155
  );
20149
20156
  }
20150
- const utxo = utxos.sort((a, b) => b.status.block_height - a.status.block_height).shift();
20151
- if (!utxo) {
20157
+ const confirmed = utxos.filter((utxo) => utxo.status.confirmed === true);
20158
+ const spendable = confirmed.filter((utxo) => utxo.value > SPENDABLE_DUST_LIMIT_SATS);
20159
+ if (!spendable.length) {
20160
+ const reason = confirmed.length === 0 ? `all ${utxos.length} UTXO(s) are unconfirmed` : `all ${confirmed.length} confirmed UTXO(s) are at or below the ${SPENDABLE_DUST_LIMIT_SATS}-sat dust limit`;
20152
20161
  throw new BeaconError(
20153
- "Beacon bitcoin address unfunded or utxos unconfirmed.",
20154
- "UNFUNDED_BEACON_ADDRESS",
20155
- { address: bitcoinAddress }
20162
+ `No spendable UTXO at beacon address: ${reason}.`,
20163
+ "NO_SPENDABLE_BEACON_UTXO",
20164
+ { address, total: utxos.length, confirmed: confirmed.length, dustLimit: SPENDABLE_DUST_LIMIT_SATS }
20156
20165
  );
20157
20166
  }
20167
+ return [...spendable].sort(byDepthThenId)[0];
20168
+ }
20169
+ async function fetchSpendableUtxo(bitcoinAddress, bitcoin) {
20170
+ const utxos = await bitcoin.rest.address.getUtxos(bitcoinAddress);
20171
+ const utxo = selectSpendableUtxo(utxos, bitcoinAddress);
20158
20172
  const prevTxHex = await bitcoin.rest.transaction.getHex(utxo.txid);
20159
20173
  return { utxo, prevTxBytes: hexToBytes(prevTxHex) };
20160
20174
  }
@@ -38915,18 +38929,19 @@ var Identifier = class _Identifier {
38915
38929
  * @returns {string} The new did:btcr2 identifier.
38916
38930
  */
38917
38931
  static encode(genesisBytes, options) {
38918
- const { idType, version = 1, network } = options;
38932
+ const { idType, version = 1, network = "bitcoin" } = options;
38919
38933
  if (!(idType in IdentifierTypes)) {
38920
38934
  throw new IdentifierError('Expected "idType" to be "KEY" or "EXTERNAL"', INVALID_DID, { idType });
38921
38935
  }
38922
- if (isNaN(version) || version > 1) {
38936
+ if (version !== 1) {
38923
38937
  throw new IdentifierError('Expected "version" to be 1', INVALID_DID, { version });
38924
38938
  }
38925
- if (typeof network === "string" && !(network in BitcoinNetworkNames)) {
38926
- throw new IdentifierError('Invalid "network" name', INVALID_DID, { network });
38939
+ if (typeof network !== "string") {
38940
+ throw new IdentifierError('Expected "network" to be a known network name', INVALID_DID, { network });
38927
38941
  }
38928
- if (typeof network === "number" && (network < 0 || network > 8)) {
38929
- throw new IdentifierError('Invalid "network" number', INVALID_DID, { network });
38942
+ const networkValue = BitcoinNetworkNames[network];
38943
+ if (networkValue === void 0) {
38944
+ throw new IdentifierError('Invalid "network" name', INVALID_DID, { network });
38930
38945
  }
38931
38946
  if (idType === "KEY") {
38932
38947
  try {
@@ -38938,28 +38953,16 @@ var Identifier = class _Identifier {
38938
38953
  { genesisBytes }
38939
38954
  );
38940
38955
  }
38956
+ } else if (genesisBytes.length !== 32) {
38957
+ throw new IdentifierError(
38958
+ 'Expected "genesisBytes" to be a 32-byte hash for EXTERNAL identifiers',
38959
+ INVALID_DID,
38960
+ { genesisBytes }
38961
+ );
38941
38962
  }
38942
38963
  const hrp = idType === "KEY" ? "k" : "x";
38943
- const nibbles = [];
38944
- const fCount = Math.floor((version - 1) / 15);
38945
- for (let i = 0; i < fCount; i++) {
38946
- nibbles.push(15);
38947
- }
38948
- nibbles.push((version - 1) % 15);
38949
- if (typeof network === "string") {
38950
- nibbles.push(BitcoinNetworkNames[network]);
38951
- } else if (typeof network === "number") {
38952
- nibbles.push(network + 11);
38953
- }
38954
- if (nibbles.length % 2 !== 0) {
38955
- nibbles.push(0);
38956
- }
38957
- if (fCount !== 0) {
38958
- for (const index in Array.from({ length: nibbles.length / 2 - 1 })) {
38959
- throw new IdentifierError("Not implemented", "NOT_IMPLEMENTED", { index });
38960
- }
38961
- }
38962
- const dataBytes = new Uint8Array([nibbles[2 * 0] << 4 | nibbles[2 * 0 + 1], ...genesisBytes]);
38964
+ const firstByte = version - 1 << 4 | networkValue;
38965
+ const dataBytes = new Uint8Array([firstByte, ...genesisBytes]);
38963
38966
  return `did:btcr2:${bech32m.encodeFromBytes(hrp, dataBytes)}`;
38964
38967
  }
38965
38968
  /**
@@ -38989,53 +38992,34 @@ var Identifier = class _Identifier {
38989
38992
  if (!["x", "k"].includes(hrp)) {
38990
38993
  throw new IdentifierError(`Invalid hrp: ${hrp}`, INVALID_DID, { identifier });
38991
38994
  }
38992
- if (!dataBytes) {
38995
+ if (!dataBytes || dataBytes.length < 1) {
38993
38996
  throw new IdentifierError(`Failed to decode id: ${encoded}`, INVALID_DID, { identifier });
38994
38997
  }
38995
38998
  const idType = hrp === "k" ? "KEY" : "EXTERNAL";
38996
- let version = 1;
38997
- let byteIndex = 0;
38998
- let nibblesConsumed = 0;
38999
- let currentByte = dataBytes[byteIndex];
39000
- let versionNibble = currentByte >>> 4;
39001
- while (versionNibble === 15) {
39002
- version += 15;
39003
- if (nibblesConsumed % 2 === 0) {
39004
- versionNibble = currentByte & 15;
39005
- } else {
39006
- currentByte = dataBytes[++byteIndex];
39007
- versionNibble = currentByte >>> 4;
39008
- }
39009
- nibblesConsumed += 1;
39010
- if (version > 1) {
39011
- throw new IdentifierError(`Invalid version: ${version}`, INVALID_DID, { identifier });
39012
- }
39013
- }
39014
- version += versionNibble;
39015
- nibblesConsumed += 1;
39016
- let networkValue = nibblesConsumed % 2 === 0 ? dataBytes[++byteIndex] >>> 4 : currentByte & 15;
39017
- nibblesConsumed += 1;
39018
- let network = BitcoinNetworkNames[networkValue];
39019
- if (!network) {
39020
- if (networkValue >= 8 && networkValue <= 15) {
39021
- network = networkValue - 11;
39022
- } else {
39023
- throw new IdentifierError(`Invalid did: ${identifier}`, INVALID_DID, { identifier });
39024
- }
39025
- }
39026
- if (nibblesConsumed % 2 === 1) {
39027
- const fillerNibble = currentByte & 15;
39028
- if (fillerNibble !== 0) {
39029
- throw new IdentifierError(`Invalid did: ${identifier}`, INVALID_DID, { identifier });
39030
- }
38999
+ const btcr2Version = dataBytes[0] >>> 4;
39000
+ if (btcr2Version !== 0) {
39001
+ throw new IdentifierError(`Invalid btcr2_version (expected 0): ${btcr2Version}`, INVALID_DID, { identifier });
39002
+ }
39003
+ const version = 1;
39004
+ const networkValue = dataBytes[0] & 15;
39005
+ const networkName = BitcoinNetworkNames[networkValue];
39006
+ let network;
39007
+ if (typeof networkName === "string") {
39008
+ network = networkName;
39009
+ } else if (networkValue >= 12 && networkValue <= 14) {
39010
+ network = networkValue - 11;
39011
+ } else {
39012
+ throw new IdentifierError(`Invalid network: ${networkValue}`, INVALID_DID, { identifier });
39031
39013
  }
39032
- const genesisBytes = dataBytes.slice(byteIndex + 1);
39014
+ const genesisBytes = dataBytes.slice(1);
39033
39015
  if (idType === "KEY") {
39034
39016
  try {
39035
39017
  new CompressedSecp256k1PublicKey(genesisBytes);
39036
39018
  } catch {
39037
39019
  throw new IdentifierError(`Invalid genesisBytes: ${genesisBytes}`, INVALID_DID, { identifier });
39038
39020
  }
39021
+ } else if (genesisBytes.length !== 32) {
39022
+ throw new IdentifierError(`Invalid genesisBytes: ${genesisBytes}`, INVALID_DID, { identifier });
39039
39023
  }
39040
39024
  return { idType, hrp, version, network, genesisBytes };
39041
39025
  }
@@ -41545,6 +41529,7 @@ export {
41545
41529
  SINGLETON_BEACON_TX_VSIZE,
41546
41530
  SMTBeacon,
41547
41531
  SMTBeaconError,
41532
+ SPENDABLE_DUST_LIMIT_SATS,
41548
41533
  SinglePartyBeacon,
41549
41534
  SingletonBeacon,
41550
41535
  SingletonBeaconError,
@@ -41558,7 +41543,8 @@ export {
41558
41543
  isMultikeyVerificationMethod,
41559
41544
  opReturnScript,
41560
41545
  resolveBtcr2SenderPk,
41561
- resolveChangeAddress
41546
+ resolveChangeAddress,
41547
+ selectSpendableUtxo
41562
41548
  };
41563
41549
  /*! Bundled license information:
41564
41550
 
package/dist/cjs/index.js CHANGED
@@ -50,6 +50,7 @@ __export(index_exports, {
50
50
  SINGLETON_BEACON_TX_VSIZE: () => SINGLETON_BEACON_TX_VSIZE,
51
51
  SMTBeacon: () => SMTBeacon,
52
52
  SMTBeaconError: () => SMTBeaconError,
53
+ SPENDABLE_DUST_LIMIT_SATS: () => SPENDABLE_DUST_LIMIT_SATS,
53
54
  SinglePartyBeacon: () => SinglePartyBeacon,
54
55
  SingletonBeacon: () => SingletonBeacon,
55
56
  SingletonBeaconError: () => SingletonBeaconError,
@@ -63,7 +64,8 @@ __export(index_exports, {
63
64
  isMultikeyVerificationMethod: () => isMultikeyVerificationMethod,
64
65
  opReturnScript: () => opReturnScript,
65
66
  resolveBtcr2SenderPk: () => resolveBtcr2SenderPk,
66
- resolveChangeAddress: () => resolveChangeAddress
67
+ resolveChangeAddress: () => resolveChangeAddress,
68
+ selectSpendableUtxo: () => selectSpendableUtxo
67
69
  });
68
70
  module.exports = __toCommonJS(index_exports);
69
71
 
@@ -165,23 +167,37 @@ function changeOutputKind(changeAddress, network) {
165
167
  function opReturnScript(signalBytes) {
166
168
  return import_btc_signer.Script.encode(["RETURN", signalBytes]);
167
169
  }
168
- async function fetchSpendableUtxo(bitcoinAddress, bitcoin) {
169
- const utxos = await bitcoin.rest.address.getUtxos(bitcoinAddress);
170
+ var SPENDABLE_DUST_LIMIT_SATS = 546;
171
+ function byDepthThenId(a, b) {
172
+ if (a.status.block_height !== b.status.block_height) {
173
+ return a.status.block_height - b.status.block_height;
174
+ }
175
+ const txidOrder = a.txid.localeCompare(b.txid);
176
+ return txidOrder !== 0 ? txidOrder : a.vout - b.vout;
177
+ }
178
+ function selectSpendableUtxo(utxos, address) {
170
179
  if (!utxos.length) {
171
180
  throw new BeaconError(
172
181
  "No UTXOs found, please fund address!",
173
182
  "UNFUNDED_BEACON_ADDRESS",
174
- { address: bitcoinAddress }
183
+ { address }
175
184
  );
176
185
  }
177
- const utxo = utxos.sort((a, b) => b.status.block_height - a.status.block_height).shift();
178
- if (!utxo) {
186
+ const confirmed = utxos.filter((utxo) => utxo.status.confirmed === true);
187
+ const spendable = confirmed.filter((utxo) => utxo.value > SPENDABLE_DUST_LIMIT_SATS);
188
+ if (!spendable.length) {
189
+ const reason = confirmed.length === 0 ? `all ${utxos.length} UTXO(s) are unconfirmed` : `all ${confirmed.length} confirmed UTXO(s) are at or below the ${SPENDABLE_DUST_LIMIT_SATS}-sat dust limit`;
179
190
  throw new BeaconError(
180
- "Beacon bitcoin address unfunded or utxos unconfirmed.",
181
- "UNFUNDED_BEACON_ADDRESS",
182
- { address: bitcoinAddress }
191
+ `No spendable UTXO at beacon address: ${reason}.`,
192
+ "NO_SPENDABLE_BEACON_UTXO",
193
+ { address, total: utxos.length, confirmed: confirmed.length, dustLimit: SPENDABLE_DUST_LIMIT_SATS }
183
194
  );
184
195
  }
196
+ return [...spendable].sort(byDepthThenId)[0];
197
+ }
198
+ async function fetchSpendableUtxo(bitcoinAddress, bitcoin) {
199
+ const utxos = await bitcoin.rest.address.getUtxos(bitcoinAddress);
200
+ const utxo = selectSpendableUtxo(utxos, bitcoinAddress);
185
201
  const prevTxHex = await bitcoin.rest.transaction.getHex(utxo.txid);
186
202
  return { utxo, prevTxBytes: (0, import_utils.hexToBytes)(prevTxHex) };
187
203
  }
@@ -844,18 +860,19 @@ var Identifier = class _Identifier {
844
860
  * @returns {string} The new did:btcr2 identifier.
845
861
  */
846
862
  static encode(genesisBytes, options) {
847
- const { idType, version = 1, network } = options;
863
+ const { idType, version = 1, network = "bitcoin" } = options;
848
864
  if (!(idType in import_common6.IdentifierTypes)) {
849
865
  throw new import_common6.IdentifierError('Expected "idType" to be "KEY" or "EXTERNAL"', import_common6.INVALID_DID, { idType });
850
866
  }
851
- if (isNaN(version) || version > 1) {
867
+ if (version !== 1) {
852
868
  throw new import_common6.IdentifierError('Expected "version" to be 1', import_common6.INVALID_DID, { version });
853
869
  }
854
- if (typeof network === "string" && !(network in import_common6.BitcoinNetworkNames)) {
855
- throw new import_common6.IdentifierError('Invalid "network" name', import_common6.INVALID_DID, { network });
870
+ if (typeof network !== "string") {
871
+ throw new import_common6.IdentifierError('Expected "network" to be a known network name', import_common6.INVALID_DID, { network });
856
872
  }
857
- if (typeof network === "number" && (network < 0 || network > 8)) {
858
- throw new import_common6.IdentifierError('Invalid "network" number', import_common6.INVALID_DID, { network });
873
+ const networkValue = import_common6.BitcoinNetworkNames[network];
874
+ if (networkValue === void 0) {
875
+ throw new import_common6.IdentifierError('Invalid "network" name', import_common6.INVALID_DID, { network });
859
876
  }
860
877
  if (idType === "KEY") {
861
878
  try {
@@ -867,28 +884,16 @@ var Identifier = class _Identifier {
867
884
  { genesisBytes }
868
885
  );
869
886
  }
887
+ } else if (genesisBytes.length !== 32) {
888
+ throw new import_common6.IdentifierError(
889
+ 'Expected "genesisBytes" to be a 32-byte hash for EXTERNAL identifiers',
890
+ import_common6.INVALID_DID,
891
+ { genesisBytes }
892
+ );
870
893
  }
871
894
  const hrp = idType === "KEY" ? "k" : "x";
872
- const nibbles = [];
873
- const fCount = Math.floor((version - 1) / 15);
874
- for (let i = 0; i < fCount; i++) {
875
- nibbles.push(15);
876
- }
877
- nibbles.push((version - 1) % 15);
878
- if (typeof network === "string") {
879
- nibbles.push(import_common6.BitcoinNetworkNames[network]);
880
- } else if (typeof network === "number") {
881
- nibbles.push(network + 11);
882
- }
883
- if (nibbles.length % 2 !== 0) {
884
- nibbles.push(0);
885
- }
886
- if (fCount !== 0) {
887
- for (const index in Array.from({ length: nibbles.length / 2 - 1 })) {
888
- throw new import_common6.IdentifierError("Not implemented", "NOT_IMPLEMENTED", { index });
889
- }
890
- }
891
- const dataBytes = new Uint8Array([nibbles[2 * 0] << 4 | nibbles[2 * 0 + 1], ...genesisBytes]);
895
+ const firstByte = version - 1 << 4 | networkValue;
896
+ const dataBytes = new Uint8Array([firstByte, ...genesisBytes]);
892
897
  return `did:btcr2:${import_base.bech32m.encodeFromBytes(hrp, dataBytes)}`;
893
898
  }
894
899
  /**
@@ -918,53 +923,34 @@ var Identifier = class _Identifier {
918
923
  if (!["x", "k"].includes(hrp)) {
919
924
  throw new import_common6.IdentifierError(`Invalid hrp: ${hrp}`, import_common6.INVALID_DID, { identifier });
920
925
  }
921
- if (!dataBytes) {
926
+ if (!dataBytes || dataBytes.length < 1) {
922
927
  throw new import_common6.IdentifierError(`Failed to decode id: ${encoded}`, import_common6.INVALID_DID, { identifier });
923
928
  }
924
929
  const idType = hrp === "k" ? "KEY" : "EXTERNAL";
925
- let version = 1;
926
- let byteIndex = 0;
927
- let nibblesConsumed = 0;
928
- let currentByte = dataBytes[byteIndex];
929
- let versionNibble = currentByte >>> 4;
930
- while (versionNibble === 15) {
931
- version += 15;
932
- if (nibblesConsumed % 2 === 0) {
933
- versionNibble = currentByte & 15;
934
- } else {
935
- currentByte = dataBytes[++byteIndex];
936
- versionNibble = currentByte >>> 4;
937
- }
938
- nibblesConsumed += 1;
939
- if (version > 1) {
940
- throw new import_common6.IdentifierError(`Invalid version: ${version}`, import_common6.INVALID_DID, { identifier });
941
- }
942
- }
943
- version += versionNibble;
944
- nibblesConsumed += 1;
945
- let networkValue = nibblesConsumed % 2 === 0 ? dataBytes[++byteIndex] >>> 4 : currentByte & 15;
946
- nibblesConsumed += 1;
947
- let network = import_common6.BitcoinNetworkNames[networkValue];
948
- if (!network) {
949
- if (networkValue >= 8 && networkValue <= 15) {
950
- network = networkValue - 11;
951
- } else {
952
- throw new import_common6.IdentifierError(`Invalid did: ${identifier}`, import_common6.INVALID_DID, { identifier });
953
- }
954
- }
955
- if (nibblesConsumed % 2 === 1) {
956
- const fillerNibble = currentByte & 15;
957
- if (fillerNibble !== 0) {
958
- throw new import_common6.IdentifierError(`Invalid did: ${identifier}`, import_common6.INVALID_DID, { identifier });
959
- }
930
+ const btcr2Version = dataBytes[0] >>> 4;
931
+ if (btcr2Version !== 0) {
932
+ throw new import_common6.IdentifierError(`Invalid btcr2_version (expected 0): ${btcr2Version}`, import_common6.INVALID_DID, { identifier });
933
+ }
934
+ const version = 1;
935
+ const networkValue = dataBytes[0] & 15;
936
+ const networkName = import_common6.BitcoinNetworkNames[networkValue];
937
+ let network;
938
+ if (typeof networkName === "string") {
939
+ network = networkName;
940
+ } else if (networkValue >= 12 && networkValue <= 14) {
941
+ network = networkValue - 11;
942
+ } else {
943
+ throw new import_common6.IdentifierError(`Invalid network: ${networkValue}`, import_common6.INVALID_DID, { identifier });
960
944
  }
961
- const genesisBytes = dataBytes.slice(byteIndex + 1);
945
+ const genesisBytes = dataBytes.slice(1);
962
946
  if (idType === "KEY") {
963
947
  try {
964
948
  new import_keypair.CompressedSecp256k1PublicKey(genesisBytes);
965
949
  } catch {
966
950
  throw new import_common6.IdentifierError(`Invalid genesisBytes: ${genesisBytes}`, import_common6.INVALID_DID, { identifier });
967
951
  }
952
+ } else if (genesisBytes.length !== 32) {
953
+ throw new import_common6.IdentifierError(`Invalid genesisBytes: ${genesisBytes}`, import_common6.INVALID_DID, { identifier });
968
954
  }
969
955
  return { idType, hrp, version, network, genesisBytes };
970
956
  }
@@ -2735,6 +2721,7 @@ var DidDocumentBuilder = class {
2735
2721
  SINGLETON_BEACON_TX_VSIZE,
2736
2722
  SMTBeacon,
2737
2723
  SMTBeaconError,
2724
+ SPENDABLE_DUST_LIMIT_SATS,
2738
2725
  SinglePartyBeacon,
2739
2726
  SingletonBeacon,
2740
2727
  SingletonBeaconError,
@@ -2748,5 +2735,6 @@ var DidDocumentBuilder = class {
2748
2735
  isMultikeyVerificationMethod,
2749
2736
  opReturnScript,
2750
2737
  resolveBtcr2SenderPk,
2751
- resolveChangeAddress
2738
+ resolveChangeAddress,
2739
+ selectSpendableUtxo
2752
2740
  });
@@ -146,18 +146,84 @@ export function opReturnScript(signalBytes) {
146
146
  return Script.encode(['RETURN', signalBytes]);
147
147
  }
148
148
  /**
149
- * Fetch the most recent confirmed UTXO at `bitcoinAddress` + the raw bytes of its
150
- * parent transaction (needed by PSBT inputs). Throws if unfunded.
149
+ * Minimum value (sats) a beacon UTXO must exceed for {@link selectSpendableUtxo} to
150
+ * treat it as spendable. This is a fixed, conservative, script-kind-agnostic floor:
151
+ * an output at or below it is too small to be worth spending, so selection discards
152
+ * it in favor of a larger confirmed UTXO. Keeping the floor a constant (rather than
153
+ * deriving it from a fee estimate) keeps selection pure and fee-estimator-independent.
154
+ *
155
+ * The floor is a coarse pre-filter, not the fee-coverage boundary: whether a selected
156
+ * UTXO actually covers the transaction fee is a separate check, enforced against the
157
+ * live {@link FeeEstimator} by the builders' `value <= feeSats` guard
158
+ * ({@link SinglePartyBeacon.buildSinglePartyTx} and {@link buildAggregationBeaconTx}).
159
+ * At the default 5 sat/vB rate that fee (roughly 775 to 1200 sats across the three
160
+ * script kinds) sits above this floor, so a UTXO can clear the dust filter and still
161
+ * be rejected as insufficient; conversely, at a very low fee rate an output near the
162
+ * floor could cover the fee. The floor's job is only to skip trivially small inputs.
163
+ *
164
+ * The value is the standard Bitcoin Core P2PKH dust threshold, the largest of the
165
+ * three singleton beacon script kinds (P2PKH 546, P2TR 330, P2WPKH 294 per
166
+ * {@link DUST_LIMIT_SATS}): a UTXO above it is non-dust under any beacon address kind.
167
+ * Distinct from {@link DUST_LIMIT_SATS}, which sizes the outgoing change output by
168
+ * kind; this bounds the incoming UTXO chosen to fund the transaction.
151
169
  */
152
- async function fetchSpendableUtxo(bitcoinAddress, bitcoin) {
153
- const utxos = await bitcoin.rest.address.getUtxos(bitcoinAddress);
170
+ export const SPENDABLE_DUST_LIMIT_SATS = 546;
171
+ /**
172
+ * Deterministic ordering for spendable UTXO selection: deepest first (ascending
173
+ * block height, so the most-confirmed UTXO sorts first), tie-broken by `txid` then
174
+ * `vout`. The tie-break makes the winner independent of the order the REST API
175
+ * returns UTXOs in, so retries and independent resolvers converge on the same input.
176
+ */
177
+ function byDepthThenId(a, b) {
178
+ if (a.status.block_height !== b.status.block_height) {
179
+ return a.status.block_height - b.status.block_height;
180
+ }
181
+ const txidOrder = a.txid.localeCompare(b.txid);
182
+ return txidOrder !== 0 ? txidOrder : a.vout - b.vout;
183
+ }
184
+ /**
185
+ * Select the beacon UTXO to fund a signal transaction from the set of UTXOs at a
186
+ * beacon address. Pure and deterministic: the same address state always yields the
187
+ * same input, across broadcast retries and across independent resolvers.
188
+ *
189
+ * Filters to confirmed UTXOs (an unconfirmed input is reorg- and RBF-unsafe: a
190
+ * signal built on it can be orphaned or double-spent before it confirms), then drops
191
+ * dust at or below {@link SPENDABLE_DUST_LIMIT_SATS}, then picks the deepest via
192
+ * {@link byDepthThenId}. The did:btcr2 spec does not mandate a selection rule or a
193
+ * confirmation depth (only the security considerations favor deeper confirmations),
194
+ * so this is an implementation policy: prefer safety and reproducibility over
195
+ * spending the newest or largest output.
196
+ *
197
+ * @param utxos UTXOs reported at the beacon address.
198
+ * @param address Beacon address, used only to annotate thrown errors.
199
+ * @returns The confirmed, non-dust, deepest UTXO.
200
+ * @throws {BeaconError} `UNFUNDED_BEACON_ADDRESS` when no UTXOs exist at all;
201
+ * `NO_SPENDABLE_BEACON_UTXO` when UTXOs exist but none are both confirmed and above
202
+ * the dust limit (the message distinguishes all-unconfirmed from all-dust).
203
+ */
204
+ export function selectSpendableUtxo(utxos, address) {
154
205
  if (!utxos.length) {
155
- throw new BeaconError('No UTXOs found, please fund address!', 'UNFUNDED_BEACON_ADDRESS', { address: bitcoinAddress });
206
+ throw new BeaconError('No UTXOs found, please fund address!', 'UNFUNDED_BEACON_ADDRESS', { address });
156
207
  }
157
- const utxo = utxos.sort((a, b) => b.status.block_height - a.status.block_height).shift();
158
- if (!utxo) {
159
- throw new BeaconError('Beacon bitcoin address unfunded or utxos unconfirmed.', 'UNFUNDED_BEACON_ADDRESS', { address: bitcoinAddress });
208
+ const confirmed = utxos.filter(utxo => utxo.status.confirmed === true);
209
+ const spendable = confirmed.filter(utxo => utxo.value > SPENDABLE_DUST_LIMIT_SATS);
210
+ if (!spendable.length) {
211
+ const reason = confirmed.length === 0
212
+ ? `all ${utxos.length} UTXO(s) are unconfirmed`
213
+ : `all ${confirmed.length} confirmed UTXO(s) are at or below the ${SPENDABLE_DUST_LIMIT_SATS}-sat dust limit`;
214
+ throw new BeaconError(`No spendable UTXO at beacon address: ${reason}.`, 'NO_SPENDABLE_BEACON_UTXO', { address, total: utxos.length, confirmed: confirmed.length, dustLimit: SPENDABLE_DUST_LIMIT_SATS });
160
215
  }
216
+ return [...spendable].sort(byDepthThenId)[0];
217
+ }
218
+ /**
219
+ * Fetch the deepest confirmed, non-dust spendable UTXO at `bitcoinAddress` plus the
220
+ * raw bytes of its parent transaction (needed by PSBT inputs). Selection is delegated
221
+ * to {@link selectSpendableUtxo}; throws {@link BeaconError} when the address is
222
+ * unfunded or has no confirmed, non-dust UTXO.
223
+ */
224
+ async function fetchSpendableUtxo(bitcoinAddress, bitcoin) {
225
+ const utxos = await bitcoin.rest.address.getUtxos(bitcoinAddress);
226
+ const utxo = selectSpendableUtxo(utxos, bitcoinAddress);
161
227
  const prevTxHex = await bitcoin.rest.transaction.getHex(utxo.txid);
162
228
  return { utxo, prevTxBytes: hexToBytes(prevTxHex) };
163
229
  }
@@ -1 +1 @@
1
- {"version":3,"file":"beacon.js","sourceRoot":"","sources":["../../../../src/core/beacon/beacon.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG1G,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAY3D;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAExC;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAEzC,iEAAiE;AACjE,MAAM,CAAC,MAAM,yBAAyB,GAAkD;IACtF,KAAK,EAAI,qBAAqB;IAC9B,MAAM,EAAG,sBAAsB;IAC/B,IAAI,EAAK,oBAAoB;CAC9B,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAkD;IACjF,KAAK,EAAI,EAAE;IACX,MAAM,EAAG,EAAE;IACX,IAAI,EAAK,EAAE;CACZ,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAkD;IAC5E,KAAK,EAAI,GAAG;IACZ,MAAM,EAAG,GAAG;IACZ,IAAI,EAAK,GAAG;CACb,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa,CAC3B,UAA+B,EAC/B,UAA+B;IAE/B,MAAM,IAAI,GAAG,yBAAyB,CAAC,UAAU,CAAC,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAA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