@did-btcr2/method 0.49.0 → 0.51.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/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,
@@ -60,10 +61,12 @@ __export(index_exports, {
60
61
  deriveSingletonAddress: () => deriveSingletonAddress,
61
62
  detectSingletonScriptKind: () => detectSingletonScriptKind,
62
63
  extractOpReturnSignal: () => extractOpReturnSignal,
64
+ getAggregationCommunicationKey: () => getAggregationCommunicationKey,
63
65
  isMultikeyVerificationMethod: () => isMultikeyVerificationMethod,
64
66
  opReturnScript: () => opReturnScript,
65
67
  resolveBtcr2SenderPk: () => resolveBtcr2SenderPk,
66
- resolveChangeAddress: () => resolveChangeAddress
68
+ resolveChangeAddress: () => resolveChangeAddress,
69
+ selectSpendableUtxo: () => selectSpendableUtxo
67
70
  });
68
71
  module.exports = __toCommonJS(index_exports);
69
72
 
@@ -165,23 +168,37 @@ function changeOutputKind(changeAddress, network) {
165
168
  function opReturnScript(signalBytes) {
166
169
  return import_btc_signer.Script.encode(["RETURN", signalBytes]);
167
170
  }
168
- async function fetchSpendableUtxo(bitcoinAddress, bitcoin) {
169
- const utxos = await bitcoin.rest.address.getUtxos(bitcoinAddress);
171
+ var SPENDABLE_DUST_LIMIT_SATS = 546;
172
+ function byDepthThenId(a, b) {
173
+ if (a.status.block_height !== b.status.block_height) {
174
+ return a.status.block_height - b.status.block_height;
175
+ }
176
+ const txidOrder = a.txid.localeCompare(b.txid);
177
+ return txidOrder !== 0 ? txidOrder : a.vout - b.vout;
178
+ }
179
+ function selectSpendableUtxo(utxos, address) {
170
180
  if (!utxos.length) {
171
181
  throw new BeaconError(
172
182
  "No UTXOs found, please fund address!",
173
183
  "UNFUNDED_BEACON_ADDRESS",
174
- { address: bitcoinAddress }
184
+ { address }
175
185
  );
176
186
  }
177
- const utxo = utxos.sort((a, b) => b.status.block_height - a.status.block_height).shift();
178
- if (!utxo) {
187
+ const confirmed = utxos.filter((utxo) => utxo.status.confirmed === true);
188
+ const spendable = confirmed.filter((utxo) => utxo.value > SPENDABLE_DUST_LIMIT_SATS);
189
+ if (!spendable.length) {
190
+ 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
191
  throw new BeaconError(
180
- "Beacon bitcoin address unfunded or utxos unconfirmed.",
181
- "UNFUNDED_BEACON_ADDRESS",
182
- { address: bitcoinAddress }
192
+ `No spendable UTXO at beacon address: ${reason}.`,
193
+ "NO_SPENDABLE_BEACON_UTXO",
194
+ { address, total: utxos.length, confirmed: confirmed.length, dustLimit: SPENDABLE_DUST_LIMIT_SATS }
183
195
  );
184
196
  }
197
+ return [...spendable].sort(byDepthThenId)[0];
198
+ }
199
+ async function fetchSpendableUtxo(bitcoinAddress, bitcoin) {
200
+ const utxos = await bitcoin.rest.address.getUtxos(bitcoinAddress);
201
+ const utxo = selectSpendableUtxo(utxos, bitcoinAddress);
185
202
  const prevTxHex = await bitcoin.rest.transaction.getHex(utxo.txid);
186
203
  return { utxo, prevTxBytes: (0, import_utils.hexToBytes)(prevTxHex) };
187
204
  }
@@ -1269,23 +1286,15 @@ var BeaconSignalDiscovery = class {
1269
1286
  };
1270
1287
 
1271
1288
  // src/core/did-sender-resolver.ts
1272
- var import_keypair2 = require("@did-btcr2/keypair");
1273
- function resolveBtcr2SenderPk(did) {
1274
- try {
1275
- const components = Identifier.decode(did);
1276
- if (components.idType === "KEY") {
1277
- return new import_keypair2.CompressedSecp256k1PublicKey(components.genesisBytes);
1278
- }
1279
- } catch {
1280
- }
1281
- return void 0;
1282
- }
1289
+ var import_common13 = require("@did-btcr2/common");
1290
+ var import_cryptosuite3 = require("@did-btcr2/cryptosuite");
1291
+ var import_keypair4 = require("@did-btcr2/keypair");
1283
1292
 
1284
1293
  // src/core/resolver.ts
1285
1294
  var import_bitcoin5 = require("@did-btcr2/bitcoin");
1286
1295
  var import_common12 = require("@did-btcr2/common");
1287
1296
  var import_cryptosuite2 = require("@did-btcr2/cryptosuite");
1288
- var import_keypair4 = require("@did-btcr2/keypair");
1297
+ var import_keypair3 = require("@did-btcr2/keypair");
1289
1298
 
1290
1299
  // src/did-btcr2.ts
1291
1300
  var import_common11 = require("@did-btcr2/common");
@@ -1298,7 +1307,7 @@ var import_cryptosuite = require("@did-btcr2/cryptosuite");
1298
1307
  // src/utils/did-document.ts
1299
1308
  var import_bitcoin4 = require("@did-btcr2/bitcoin");
1300
1309
  var import_common9 = require("@did-btcr2/common");
1301
- var import_keypair3 = require("@did-btcr2/keypair");
1310
+ var import_keypair2 = require("@did-btcr2/keypair");
1302
1311
  var import_utils4 = require("@web5/dids/utils");
1303
1312
  var import_btc_signer3 = require("@scure/btc-signer");
1304
1313
  var BTCR2_DID_DOCUMENT_CONTEXT = [
@@ -1636,7 +1645,7 @@ var GenesisDocument = class _GenesisDocument extends DidDocument {
1636
1645
  * @returns {GenesisDocument} A new GenesisDocument with the placeholder ID.
1637
1646
  */
1638
1647
  static fromPublicKey(publicKey, network) {
1639
- const pk = new import_keypair3.CompressedSecp256k1PublicKey(publicKey);
1648
+ const pk = new import_keypair2.CompressedSecp256k1PublicKey(publicKey);
1640
1649
  const id = ID_PLACEHOLDER_VALUE;
1641
1650
  const address = (0, import_btc_signer3.p2pkh)(pk.compressed, (0, import_bitcoin4.getNetwork)(network)).address;
1642
1651
  const services = [{
@@ -2196,7 +2205,7 @@ var Resolver = class _Resolver {
2196
2205
  static deterministic(didComponents) {
2197
2206
  const genesisBytes = didComponents.genesisBytes;
2198
2207
  const did = Identifier.encode(genesisBytes, didComponents);
2199
- const { multibase } = new import_keypair4.CompressedSecp256k1PublicKey(genesisBytes);
2208
+ const { multibase } = new import_keypair3.CompressedSecp256k1PublicKey(genesisBytes);
2200
2209
  const service = BeaconUtils.generateBeaconServices({
2201
2210
  id: did,
2202
2211
  publicKey: genesisBytes,
@@ -2619,13 +2628,48 @@ var Resolver = class _Resolver {
2619
2628
  }
2620
2629
  };
2621
2630
 
2631
+ // src/core/did-sender-resolver.ts
2632
+ function getAggregationCommunicationKey(document) {
2633
+ const invocation = document.capabilityInvocation?.[0];
2634
+ if (invocation === void 0) {
2635
+ throw new import_common13.DidDocumentError(
2636
+ "Cannot derive aggregation communication key: capabilityInvocation is absent",
2637
+ import_common13.INVALID_DID_DOCUMENT,
2638
+ { id: document.id }
2639
+ );
2640
+ }
2641
+ const vm = typeof invocation === "string" ? document.verificationMethod?.find((method) => method.id === invocation) : invocation;
2642
+ if (!vm) {
2643
+ throw new import_common13.DidDocumentError(
2644
+ `Cannot derive aggregation communication key: capabilityInvocation[0] "${invocation}" does not resolve to a verification method`,
2645
+ import_common13.INVALID_DID_DOCUMENT,
2646
+ { id: document.id, invocation }
2647
+ );
2648
+ }
2649
+ return import_cryptosuite3.SchnorrMultikey.fromVerificationMethod(vm).publicKey;
2650
+ }
2651
+ function resolveBtcr2SenderPk(did, opts) {
2652
+ try {
2653
+ const components = Identifier.decode(did);
2654
+ if (components.idType === "KEY") {
2655
+ return new import_keypair4.CompressedSecp256k1PublicKey(components.genesisBytes);
2656
+ }
2657
+ if (opts?.genesisDocument) {
2658
+ const document = Resolver.external(components, opts.genesisDocument);
2659
+ return getAggregationCommunicationKey(document);
2660
+ }
2661
+ } catch {
2662
+ }
2663
+ return void 0;
2664
+ }
2665
+
2622
2666
  // src/utils/did-document-builder.ts
2623
- var import_common13 = require("@did-btcr2/common");
2667
+ var import_common14 = require("@did-btcr2/common");
2624
2668
  var DidDocumentBuilder = class {
2625
2669
  document = {};
2626
2670
  constructor(initialDocument) {
2627
2671
  if (!initialDocument.id) {
2628
- throw new import_common13.DidDocumentError('Missing required "id" property', import_common13.INVALID_DID_DOCUMENT, initialDocument);
2672
+ throw new import_common14.DidDocumentError('Missing required "id" property', import_common14.INVALID_DID_DOCUMENT, initialDocument);
2629
2673
  }
2630
2674
  this.document.id = initialDocument.id;
2631
2675
  this.document.verificationMethod = initialDocument.verificationMethod ?? [];
@@ -2705,6 +2749,7 @@ var DidDocumentBuilder = class {
2705
2749
  SINGLETON_BEACON_TX_VSIZE,
2706
2750
  SMTBeacon,
2707
2751
  SMTBeaconError,
2752
+ SPENDABLE_DUST_LIMIT_SATS,
2708
2753
  SinglePartyBeacon,
2709
2754
  SingletonBeacon,
2710
2755
  SingletonBeaconError,
@@ -2715,8 +2760,10 @@ var DidDocumentBuilder = class {
2715
2760
  deriveSingletonAddress,
2716
2761
  detectSingletonScriptKind,
2717
2762
  extractOpReturnSignal,
2763
+ getAggregationCommunicationKey,
2718
2764
  isMultikeyVerificationMethod,
2719
2765
  opReturnScript,
2720
2766
  resolveBtcr2SenderPk,
2721
- resolveChangeAddress
2767
+ resolveChangeAddress,
2768
+ selectSpendableUtxo
2722
2769
  });
@@ -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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AC,CAAC;QAEvE,OAAO;YACL,EAAE;YACF,cAAc,EAAG,CAAC,aAAa,CAAC;YAChC,aAAa,EAAI,CAAC,MAAM,CAAC;YACzB,aAAa,EAAI,IAAI,CAAC,aAAa;YACnC,aAAa;YACb,IAAI,EAAa,IAAI,CAAC,IAAI;YAC1B,OAAO;YACP,UAAU,EAAO,IAAI;SACtB,CAAC;IACJ,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,iBAAiB,CAAC,IAAkB,EAAE,MAAc;QAClE,OAAO,kBAAkB,CACvB,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,EACnC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAE,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAE,CAChD,CAAC;IACJ,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,cAAc,CAAC,OAA0B,EAAE,MAAc;QACvE,OAAO,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;CACF"}
@@ -1,25 +1,90 @@
1
+ import { DidDocumentError, INVALID_DID_DOCUMENT } from '@did-btcr2/common';
2
+ import { SchnorrMultikey } from '@did-btcr2/cryptosuite';
1
3
  import { CompressedSecp256k1PublicKey } from '@did-btcr2/keypair';
2
4
  import { Identifier } from './identifier.js';
5
+ import { Resolver } from './resolver.js';
6
+ /**
7
+ * Derive the aggregation communication public key from a resolved did:btcr2 DID Document.
8
+ *
9
+ * The communication key is the verification method referenced by
10
+ * `capabilityInvocation[0]`, resolved to its public key. This is the exact relationship
11
+ * the method already enforces for DID updates (construct and sign require the signing
12
+ * method to be in `capabilityInvocation`, the update proof is built and verified with
13
+ * `proofPurpose: 'capabilityInvocation'`), so binding the transport communication key to
14
+ * it yields the invariant "transport-authenticated as D implies authorized to update D."
15
+ * For a KEY (`k1`) document the single deterministic key is already the sole
16
+ * `capabilityInvocation` entry, so this is a no-op for KEY DIDs.
17
+ *
18
+ * There is deliberately no `verificationMethod[0]` fallback: a document without
19
+ * `capabilityInvocation` cannot be updated at all, so it is useless for aggregation and is
20
+ * rejected here rather than bound to an unrelated key.
21
+ *
22
+ * @param {DidDocument} document The resolved DID Document (placeholder id already replaced).
23
+ * @returns {CompressedSecp256k1PublicKey} The compressed public key of the communication method.
24
+ * @throws {DidDocumentError} If `capabilityInvocation` is absent or its first entry does not
25
+ * resolve to a verification method in the document.
26
+ */
27
+ export function getAggregationCommunicationKey(document) {
28
+ const invocation = document.capabilityInvocation?.[0];
29
+ if (invocation === undefined) {
30
+ throw new DidDocumentError('Cannot derive aggregation communication key: capabilityInvocation is absent', INVALID_DID_DOCUMENT, { id: document.id });
31
+ }
32
+ // Resolve capabilityInvocation[0] to a verification method: a string reference is
33
+ // dereferenced by id against verificationMethod; an embedded method is used directly.
34
+ // A local id lookup is used rather than getSigningMethod, which defaults to #initialKey
35
+ // and does not resolve embedded methods.
36
+ const vm = typeof invocation === 'string'
37
+ ? document.verificationMethod?.find(method => method.id === invocation)
38
+ : invocation;
39
+ if (!vm) {
40
+ throw new DidDocumentError(`Cannot derive aggregation communication key: capabilityInvocation[0] "${invocation}" `
41
+ + 'does not resolve to a verification method', INVALID_DID_DOCUMENT, { id: document.id, invocation });
42
+ }
43
+ return SchnorrMultikey.fromVerificationMethod(vm).publicKey;
44
+ }
3
45
  /**
4
46
  * Resolve a did:btcr2 sender's communication public key from its DID, for the
5
- * aggregation HTTP transport's `resolveSenderPk` option: a KEY identifier decodes to
6
- * its genesis public key. The aggregation transport is DID-method-agnostic and does
7
- * not name `Identifier`; method supplies this resolver when it wires the transport so
8
- * a sender that is not a pre-registered peer can still be authenticated from its DID.
47
+ * aggregation HTTP transport's `resolveSenderPk` option.
48
+ *
49
+ * A KEY (`k1`) identifier decodes directly to its genesis public key: the DID string is
50
+ * the key. An EXTERNAL (`x1`) identifier is a commitment to the hash of a genesis
51
+ * document, so there is no key in the DID string. When the genesis document is supplied
52
+ * in-band (via `opts.genesisDocument`), it is self-verifying against the DID: `Resolver`'s
53
+ * external path recomputes its canonical hash, compares it to the identifier's genesis
54
+ * bytes (throwing on mismatch), and resolves it, after which the communication key is
55
+ * derived from `capabilityInvocation[0]` ({@link getAggregationCommunicationKey}). Without
56
+ * a genesis document, an `x1` DID still resolves to `undefined`, so callers that pass no
57
+ * second argument behave exactly as before.
9
58
  *
10
- * @param did The sender's DID.
11
- * @returns The sender's compressed public key, or `undefined` when the DID is not a
12
- * decodable did:btcr2 KEY identifier (resolution then falls back to registered peers).
59
+ * The aggregation transport is DID-method-agnostic and does not name `Identifier`; method
60
+ * supplies this resolver when it wires the transport so a sender that is not a
61
+ * pre-registered peer can still be authenticated from its DID.
62
+ *
63
+ * @param {string} did The sender's DID.
64
+ * @param {object} [opts] Optional resolution inputs.
65
+ * @param {object} [opts.genesisDocument] The `x1` sender's genesis document, carried in-band
66
+ * on the bootstrap opt-in. Ignored for KEY identifiers.
67
+ * @returns {CompressedSecp256k1PublicKey | undefined} The sender's compressed public key, or
68
+ * `undefined` when the DID is not a decodable did:btcr2 identifier, is an `x1` identifier
69
+ * with no (or a non-matching) genesis document, or has no usable communication key.
13
70
  */
14
- export function resolveBtcr2SenderPk(did) {
71
+ export function resolveBtcr2SenderPk(did, opts) {
15
72
  try {
16
73
  const components = Identifier.decode(did);
17
74
  if (components.idType === 'KEY') {
18
75
  return new CompressedSecp256k1PublicKey(components.genesisBytes);
19
76
  }
77
+ // EXTERNAL (x1): the DID commits to the hash of a genesis document. With the genesis
78
+ // supplied in-band, verify it hashes to the DID and derive the communication key from
79
+ // it; without it, there is no key to return.
80
+ if (opts?.genesisDocument) {
81
+ const document = Resolver.external(components, opts.genesisDocument);
82
+ return getAggregationCommunicationKey(document);
83
+ }
20
84
  }
21
85
  catch {
22
- // Not a decodable did:btcr2 KEY identifier.
86
+ // Not a decodable did:btcr2 identifier, the genesis does not hash to the DID, or the
87
+ // document has no usable capabilityInvocation communication key.
23
88
  }
24
89
  return undefined;
25
90
  }
@@ -1 +1 @@
1
- {"version":3,"file":"did-sender-resolver.js","sourceRoot":"","sources":["../../../src/core/did-sender-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1C,IAAG,UAAU,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;YAC/B,OAAO,IAAI,4BAA4B,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,4CAA4C;IAC9C,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
1
+ {"version":3,"file":"did-sender-resolver.js","sourceRoot":"","sources":["../../../src/core/did-sender-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAElE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,8BAA8B,CAC5C,QAAqB;IAErB,MAAM,UAAU,GAAG,QAAQ,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAC,CAAC;IACtD,IAAG,UAAU,KAAK,SAAS,EAAE,CAAC;QAC5B,MAAM,IAAI,gBAAgB,CACxB,6EAA6E,EAC7E,oBAAoB,EAAE,EAAE,EAAE,EAAE,QAAQ,CAAC,EAA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+138,50 @@ export interface BeaconTxPlan {
138
138
  * non-standard and rejected at broadcast with `RPC error -26: scriptpubkey`.
139
139
  */
140
140
  export declare function opReturnScript(signalBytes: Uint8Array): Uint8Array;
141
+ /**
142
+ * Minimum value (sats) a beacon UTXO must exceed for {@link selectSpendableUtxo} to
143
+ * treat it as spendable. This is a fixed, conservative, script-kind-agnostic floor:
144
+ * an output at or below it is too small to be worth spending, so selection discards
145
+ * it in favor of a larger confirmed UTXO. Keeping the floor a constant (rather than
146
+ * deriving it from a fee estimate) keeps selection pure and fee-estimator-independent.
147
+ *
148
+ * The floor is a coarse pre-filter, not the fee-coverage boundary: whether a selected
149
+ * UTXO actually covers the transaction fee is a separate check, enforced against the
150
+ * live {@link FeeEstimator} by the builders' `value <= feeSats` guard
151
+ * ({@link SinglePartyBeacon.buildSinglePartyTx} and {@link buildAggregationBeaconTx}).
152
+ * At the default 5 sat/vB rate that fee (roughly 775 to 1200 sats across the three
153
+ * script kinds) sits above this floor, so a UTXO can clear the dust filter and still
154
+ * be rejected as insufficient; conversely, at a very low fee rate an output near the
155
+ * floor could cover the fee. The floor's job is only to skip trivially small inputs.
156
+ *
157
+ * The value is the standard Bitcoin Core P2PKH dust threshold, the largest of the
158
+ * three singleton beacon script kinds (P2PKH 546, P2TR 330, P2WPKH 294 per
159
+ * {@link DUST_LIMIT_SATS}): a UTXO above it is non-dust under any beacon address kind.
160
+ * Distinct from {@link DUST_LIMIT_SATS}, which sizes the outgoing change output by
161
+ * kind; this bounds the incoming UTXO chosen to fund the transaction.
162
+ */
163
+ export declare const SPENDABLE_DUST_LIMIT_SATS = 546;
164
+ /**
165
+ * Select the beacon UTXO to fund a signal transaction from the set of UTXOs at a
166
+ * beacon address. Pure and deterministic: the same address state always yields the
167
+ * same input, across broadcast retries and across independent resolvers.
168
+ *
169
+ * Filters to confirmed UTXOs (an unconfirmed input is reorg- and RBF-unsafe: a
170
+ * signal built on it can be orphaned or double-spent before it confirms), then drops
171
+ * dust at or below {@link SPENDABLE_DUST_LIMIT_SATS}, then picks the deepest via
172
+ * {@link byDepthThenId}. The did:btcr2 spec does not mandate a selection rule or a
173
+ * confirmation depth (only the security considerations favor deeper confirmations),
174
+ * so this is an implementation policy: prefer safety and reproducibility over
175
+ * spending the newest or largest output.
176
+ *
177
+ * @param utxos UTXOs reported at the beacon address.
178
+ * @param address Beacon address, used only to annotate thrown errors.
179
+ * @returns The confirmed, non-dust, deepest UTXO.
180
+ * @throws {BeaconError} `UNFUNDED_BEACON_ADDRESS` when no UTXOs exist at all;
181
+ * `NO_SPENDABLE_BEACON_UTXO` when UTXOs exist but none are both confirmed and above
182
+ * the dust limit (the message distinguishes all-unconfirmed from all-dust).
183
+ */
184
+ export declare function selectSpendableUtxo(utxos: Array<AddressUtxo>, address?: string): AddressUtxo;
141
185
  /**
142
186
  * Build an aggregation beacon transaction (P2TR key-path spend) ready for MuSig2 signing.
143
187
  * Returns the unsigned Transaction + prev-output metadata that an aggregation service's
@@ -1 +1 @@
1
- {"version":3,"file":"beacon.d.ts","sourceRoot":"","sources":["../../../../src/core/beacon/beacon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAA4D,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC1G,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBA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AAC;IAkFzB;;;OAGG;cACa,iBAAiB,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAOtF;;OAEG;cACa,cAAc,CAAC,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAG5F"}
@@ -1,14 +1,54 @@
1
1
  import { CompressedSecp256k1PublicKey } from '@did-btcr2/keypair';
2
+ import type { DidDocument } from '../utils/did-document.js';
3
+ /**
4
+ * Derive the aggregation communication public key from a resolved did:btcr2 DID Document.
5
+ *
6
+ * The communication key is the verification method referenced by
7
+ * `capabilityInvocation[0]`, resolved to its public key. This is the exact relationship
8
+ * the method already enforces for DID updates (construct and sign require the signing
9
+ * method to be in `capabilityInvocation`, the update proof is built and verified with
10
+ * `proofPurpose: 'capabilityInvocation'`), so binding the transport communication key to
11
+ * it yields the invariant "transport-authenticated as D implies authorized to update D."
12
+ * For a KEY (`k1`) document the single deterministic key is already the sole
13
+ * `capabilityInvocation` entry, so this is a no-op for KEY DIDs.
14
+ *
15
+ * There is deliberately no `verificationMethod[0]` fallback: a document without
16
+ * `capabilityInvocation` cannot be updated at all, so it is useless for aggregation and is
17
+ * rejected here rather than bound to an unrelated key.
18
+ *
19
+ * @param {DidDocument} document The resolved DID Document (placeholder id already replaced).
20
+ * @returns {CompressedSecp256k1PublicKey} The compressed public key of the communication method.
21
+ * @throws {DidDocumentError} If `capabilityInvocation` is absent or its first entry does not
22
+ * resolve to a verification method in the document.
23
+ */
24
+ export declare function getAggregationCommunicationKey(document: DidDocument): CompressedSecp256k1PublicKey;
2
25
  /**
3
26
  * Resolve a did:btcr2 sender's communication public key from its DID, for the
4
- * aggregation HTTP transport's `resolveSenderPk` option: a KEY identifier decodes to
5
- * its genesis public key. The aggregation transport is DID-method-agnostic and does
6
- * not name `Identifier`; method supplies this resolver when it wires the transport so
7
- * a sender that is not a pre-registered peer can still be authenticated from its DID.
8
- *
9
- * @param did The sender's DID.
10
- * @returns The sender's compressed public key, or `undefined` when the DID is not a
11
- * decodable did:btcr2 KEY identifier (resolution then falls back to registered peers).
27
+ * aggregation HTTP transport's `resolveSenderPk` option.
28
+ *
29
+ * A KEY (`k1`) identifier decodes directly to its genesis public key: the DID string is
30
+ * the key. An EXTERNAL (`x1`) identifier is a commitment to the hash of a genesis
31
+ * document, so there is no key in the DID string. When the genesis document is supplied
32
+ * in-band (via `opts.genesisDocument`), it is self-verifying against the DID: `Resolver`'s
33
+ * external path recomputes its canonical hash, compares it to the identifier's genesis
34
+ * bytes (throwing on mismatch), and resolves it, after which the communication key is
35
+ * derived from `capabilityInvocation[0]` ({@link getAggregationCommunicationKey}). Without
36
+ * a genesis document, an `x1` DID still resolves to `undefined`, so callers that pass no
37
+ * second argument behave exactly as before.
38
+ *
39
+ * The aggregation transport is DID-method-agnostic and does not name `Identifier`; method
40
+ * supplies this resolver when it wires the transport so a sender that is not a
41
+ * pre-registered peer can still be authenticated from its DID.
42
+ *
43
+ * @param {string} did The sender's DID.
44
+ * @param {object} [opts] Optional resolution inputs.
45
+ * @param {object} [opts.genesisDocument] The `x1` sender's genesis document, carried in-band
46
+ * on the bootstrap opt-in. Ignored for KEY identifiers.
47
+ * @returns {CompressedSecp256k1PublicKey | undefined} The sender's compressed public key, or
48
+ * `undefined` when the DID is not a decodable did:btcr2 identifier, is an `x1` identifier
49
+ * with no (or a non-matching) genesis document, or has no usable communication key.
12
50
  */
13
- export declare function resolveBtcr2SenderPk(did: string): CompressedSecp256k1PublicKey | undefined;
51
+ export declare function resolveBtcr2SenderPk(did: string, opts?: {
52
+ genesisDocument?: object;
53
+ }): CompressedSecp256k1PublicKey | undefined;
14
54
  //# sourceMappingURL=did-sender-resolver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"did-sender-resolver.d.ts","sourceRoot":"","sources":["../../../src/core/did-sender-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAGlE;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,4BAA4B,GAAG,SAAS,CAU1F"}
1
+ {"version":3,"file":"did-sender-resolver.d.ts","sourceRoot":"","sources":["../../../src/core/did-sender-resolver.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAyB,MAAM,0BAA0B,CAAC;AAInF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,WAAW,GACpB,4BAA4B,CA0B9B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE;IAAE,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,GAClC,4BAA4B,GAAG,SAAS,CAkB1C"}