@did-btcr2/method 0.36.1 → 0.38.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/.tsbuildinfo +1 -1
- package/dist/browser.js +1149 -126
- package/dist/browser.mjs +1149 -126
- package/dist/cjs/index.js +1244 -208
- package/dist/esm/core/aggregation/beacon-strategy.js +19 -6
- package/dist/esm/core/aggregation/beacon-strategy.js.map +1 -1
- package/dist/esm/core/aggregation/cohort.js +142 -33
- package/dist/esm/core/aggregation/cohort.js.map +1 -1
- package/dist/esm/core/aggregation/conditions.js +27 -0
- package/dist/esm/core/aggregation/conditions.js.map +1 -1
- package/dist/esm/core/aggregation/fallback-spend.js +132 -0
- package/dist/esm/core/aggregation/fallback-spend.js.map +1 -0
- package/dist/esm/core/aggregation/messages/base.js.map +1 -1
- package/dist/esm/core/aggregation/messages/bodies.js +46 -1
- package/dist/esm/core/aggregation/messages/bodies.js.map +1 -1
- package/dist/esm/core/aggregation/messages/constants.js +11 -0
- package/dist/esm/core/aggregation/messages/constants.js.map +1 -1
- package/dist/esm/core/aggregation/messages/factories.js +27 -1
- package/dist/esm/core/aggregation/messages/factories.js.map +1 -1
- package/dist/esm/core/aggregation/messages/guards.js +4 -1
- package/dist/esm/core/aggregation/messages/guards.js.map +1 -1
- package/dist/esm/core/aggregation/participant.js +210 -21
- package/dist/esm/core/aggregation/participant.js.map +1 -1
- package/dist/esm/core/aggregation/phases.js +6 -0
- package/dist/esm/core/aggregation/phases.js.map +1 -1
- package/dist/esm/core/aggregation/recovery-policy.js +156 -0
- package/dist/esm/core/aggregation/recovery-policy.js.map +1 -0
- package/dist/esm/core/aggregation/recovery-spend.js +106 -0
- package/dist/esm/core/aggregation/recovery-spend.js.map +1 -0
- package/dist/esm/core/aggregation/runner/aggregation-runner.js +12 -3
- package/dist/esm/core/aggregation/runner/aggregation-runner.js.map +1 -1
- package/dist/esm/core/aggregation/runner/participant-runner.js +74 -22
- package/dist/esm/core/aggregation/runner/participant-runner.js.map +1 -1
- package/dist/esm/core/aggregation/runner/service-runner.js +104 -11
- package/dist/esm/core/aggregation/runner/service-runner.js.map +1 -1
- package/dist/esm/core/aggregation/service.js +221 -11
- package/dist/esm/core/aggregation/service.js.map +1 -1
- package/dist/esm/core/aggregation/signing-session.js +3 -3
- package/dist/esm/core/aggregation/signing-session.js.map +1 -1
- package/dist/esm/core/aggregation/transport/http/envelope.js +3 -3
- package/dist/esm/core/aggregation/transport/http/inbox-buffer.js +1 -1
- package/dist/esm/core/aggregation/transport/http/nonce-cache.js +1 -1
- package/dist/esm/core/aggregation/transport/http/rate-limiter.js +1 -1
- package/dist/esm/core/aggregation/transport/http/request-auth.js +1 -1
- package/dist/esm/core/aggregation/transport/http/server.js +1 -1
- package/dist/esm/core/aggregation/transport/http/sse-stream.js +1 -1
- package/dist/esm/core/aggregation/transport/http/sse-writer.js +1 -1
- package/dist/esm/core/aggregation/transport/in-memory.js +1 -1
- package/dist/esm/core/aggregation/transport/nostr.js +6 -6
- package/dist/esm/core/beacon/beacon.js +116 -20
- package/dist/esm/core/beacon/beacon.js.map +1 -1
- package/dist/esm/core/beacon/cas-beacon.js +6 -6
- package/dist/esm/core/beacon/cas-beacon.js.map +1 -1
- package/dist/esm/core/beacon/fee-estimator.js +8 -0
- package/dist/esm/core/beacon/fee-estimator.js.map +1 -1
- package/dist/esm/core/beacon/singleton-beacon.js +2 -2
- package/dist/esm/core/beacon/singleton-beacon.js.map +1 -1
- package/dist/esm/core/beacon/smt-beacon.js +3 -3
- package/dist/esm/core/beacon/smt-beacon.js.map +1 -1
- package/dist/esm/core/resolver.js +8 -8
- package/dist/esm/core/resolver.js.map +1 -1
- package/dist/esm/core/updater.js +6 -6
- package/dist/esm/core/updater.js.map +1 -1
- package/dist/esm/did-btcr2.js +2 -2
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/types/core/aggregation/beacon-strategy.d.ts +8 -4
- package/dist/types/core/aggregation/beacon-strategy.d.ts.map +1 -1
- package/dist/types/core/aggregation/cohort.d.ts +88 -17
- package/dist/types/core/aggregation/cohort.d.ts.map +1 -1
- package/dist/types/core/aggregation/conditions.d.ts +28 -0
- package/dist/types/core/aggregation/conditions.d.ts.map +1 -1
- package/dist/types/core/aggregation/fallback-spend.d.ts +94 -0
- package/dist/types/core/aggregation/fallback-spend.d.ts.map +1 -0
- package/dist/types/core/aggregation/logger.d.ts +1 -1
- package/dist/types/core/aggregation/messages/base.d.ts +6 -0
- package/dist/types/core/aggregation/messages/base.d.ts.map +1 -1
- package/dist/types/core/aggregation/messages/bodies.d.ts +50 -2
- package/dist/types/core/aggregation/messages/bodies.d.ts.map +1 -1
- package/dist/types/core/aggregation/messages/constants.d.ts +8 -0
- package/dist/types/core/aggregation/messages/constants.d.ts.map +1 -1
- package/dist/types/core/aggregation/messages/factories.d.ts +40 -0
- package/dist/types/core/aggregation/messages/factories.d.ts.map +1 -1
- package/dist/types/core/aggregation/messages/guards.d.ts.map +1 -1
- package/dist/types/core/aggregation/participant.d.ts +41 -7
- package/dist/types/core/aggregation/participant.d.ts.map +1 -1
- package/dist/types/core/aggregation/phases.d.ts +8 -2
- package/dist/types/core/aggregation/phases.d.ts.map +1 -1
- package/dist/types/core/aggregation/recovery-policy.d.ts +132 -0
- package/dist/types/core/aggregation/recovery-policy.d.ts.map +1 -0
- package/dist/types/core/aggregation/recovery-spend.d.ts +94 -0
- package/dist/types/core/aggregation/recovery-spend.d.ts.map +1 -0
- package/dist/types/core/aggregation/runner/aggregation-runner.d.ts +19 -3
- package/dist/types/core/aggregation/runner/aggregation-runner.d.ts.map +1 -1
- package/dist/types/core/aggregation/runner/events.d.ts +28 -7
- package/dist/types/core/aggregation/runner/events.d.ts.map +1 -1
- package/dist/types/core/aggregation/runner/participant-runner.d.ts +3 -3
- package/dist/types/core/aggregation/runner/participant-runner.d.ts.map +1 -1
- package/dist/types/core/aggregation/runner/service-runner.d.ts +47 -5
- package/dist/types/core/aggregation/runner/service-runner.d.ts.map +1 -1
- package/dist/types/core/aggregation/service.d.ts +26 -2
- package/dist/types/core/aggregation/service.d.ts.map +1 -1
- package/dist/types/core/aggregation/signing-session.d.ts +2 -2
- package/dist/types/core/aggregation/signing-session.d.ts.map +1 -1
- package/dist/types/core/aggregation/transport/http/envelope.d.ts +3 -3
- package/dist/types/core/aggregation/transport/http/inbox-buffer.d.ts +1 -1
- package/dist/types/core/aggregation/transport/http/nonce-cache.d.ts +1 -1
- package/dist/types/core/aggregation/transport/http/rate-limiter.d.ts +1 -1
- package/dist/types/core/aggregation/transport/http/request-auth.d.ts +1 -1
- package/dist/types/core/aggregation/transport/http/server.d.ts +1 -1
- package/dist/types/core/aggregation/transport/http/sse-stream.d.ts +2 -2
- package/dist/types/core/aggregation/transport/http/sse-writer.d.ts +1 -1
- package/dist/types/core/aggregation/transport/in-memory.d.ts +1 -1
- package/dist/types/core/aggregation/transport/nostr.d.ts +4 -4
- package/dist/types/core/aggregation/transport/transport.d.ts +4 -4
- package/dist/types/core/aggregation/transport/transport.d.ts.map +1 -1
- package/dist/types/core/beacon/beacon.d.ts +66 -10
- package/dist/types/core/beacon/beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/cas-beacon.d.ts +2 -2
- package/dist/types/core/beacon/fee-estimator.d.ts +8 -0
- package/dist/types/core/beacon/fee-estimator.d.ts.map +1 -1
- package/dist/types/core/beacon/interfaces.d.ts +1 -1
- package/dist/types/core/resolver.d.ts +3 -3
- package/dist/types/core/updater.d.ts +4 -4
- package/dist/types/did-btcr2.d.ts +2 -2
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/core/aggregation/beacon-strategy.ts +27 -9
- package/src/core/aggregation/cohort.ts +171 -35
- package/src/core/aggregation/conditions.ts +56 -0
- package/src/core/aggregation/fallback-spend.ts +223 -0
- package/src/core/aggregation/logger.ts +1 -1
- package/src/core/aggregation/messages/base.ts +6 -0
- package/src/core/aggregation/messages/bodies.ts +94 -1
- package/src/core/aggregation/messages/constants.ts +12 -0
- package/src/core/aggregation/messages/factories.ts +57 -0
- package/src/core/aggregation/messages/guards.ts +6 -0
- package/src/core/aggregation/participant.ts +255 -23
- package/src/core/aggregation/phases.ts +9 -0
- package/src/core/aggregation/recovery-policy.ts +237 -0
- package/src/core/aggregation/recovery-spend.ts +192 -0
- package/src/core/aggregation/runner/aggregation-runner.ts +34 -5
- package/src/core/aggregation/runner/events.ts +26 -7
- package/src/core/aggregation/runner/participant-runner.ts +75 -23
- package/src/core/aggregation/runner/service-runner.ts +144 -12
- package/src/core/aggregation/service.ts +260 -14
- package/src/core/aggregation/signing-session.ts +3 -3
- package/src/core/aggregation/transport/http/envelope.ts +3 -3
- package/src/core/aggregation/transport/http/inbox-buffer.ts +1 -1
- package/src/core/aggregation/transport/http/nonce-cache.ts +1 -1
- package/src/core/aggregation/transport/http/rate-limiter.ts +1 -1
- package/src/core/aggregation/transport/http/request-auth.ts +1 -1
- package/src/core/aggregation/transport/http/server.ts +1 -1
- package/src/core/aggregation/transport/http/sse-stream.ts +2 -2
- package/src/core/aggregation/transport/http/sse-writer.ts +1 -1
- package/src/core/aggregation/transport/in-memory.ts +1 -1
- package/src/core/aggregation/transport/nostr.ts +6 -6
- package/src/core/aggregation/transport/transport.ts +4 -4
- package/src/core/beacon/beacon.ts +149 -25
- package/src/core/beacon/cas-beacon.ts +7 -7
- package/src/core/beacon/fee-estimator.ts +9 -0
- package/src/core/beacon/interfaces.ts +1 -1
- package/src/core/beacon/singleton-beacon.ts +2 -2
- package/src/core/beacon/smt-beacon.ts +3 -3
- package/src/core/resolver.ts +8 -8
- package/src/core/updater.ts +6 -6
- package/src/did-btcr2.ts +2 -2
- package/src/index.ts +3 -0
|
@@ -11,7 +11,7 @@ export type ShouldJoin = (advert: CohortAdvert) => Promise<boolean>;
|
|
|
11
11
|
export type OnProvideUpdate = (info: {
|
|
12
12
|
cohortId: string;
|
|
13
13
|
beaconAddress: string;
|
|
14
|
-
}) => Promise<SignedBTCR2Update>;
|
|
14
|
+
}) => Promise<SignedBTCR2Update | null>;
|
|
15
15
|
/** Decision callback: approve or reject aggregated data. */
|
|
16
16
|
export type OnValidateData = (info: PendingValidation) => Promise<{
|
|
17
17
|
approved: boolean;
|
|
@@ -33,7 +33,7 @@ export interface AggregationParticipantRunnerOptions {
|
|
|
33
33
|
shouldJoin?: ShouldJoin;
|
|
34
34
|
/**
|
|
35
35
|
* Provide a signed BTCR2 update for the cohort.
|
|
36
|
-
* REQUIRED
|
|
36
|
+
* REQUIRED - no sensible default.
|
|
37
37
|
*/
|
|
38
38
|
onProvideUpdate: OnProvideUpdate;
|
|
39
39
|
/**
|
|
@@ -110,7 +110,7 @@ export declare class AggregationParticipantRunner extends TypedEventEmitter<Aggr
|
|
|
110
110
|
*
|
|
111
111
|
* For an open-ended, long-lived subscriber (no fixed count), construct an
|
|
112
112
|
* {@link AggregationParticipantRunner} directly, set `shouldJoin`, call
|
|
113
|
-
* `start()`, and listen for `cohort-complete`
|
|
113
|
+
* `start()`, and listen for `cohort-complete` - the runner already drives
|
|
114
114
|
* any number of cohorts concurrently.
|
|
115
115
|
*
|
|
116
116
|
* @param options Participant runner options (set `shouldJoin` to select cohorts).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"participant-runner.d.ts","sourceRoot":"","sources":["../../../../../src/core/aggregation/runner/participant-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"participant-runner.d.ts","sourceRoot":"","sources":["../../../../../src/core/aggregation/runner/participant-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAWzD,OAAO,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AED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,qBAAa,4BAA6B,SAAQ,iBAAiB,CAAC,4BAA4B,CAAC;;IAC/F,sEAAsE;IACtE,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAC;gBAY7B,OAAO,EAAE,mCAAmC;IAexD;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,8EAA8E;IAC9E,IAAI,IAAI,IAAI;IA6BZ;;;;OAIG;WACU,SAAS,CACpB,OAAO,EAAE,mCAAmC,GAC3C,OAAO,CAAC,kBAAkB,CAAC;IAY9B;;;;;;;;;;;;;;;OAeG;WACU,YAAY,CACvB,OAAO,EAAE,mCAAmC,EAC5C,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,kBAAkB,EAAE,CAAC;CAiRjC"}
|
|
@@ -2,6 +2,7 @@ import type { SchnorrKeyPair } from '@did-btcr2/keypair';
|
|
|
2
2
|
import type { AggregationResult, CohortConfig, PendingOptIn, SigningTxData } from '../service.js';
|
|
3
3
|
import { AggregationService } from '../service.js';
|
|
4
4
|
import type { Transport } from '../transport/transport.js';
|
|
5
|
+
import type { FeeEstimator } from '../../beacon/fee-estimator.js';
|
|
5
6
|
import type { AggregationServiceEvents } from './events.js';
|
|
6
7
|
import { TypedEventEmitter } from './typed-emitter.js';
|
|
7
8
|
/** Decision callback: accept or reject a participant's opt-in. */
|
|
@@ -20,6 +21,13 @@ export type OnProvideTxData = (info: {
|
|
|
20
21
|
cohortId: string;
|
|
21
22
|
beaconAddress: string;
|
|
22
23
|
signalBytes: Uint8Array;
|
|
24
|
+
/**
|
|
25
|
+
* Fee estimator the runner is configured with (the runner's `feeEstimator`
|
|
26
|
+
* option, or a static 5 sat/vB default). Forward it to the beacon transaction
|
|
27
|
+
* builder so a dynamic rate injected at the runner is honored, rather than
|
|
28
|
+
* hard-coding a rate inside this callback (ADR 045).
|
|
29
|
+
*/
|
|
30
|
+
feeEstimator: FeeEstimator;
|
|
23
31
|
}) => Promise<SigningTxData>;
|
|
24
32
|
export interface AggregationServiceRunnerOptions {
|
|
25
33
|
/** Underlying transport (NostrTransport, MockTransport, etc.). */
|
|
@@ -47,9 +55,17 @@ export interface AggregationServiceRunnerOptions {
|
|
|
47
55
|
onReadyToFinalize?: OnReadyToFinalize;
|
|
48
56
|
/**
|
|
49
57
|
* Provide the Bitcoin transaction data to sign.
|
|
50
|
-
* REQUIRED
|
|
58
|
+
* REQUIRED - no sensible default.
|
|
51
59
|
*/
|
|
52
60
|
onProvideTxData: OnProvideTxData;
|
|
61
|
+
/**
|
|
62
|
+
* Fee estimator passed to {@link OnProvideTxData} so the beacon transaction the
|
|
63
|
+
* callback builds is sized at a chosen rate. Inject a dynamic estimator (a mempool
|
|
64
|
+
* API or Bitcoin Core `estimatesmartfee`) here as the single standard point for
|
|
65
|
+
* fee-rate selection, instead of hard-coding a rate inside the callback (ADR 045).
|
|
66
|
+
* Defaults to a static 5 sat/vB estimator.
|
|
67
|
+
*/
|
|
68
|
+
feeEstimator?: FeeEstimator;
|
|
53
69
|
/**
|
|
54
70
|
* Maximum canonicalized byte-length of a signed update body. Submissions
|
|
55
71
|
* above this cap are rejected and surfaced via the `message-rejected` event.
|
|
@@ -73,7 +89,7 @@ export interface AggregationServiceRunnerOptions {
|
|
|
73
89
|
/**
|
|
74
90
|
* Re-publish COHORT_ADVERT on this interval until a cohort's keygen is
|
|
75
91
|
* finalized. Works around relays that don't backfill historical events to
|
|
76
|
-
* late subscribers
|
|
92
|
+
* late subscribers - a republish gives late joiners a window to discover the
|
|
77
93
|
* advert without protocol changes. The first publish is immediate;
|
|
78
94
|
* subsequent publishes fire every `advertRepeatIntervalMs` until that
|
|
79
95
|
* cohort's keygen completes, fails, or is stopped. Defaults to
|
|
@@ -81,6 +97,16 @@ export interface AggregationServiceRunnerOptions {
|
|
|
81
97
|
* once and never retry.
|
|
82
98
|
*/
|
|
83
99
|
advertRepeatIntervalMs?: number;
|
|
100
|
+
/**
|
|
101
|
+
* When a cohort stalls (phase timeout) while the optimistic n-of-n signing
|
|
102
|
+
* round is in flight, fall back to the k-of-n script path instead of failing
|
|
103
|
+
* the cohort (graceful liveness, ADR 042). Off by default: enabling it trades a
|
|
104
|
+
* cheaper/private key-path spend for a larger script-path spend whenever the
|
|
105
|
+
* optimistic round does not complete in time. A stall outside the signing
|
|
106
|
+
* phases still fails the cohort. Operators can also drive the fallback
|
|
107
|
+
* explicitly via {@link AggregationServiceRunner.triggerFallback}.
|
|
108
|
+
*/
|
|
109
|
+
autoFallbackOnStall?: boolean;
|
|
84
110
|
}
|
|
85
111
|
/** Default cadence for re-publishing COHORT_ADVERT until keygen completes: 60 seconds. */
|
|
86
112
|
export declare const DEFAULT_ADVERT_REPEAT_INTERVAL_MS = 60000;
|
|
@@ -93,7 +119,7 @@ export declare const DEFAULT_ADVERT_REPEAT_INTERVAL_MS = 60000;
|
|
|
93
119
|
*
|
|
94
120
|
* A single runner is a long-lived multiplexer: it advertises and drives many
|
|
95
121
|
* cohorts concurrently over one transport. Each advertised cohort owns an
|
|
96
|
-
* independent completion promise and fails in isolation
|
|
122
|
+
* independent completion promise and fails in isolation - a stalled or failed
|
|
97
123
|
* cohort never settles its siblings (see ADR 040). Use
|
|
98
124
|
* {@link AggregationServiceRunner.advertiseCohort} for the multi-cohort path;
|
|
99
125
|
* {@link AggregationServiceRunner.run} is a thin single-cohort convenience over
|
|
@@ -108,8 +134,9 @@ export declare const DEFAULT_ADVERT_REPEAT_INTERVAL_MS = 60000;
|
|
|
108
134
|
* transport,
|
|
109
135
|
* did: serviceDid,
|
|
110
136
|
* keys: serviceKeys,
|
|
111
|
-
* onProvideTxData: async ({
|
|
112
|
-
*
|
|
137
|
+
* onProvideTxData: async ({ beaconAddress, signalBytes, feeEstimator }) => {
|
|
138
|
+
* // Forward feeEstimator so a dynamic rate injected at the runner is honored.
|
|
139
|
+
* return await buildBeaconTransaction(beaconAddress, signalBytes, bitcoin, feeEstimator);
|
|
113
140
|
* },
|
|
114
141
|
* });
|
|
115
142
|
*
|
|
@@ -170,6 +197,21 @@ export declare class AggregationServiceRunner extends TypedEventEmitter<Aggregat
|
|
|
170
197
|
* @returns {Promise<AggregationResult[]>} Results of the cohorts that completed.
|
|
171
198
|
*/
|
|
172
199
|
runAll(): Promise<AggregationResult[]>;
|
|
200
|
+
/**
|
|
201
|
+
* Abandon the optimistic n-of-n key path for a cohort and collect k-of-n
|
|
202
|
+
* fallback (script-path) signatures instead (ADR 042). Idempotent and safe
|
|
203
|
+
* against the optimistic completion: it commits the cohort to the fallback
|
|
204
|
+
* path synchronously (the `committedPath` latch) before sending anything, so a
|
|
205
|
+
* late optimistic signature can no longer complete-and-broadcast a competing
|
|
206
|
+
* spend of the same UTXO. No-op if the cohort is unknown, already settled, or
|
|
207
|
+
* already committed to a path.
|
|
208
|
+
*
|
|
209
|
+
* Wired automatically to the phase-stall timer when `autoFallbackOnStall` is
|
|
210
|
+
* set; otherwise call it from an operator decision (a UI "fall back now"
|
|
211
|
+
* action). Throws only if the underlying state machine rejects the transition
|
|
212
|
+
* (e.g. signing has not started).
|
|
213
|
+
*/
|
|
214
|
+
triggerFallback(cohortId: string): Promise<void>;
|
|
173
215
|
/**
|
|
174
216
|
* Stop a single cohort early without affecting the rest of the runner. Drops
|
|
175
217
|
* the cohort's state machine state; its `completion` promise rejects with a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-runner.d.ts","sourceRoot":"","sources":["../../../../../src/core/aggregation/runner/service-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"service-runner.d.ts","sourceRoot":"","sources":["../../../../../src/core/aggregation/runner/service-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAczD,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ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CAAC;IAEjC;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAE5B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;;;;;;OASG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC;;;;;;;;OAQG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,0FAA0F;AAC1F,eAAO,MAAM,iCAAiC,QAAS,CAAC;AA6CxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,qBAAa,wBAAyB,SAAQ,iBAAiB,CAAC,wBAAwB,CAAC;;IACvF,sEAAsE;IACtE,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;gBA0BzB,OAAO,EAAE,+BAA+B;IA2CpD;;;;;;;;;OASG;IACH,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAA;KAAE;IA6CnG;;;;;;OAMG;IACH,GAAG,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAcjC;;;;;;;;;;OAUG;IACG,MAAM,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;IA+E5C;;;;;;;;;;;;;OAaG;IACG,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA6EtD;;;;OAIG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IASlC;;;;OAIG;IACH,IAAI,IAAI,IAAI;CAgTb"}
|
|
@@ -31,8 +31,19 @@ export interface ValidationProgress {
|
|
|
31
31
|
/** Final aggregation result for a cohort. */
|
|
32
32
|
export interface AggregationResult {
|
|
33
33
|
cohortId: string;
|
|
34
|
+
/**
|
|
35
|
+
* The 64-byte aggregated MuSig2 signature for the optimistic key path. Empty
|
|
36
|
+
* for a `script-path` result: the k-of-n fallback embeds k separate signatures
|
|
37
|
+
* directly in the witness of {@link signedTx}, with no single aggregate sig.
|
|
38
|
+
*/
|
|
34
39
|
signature: Uint8Array;
|
|
35
40
|
signedTx: Transaction;
|
|
41
|
+
/**
|
|
42
|
+
* Which Taproot spend path produced {@link signedTx}: `key-path` is the
|
|
43
|
+
* optimistic n-of-n MuSig2 spend, `script-path` is the k-of-n fallback (ADR
|
|
44
|
+
* 042). Absent is treated as `key-path` for backward compatibility.
|
|
45
|
+
*/
|
|
46
|
+
path?: 'key-path' | 'script-path';
|
|
36
47
|
}
|
|
37
48
|
/** Transaction data needed to start a signing session. */
|
|
38
49
|
export interface SigningTxData {
|
|
@@ -95,7 +106,7 @@ export declare class AggregationService {
|
|
|
95
106
|
drainRejections(cohortId: string): Array<Rejection>;
|
|
96
107
|
/**
|
|
97
108
|
* Create a new cohort with the given config. Returns the cohort ID.
|
|
98
|
-
* Cohort starts in `Created` phase
|
|
109
|
+
* Cohort starts in `Created` phase - call `advertise()` to broadcast.
|
|
99
110
|
*/
|
|
100
111
|
createCohort(config: CohortConfig): string;
|
|
101
112
|
/**
|
|
@@ -125,7 +136,7 @@ export declare class AggregationService {
|
|
|
125
136
|
validationProgress(cohortId: string): ValidationProgress;
|
|
126
137
|
/**
|
|
127
138
|
* Start a signing session by creating auth requests for all participants.
|
|
128
|
-
* The caller provides the transaction data
|
|
139
|
+
* The caller provides the transaction data - typically built via
|
|
129
140
|
* `buildBeaconTransaction()` against a Bitcoin connection.
|
|
130
141
|
*/
|
|
131
142
|
startSigning(cohortId: string, txData: SigningTxData): BaseMessage[];
|
|
@@ -134,6 +145,19 @@ export declare class AggregationService {
|
|
|
134
145
|
* Call after `validationProgress(cohortId).approved.size === total`.
|
|
135
146
|
*/
|
|
136
147
|
sendAggregatedNonce(cohortId: string): BaseMessage[];
|
|
148
|
+
/**
|
|
149
|
+
* Abandon the optimistic n-of-n key path and ask members to authorize the
|
|
150
|
+
* k-of-n fallback (script-path) spend of the SAME beacon transaction (graceful
|
|
151
|
+
* liveness, ADR 042). Reuses the in-flight signing session's transaction and
|
|
152
|
+
* spent output, so the announcement and its outputs are unchanged: only the
|
|
153
|
+
* witness path differs. Returns one FALLBACK_AUTHORIZATION_REQUEST per
|
|
154
|
+
* participant.
|
|
155
|
+
*
|
|
156
|
+
* Callable once optimistic signing has started (the session and its tx exist)
|
|
157
|
+
* and before it completes. A cohort can take exactly one of the two paths: the
|
|
158
|
+
* caller (runner) must commit to fallback and stop driving the optimistic path.
|
|
159
|
+
*/
|
|
160
|
+
startFallbackSigning(cohortId: string): BaseMessage[];
|
|
137
161
|
getResult(cohortId: string): AggregationResult | undefined;
|
|
138
162
|
getCohortPhase(cohortId: string): ServiceCohortPhaseType | undefined;
|
|
139
163
|
getCohort(cohortId: string): AggregationCohort | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../src/core/aggregation/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../src/core/aggregation/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAGvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAA4B,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAKlF,OAAO,KAAK,EAAE,WAAW,EAAE,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YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,WAAW,EAAE;IAgEpE;;;OAGG;IACH,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,EAAE;IA6DpD;;;;;;;;;;;OAWG;IACH,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,EAAE;IAkIrD,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS;IAI1D,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,sBAAsB,GAAG,SAAS;IAIpE,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS;IAI1D;;;;OAIG;IACH,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIzD,IAAI,OAAO,IAAI,aAAa,CAAC,iBAAiB,CAAC,CAE9C;IAED;;;OAGG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;CAGrC"}
|
|
@@ -32,11 +32,11 @@ export declare class BeaconSigningSession {
|
|
|
32
32
|
prevOutScripts: Uint8Array[];
|
|
33
33
|
/** Previous output values for Taproot sighash computation. */
|
|
34
34
|
prevOutValues: bigint[];
|
|
35
|
-
/** Map of participant publicKey-hex
|
|
35
|
+
/** Map of participant publicKey-hex to public nonce contribution. */
|
|
36
36
|
nonceContributions: Map<PublicKeyHex, Nonce>;
|
|
37
37
|
/** Aggregated MuSig2 nonce (66 bytes). */
|
|
38
38
|
aggregatedNonce?: Uint8Array;
|
|
39
|
-
/** Map of participant DID
|
|
39
|
+
/** Map of participant DID to partial signature. */
|
|
40
40
|
partialSignatures: Map<string, Uint8Array>;
|
|
41
41
|
/** Final 64-byte Schnorr signature. */
|
|
42
42
|
signature?: Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signing-session.d.ts","sourceRoot":"","sources":["../../../../src/core/aggregation/signing-session.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAG3D,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,KAAK,GAAG,UAAU,CAAC;AAExB,MAAM,WAAW,oBAAoB;IACnC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,iBAAiB,CAAC;IAC1B,SAAS,EAAE,WAAW,CAAC;IACvB,cAAc,CAAC,EAAE,UAAU,EAAE,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED;;;;;;;;;GASG;AACH,qBAAa,oBAAoB;;IAC/B,kDAAkD;IAC3C,EAAE,EAAE,MAAM,CAAC;IAElB,yCAAyC;IAClC,MAAM,EAAE,iBAAiB,CAAC;IAEjC,4CAA4C;IACrC,SAAS,EAAE,WAAW,CAAC;IAE9B,yEAAyE;IAClE,cAAc,EAAE,UAAU,EAAE,CAAC;IAEpC,8DAA8D;IACvD,aAAa,EAAE,MAAM,EAAE,CAAC;IAE/B,
|
|
1
|
+
{"version":3,"file":"signing-session.d.ts","sourceRoot":"","sources":["../../../../src/core/aggregation/signing-session.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAG3D,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,KAAK,GAAG,UAAU,CAAC;AAExB,MAAM,WAAW,oBAAoB;IACnC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,iBAAiB,CAAC;IAC1B,SAAS,EAAE,WAAW,CAAC;IACvB,cAAc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IAAI;IAOpB,UAAU,IAAI,OAAO;IAIrB,QAAQ,IAAI,OAAO;CAG3B"}
|
|
@@ -26,7 +26,7 @@ export interface VerifyEnvelopeOptions {
|
|
|
26
26
|
/**
|
|
27
27
|
* Build a {@link SignedEnvelope} around `message`.
|
|
28
28
|
*
|
|
29
|
-
* Pure function
|
|
29
|
+
* Pure function - no I/O beyond `randomBytes` for nonce generation (which
|
|
30
30
|
* uses the platform's cryptographic RNG: `crypto.getRandomValues` in browsers,
|
|
31
31
|
* `node:crypto` in Node). Deterministic when both `nonce` and `timestamp` are
|
|
32
32
|
* supplied via {@link SignEnvelopeOptions}.
|
|
@@ -40,7 +40,7 @@ export declare function signEnvelope(message: EnvelopeMessage, sender: {
|
|
|
40
40
|
* communication public key. Throws {@link HttpTransportError} on any failure;
|
|
41
41
|
* returns normally on success.
|
|
42
42
|
*
|
|
43
|
-
* Does NOT check nonce uniqueness
|
|
43
|
+
* Does NOT check nonce uniqueness - replay protection is the caller's
|
|
44
44
|
* responsibility (the server-side transport maintains an LRU cache).
|
|
45
45
|
*/
|
|
46
46
|
export declare function verifyEnvelope(envelope: SignedEnvelope, senderPk: CompressedSecp256k1PublicKey, opts?: VerifyEnvelopeOptions): void;
|
|
@@ -51,7 +51,7 @@ export declare function verifyEnvelope(envelope: SignedEnvelope, senderPk: Compr
|
|
|
51
51
|
*
|
|
52
52
|
* Without this, `JSON.stringify` serializes a `Uint8Array` as an index-keyed
|
|
53
53
|
* object (`{"0":1,"1":2,...}`), which `canonicalize` then re-parses into a
|
|
54
|
-
* plain object
|
|
54
|
+
* plain object - the receiver cannot reconstruct the original bytes even
|
|
55
55
|
* though the signature still verifies.
|
|
56
56
|
*/
|
|
57
57
|
export declare function normalizeForWire(value: unknown): unknown;
|
|
@@ -12,7 +12,7 @@ export interface StoredEvent {
|
|
|
12
12
|
* When a subscriber (re)connects with a `Last-Event-ID` header, the server
|
|
13
13
|
* uses {@link since} to replay everything that arrived while the subscriber
|
|
14
14
|
* was disconnected. Events older than the replay window (evicted from the
|
|
15
|
-
* ring) are unrecoverable
|
|
15
|
+
* ring) are unrecoverable - callers should choose `capacity` based on
|
|
16
16
|
* expected message rate × acceptable reconnect window.
|
|
17
17
|
*/
|
|
18
18
|
export declare class InboxBuffer {
|
|
@@ -5,7 +5,7 @@ export interface NonceCacheConfig {
|
|
|
5
5
|
/**
|
|
6
6
|
* Bounded anti-replay cache for `(did, nonce)` pairs.
|
|
7
7
|
*
|
|
8
|
-
* Replay windowing is the caller's responsibility
|
|
8
|
+
* Replay windowing is the caller's responsibility - this cache only detects
|
|
9
9
|
* duplicates. Callers are expected to reject envelopes/headers whose timestamp
|
|
10
10
|
* is outside the clock-skew window *before* consulting the cache, so entries
|
|
11
11
|
* here are always within the protocol's acceptable window.
|
|
@@ -29,7 +29,7 @@ export interface RateLimiterConfig {
|
|
|
29
29
|
* sender DID). Tokens refill linearly at `rps` up to `burst`. Each `consume`
|
|
30
30
|
* call atomically debits one token or returns `false` to reject.
|
|
31
31
|
*
|
|
32
|
-
* The limiter is synchronous and deterministic given `nowMs`
|
|
32
|
+
* The limiter is synchronous and deterministic given `nowMs` - tests can
|
|
33
33
|
* drive it with a fixed clock to exercise exact boundaries.
|
|
34
34
|
*/
|
|
35
35
|
export declare class RateLimiter {
|
|
@@ -32,7 +32,7 @@ export interface BuildRequestAuthOptions {
|
|
|
32
32
|
export declare function buildRequestAuth(did: string, keys: SchnorrKeyPair, path: string, opts?: BuildRequestAuthOptions): string;
|
|
33
33
|
/**
|
|
34
34
|
* Parse a `BTCR2-Sig` auth header value into its structured fields. Does NOT
|
|
35
|
-
* verify the signature
|
|
35
|
+
* verify the signature: call {@link verifyRequestAuth} for that.
|
|
36
36
|
*/
|
|
37
37
|
export declare function parseRequestAuth(headerValue: string): ParsedRequestAuth;
|
|
38
38
|
export interface VerifyRequestAuthOptions {
|
|
@@ -65,7 +65,7 @@ export interface HttpServerTransportConfig {
|
|
|
65
65
|
now?: () => number;
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
|
-
* Server-side HTTP transport. Sans-I/O
|
|
68
|
+
* Server-side HTTP transport. Sans-I/O - the caller mounts
|
|
69
69
|
* {@link handleRequest} and {@link handleSse} under their HTTP framework of
|
|
70
70
|
* choice; the transport owns only in-memory state (actors, inboxes, advert
|
|
71
71
|
* cache, replay / rate-limit policies).
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Parsed Server-Sent Events record.
|
|
3
3
|
*
|
|
4
|
-
* Events without a `data` field are never yielded (per the SSE spec
|
|
4
|
+
* Events without a `data` field are never yielded (per the SSE spec - only a
|
|
5
5
|
* blank line that follows at least one `data:` line dispatches an event).
|
|
6
6
|
*/
|
|
7
7
|
export interface SseEvent {
|
|
@@ -23,7 +23,7 @@ export interface SseEvent {
|
|
|
23
23
|
* CR-only line terminators are not supported (every mainstream SSE
|
|
24
24
|
* implementation emits LF or CRLF).
|
|
25
25
|
*
|
|
26
|
-
* Pure, runtime-agnostic
|
|
26
|
+
* Pure, runtime-agnostic - works anywhere `ReadableStream<Uint8Array>` and
|
|
27
27
|
* `TextDecoder` exist (browsers and Node 22+).
|
|
28
28
|
*
|
|
29
29
|
* The caller owns stream lifecycle: cancellation should be effected via an
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Format an SSE event frame. Pairs with {@link parseSseStream}.
|
|
3
3
|
*
|
|
4
|
-
* Multi-line `data` is split across multiple `data:` lines per the SSE spec
|
|
4
|
+
* Multi-line `data` is split across multiple `data:` lines per the SSE spec -
|
|
5
5
|
* each embedded `\n` becomes its own line, and the parser rejoins them.
|
|
6
6
|
*
|
|
7
7
|
* The returned string includes a trailing blank line (the dispatch marker).
|
|
@@ -4,7 +4,7 @@ import type { MessageHandler, Transport } from './transport.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* In-process message bus connecting one or more {@link InMemoryTransport}
|
|
6
6
|
* instances. Routes broadcasts to every registered actor and directed messages
|
|
7
|
-
* to the actor that owns the recipient DID
|
|
7
|
+
* to the actor that owns the recipient DID, with no relay, server, or network.
|
|
8
8
|
*
|
|
9
9
|
* Each delivery does a JSON round-trip (Uint8Array preserved as `__bytes` hex)
|
|
10
10
|
* so handlers receive an isolated, serialization-faithful copy, exactly as a
|
|
@@ -38,9 +38,9 @@ export declare const DEFAULT_BROADCAST_LOOKBACK_MS: number;
|
|
|
38
38
|
* sending or receiving.
|
|
39
39
|
*
|
|
40
40
|
* Message routing:
|
|
41
|
-
* - Keygen messages (COHORT_ADVERT, COHORT_OPT_IN, COHORT_OPT_IN_ACCEPT, COHORT_READY)
|
|
42
|
-
* - Update messages (SUBMIT_UPDATE, DISTRIBUTE_AGGREGATED_DATA, VALIDATION_ACK)
|
|
43
|
-
* - Sign messages
|
|
41
|
+
* - Keygen messages (COHORT_ADVERT, COHORT_OPT_IN, COHORT_OPT_IN_ACCEPT, COHORT_READY) to kind 1 (plaintext)
|
|
42
|
+
* - Update messages (SUBMIT_UPDATE, DISTRIBUTE_AGGREGATED_DATA, VALIDATION_ACK) to kind 1059 (NIP-44 encrypted)
|
|
43
|
+
* - Sign messages to kind 1059 (NIP-44 encrypted)
|
|
44
44
|
*
|
|
45
45
|
* @class NostrTransport
|
|
46
46
|
* @implements {Transport}
|
|
@@ -145,7 +145,7 @@ export declare class NostrTransport implements Transport {
|
|
|
145
145
|
* backfill historical events to late subscribers: republishing gives late
|
|
146
146
|
* joiners a window to discover the message without requiring protocol
|
|
147
147
|
* changes. Relay rate-limit / publish failures inside the interval are
|
|
148
|
-
* caught and logged rather than propagated
|
|
148
|
+
* caught and logged rather than propagated - the caller should stop the
|
|
149
149
|
* repeater once the protocol condition is satisfied.
|
|
150
150
|
*/
|
|
151
151
|
publishRepeating(message: BaseMessage, sender: Did, intervalMs: number, recipient?: Did): () => void;
|
|
@@ -11,7 +11,7 @@ export type TransportType = 'nostr' | 'didcomm' | 'http';
|
|
|
11
11
|
* shared by all registered actors. Each actor registers its own DID and keys;
|
|
12
12
|
* the transport resolves the correct identity when sending or receiving messages.
|
|
13
13
|
*
|
|
14
|
-
* The transport is a pure passthrough
|
|
14
|
+
* The transport is a pure passthrough: it knows nothing about the aggregation
|
|
15
15
|
* protocol. It only signs/encrypts outgoing messages with the sender's keys and
|
|
16
16
|
* dispatches incoming messages to the correct actor's registered handler.
|
|
17
17
|
*
|
|
@@ -19,7 +19,7 @@ export type TransportType = 'nostr' | 'didcomm' | 'http';
|
|
|
19
19
|
*/
|
|
20
20
|
export interface Transport {
|
|
21
21
|
name: string;
|
|
22
|
-
/** Start the underlying transport (idempotent
|
|
22
|
+
/** Start the underlying transport (idempotent, only starts once). */
|
|
23
23
|
start(): void;
|
|
24
24
|
/** Register an actor (service or participant) with this transport. */
|
|
25
25
|
registerActor(did: string, keys: SchnorrKeyPair): void;
|
|
@@ -48,14 +48,14 @@ export interface Transport {
|
|
|
48
48
|
* message is satisfied).
|
|
49
49
|
*
|
|
50
50
|
* Useful for broadcasts on transports that don't reliably backfill
|
|
51
|
-
* historical events to late subscribers (many Nostr relays)
|
|
51
|
+
* historical events to late subscribers (many Nostr relays): republishing
|
|
52
52
|
* gives late joiners a window in which to discover the message. The first
|
|
53
53
|
* publish is synchronous-ish (fired before the method returns).
|
|
54
54
|
*
|
|
55
55
|
* Callers specify `recipient` only for directed messages; for broadcasts
|
|
56
56
|
* it is omitted.
|
|
57
57
|
*
|
|
58
|
-
* @returns A stop function. Idempotent
|
|
58
|
+
* @returns A stop function. Idempotent, safe to call more than once.
|
|
59
59
|
*/
|
|
60
60
|
publishRepeating(message: BaseMessage, sender: string, intervalMs: number, recipient?: string): () => void;
|
|
61
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../../../src/core/aggregation/transport/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MA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C,GAAG,EAAE,MAAM,EAAE,eAAe,EAAE,UAAU,GAAG,IAAI,CAAC;IAE7D,yDAAyD;IACzD,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IAE/C,6DAA6D;IAC7D,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAE7F,uEAAuE;IACvE,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtE;;;;OAIG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAEnC,6EAA6E;IAC7E,WAAW,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAErF;;;;;;;;;;;;;;;OAeG;IACH,gBAAgB,CACd,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,IAAI,CAAC;CACf"}
|
|
@@ -9,25 +9,25 @@ import type { FeeEstimator } from './fee-estimator.js';
|
|
|
9
9
|
import type { BeaconService, BeaconSignal } from './interfaces.js';
|
|
10
10
|
/**
|
|
11
11
|
* Singleton beacon script kinds. Per the did:btcr2 spec, deterministic DID documents
|
|
12
|
-
* include three beacon services: P2PKH, P2WPKH, and P2TR (taproot key-path)
|
|
12
|
+
* include three beacon services: P2PKH, P2WPKH, and P2TR (taproot key-path), all
|
|
13
13
|
* derived from the genesis secp256k1 public key. The singleton broadcast path must
|
|
14
14
|
* support signing for all three.
|
|
15
15
|
*/
|
|
16
16
|
export type SingletonScriptKind = 'p2pkh' | 'p2wpkh' | 'p2tr';
|
|
17
17
|
/**
|
|
18
|
-
* Conservative vsize estimate for a 1-input P2TR key-path
|
|
18
|
+
* Conservative vsize estimate for a 1-input P2TR key-path to 1 P2TR change + 1 OP_RETURN(32) tx.
|
|
19
19
|
* Stripped 137 + witness ≈ 68 (marker + flag + stack-count + sig-len + 64 BIP-340 sig).
|
|
20
20
|
* Weight = 137*4 + 68 = 616, vsize ≈ 154, rounded to 160 for headroom.
|
|
21
21
|
*/
|
|
22
22
|
export declare const P2TR_BEACON_TX_VSIZE = 160;
|
|
23
23
|
/**
|
|
24
|
-
* Conservative vsize estimate for a 1-input P2WPKH
|
|
24
|
+
* Conservative vsize estimate for a 1-input P2WPKH to 1 P2WPKH change + 1 OP_RETURN(32) tx.
|
|
25
25
|
* Stripped 125 + witness ≈ 110 (worst-case DER ECDSA sig 72 + sighash byte + 33 pubkey + framing).
|
|
26
26
|
* vsize = ceil((125*4 + 110) / 4) ≈ 153, rounded to 155.
|
|
27
27
|
*/
|
|
28
28
|
export declare const P2WPKH_BEACON_TX_VSIZE = 155;
|
|
29
29
|
/**
|
|
30
|
-
* Conservative vsize estimate for a 1-input P2PKH
|
|
30
|
+
* Conservative vsize estimate for a 1-input P2PKH to 1 P2PKH change + 1 OP_RETURN(32) tx.
|
|
31
31
|
* Legacy (non-segwit): scriptSig carries the full sig+pubkey (~108 bytes), no witness
|
|
32
32
|
* discount. Stripped ≈ 4 nVer + 1 vin-count + (32+4+1+108+4) input + 1 vout-count +
|
|
33
33
|
* 34 P2PKH-change + 43 OP_RETURN + 4 nLockTime ≈ 236 bytes. vsize = 236, rounded to 240.
|
|
@@ -35,6 +35,37 @@ export declare const P2WPKH_BEACON_TX_VSIZE = 155;
|
|
|
35
35
|
export declare const P2PKH_BEACON_TX_VSIZE = 240;
|
|
36
36
|
/** Per-kind vsize lookup for singleton beacon fee estimation. */
|
|
37
37
|
export declare const SINGLETON_BEACON_TX_VSIZE: Readonly<Record<SingletonScriptKind, number>>;
|
|
38
|
+
/**
|
|
39
|
+
* Serialized size (vbytes) of a single change output, by script kind:
|
|
40
|
+
* 8 (value) + 1 (scriptPubKey length) + scriptPubKey bytes. P2PKH 25, P2WPKH 22,
|
|
41
|
+
* P2TR 34. These are non-witness bytes, so each contributes its full byte count to
|
|
42
|
+
* the transaction vsize. The {@link SINGLETON_BEACON_TX_VSIZE} constants bake in a
|
|
43
|
+
* same-kind change output; {@link beaconTxVsize} uses these deltas to re-size the
|
|
44
|
+
* fee when a caller routes change to an address of a different kind (ADR 044).
|
|
45
|
+
*/
|
|
46
|
+
export declare const CHANGE_OUTPUT_VBYTES: Readonly<Record<SingletonScriptKind, number>>;
|
|
47
|
+
/**
|
|
48
|
+
* Dust threshold (sats) below which a change output is not worth creating, by script
|
|
49
|
+
* kind (the standard Bitcoin Core dust relay thresholds at the default 3 sat/vB dust
|
|
50
|
+
* rate). When the change after fees falls below this, the builders omit the change
|
|
51
|
+
* output and let the remainder fall into the fee rather than emit an unspendable,
|
|
52
|
+
* relay-rejected dust output (ADR 044).
|
|
53
|
+
*/
|
|
54
|
+
export declare const DUST_LIMIT_SATS: Readonly<Record<SingletonScriptKind, number>>;
|
|
55
|
+
/**
|
|
56
|
+
* vsize (vbytes) for a beacon transaction that spends one input of `beaconKind`
|
|
57
|
+
* and returns change to an output of `changeKind`, plus the OP_RETURN(32) signal.
|
|
58
|
+
*
|
|
59
|
+
* When `changeKind === beaconKind` (the default, change to the beacon address) this
|
|
60
|
+
* returns the per-kind {@link SINGLETON_BEACON_TX_VSIZE} constant unchanged, so the
|
|
61
|
+
* default path and the constants' lock-in tests are byte-identical. A differing
|
|
62
|
+
* `changeKind` swaps the assumed same-kind change output for the actual one, keeping
|
|
63
|
+
* the result a valid upper bound. The aggregation key-path spend is the
|
|
64
|
+
* `beaconKind: 'p2tr'` case (its input is always the cohort's P2TR key path; only the
|
|
65
|
+
* change output varies), the analytical sizing ADR 045 calls for, computed without a
|
|
66
|
+
* secret.
|
|
67
|
+
*/
|
|
68
|
+
export declare function beaconTxVsize(beaconKind: SingletonScriptKind, changeKind: SingletonScriptKind): number;
|
|
38
69
|
/**
|
|
39
70
|
* Detect the singleton script kind of a Bitcoin address (P2PKH / P2WPKH / P2TR).
|
|
40
71
|
* The deterministic-DID document emits all three kinds; the broadcast path needs
|
|
@@ -47,12 +78,26 @@ export declare function detectSingletonScriptKind(bitcoinAddress: string, networ
|
|
|
47
78
|
* pubkey cannot actually spend.
|
|
48
79
|
*/
|
|
49
80
|
export declare function deriveSingletonAddress(kind: SingletonScriptKind, pubkey: KeyBytes, network: BTCNetwork): string;
|
|
81
|
+
/**
|
|
82
|
+
* Resolve the change-output recipient for a beacon transaction. Returns the beacon
|
|
83
|
+
* address when no change address is supplied (preserving the prior behavior of
|
|
84
|
+
* returning change to the spent address), otherwise validates the caller-supplied
|
|
85
|
+
* address against the network and returns it. Validating here fails fast rather than
|
|
86
|
+
* burning a real UTXO on a transaction that breaks at broadcast (ADR 044).
|
|
87
|
+
*/
|
|
88
|
+
export declare function resolveChangeAddress(beaconAddress: string, network: BTCNetwork, changeAddress?: string): string;
|
|
50
89
|
/**
|
|
51
90
|
* Options accepted by {@link SinglePartyBeacon.buildSignAndBroadcast} and related helpers.
|
|
52
91
|
*/
|
|
53
92
|
export interface BroadcastOptions {
|
|
54
93
|
/** Fee estimator for computing the transaction fee. Defaults to {@link DEFAULT_FEE_ESTIMATOR}. */
|
|
55
94
|
feeEstimator?: FeeEstimator;
|
|
95
|
+
/**
|
|
96
|
+
* Address to send change to. Defaults to the beacon address (reuses the spent
|
|
97
|
+
* address, the prior behavior). Supply a fresh address the controller owns to
|
|
98
|
+
* stop linking the beacon's announcements into one on-chain chain (ADR 044).
|
|
99
|
+
*/
|
|
100
|
+
changeAddress?: string;
|
|
56
101
|
}
|
|
57
102
|
/**
|
|
58
103
|
* Unsigned beacon transaction + the prev-output metadata needed for downstream
|
|
@@ -65,8 +110,10 @@ export interface BeaconTxPlan {
|
|
|
65
110
|
prevOutScripts: Uint8Array[];
|
|
66
111
|
/** Amounts (sats) of the consumed previous outputs. */
|
|
67
112
|
prevOutValues: bigint[];
|
|
68
|
-
/**
|
|
113
|
+
/** The beacon address this tx spends from. */
|
|
69
114
|
beaconAddress: string;
|
|
115
|
+
/** Address the change output was sent to (the beacon address unless a change address was supplied). */
|
|
116
|
+
changeAddress: string;
|
|
70
117
|
/** The UTXO this tx consumes. */
|
|
71
118
|
utxo: AddressUtxo;
|
|
72
119
|
/** The fee (sats) already deducted from the change output. */
|
|
@@ -97,7 +144,7 @@ export declare function opReturnScript(signalBytes: Uint8Array): Uint8Array;
|
|
|
97
144
|
* signing session consumes (via {@link SigningTxData}).
|
|
98
145
|
*
|
|
99
146
|
* This is the reusable counterpart to {@link SinglePartyBeacon.buildSignAndBroadcast}'s internal
|
|
100
|
-
* construction step
|
|
147
|
+
* construction step: the aggregation path must produce an unsigned tx because the
|
|
101
148
|
* signature comes from a MuSig2 round, not a local secret key.
|
|
102
149
|
*
|
|
103
150
|
* @param opts Parameters including the cohort's aggregate internal pubkey.
|
|
@@ -116,6 +163,13 @@ export declare function buildAggregationBeaconTx(opts: {
|
|
|
116
163
|
network: BTCNetwork;
|
|
117
164
|
/** Optional fee estimator (defaults to 5 sat/vB). */
|
|
118
165
|
feeEstimator?: FeeEstimator;
|
|
166
|
+
/**
|
|
167
|
+
* Address to send change to. Defaults to the beacon (cohort) address. Supply the
|
|
168
|
+
* funder's address (an operator-funded cohort's funding wallet) to stop reusing the
|
|
169
|
+
* cohort address for change (ADR 044). Change ownership is the funder's call, which
|
|
170
|
+
* the cohort-condition model leaves to the caller (ADR 039).
|
|
171
|
+
*/
|
|
172
|
+
changeAddress?: string;
|
|
119
173
|
}): Promise<BeaconTxPlan>;
|
|
120
174
|
/**
|
|
121
175
|
* Abstract base class providing the single-party broadcast machinery shared by
|
|
@@ -170,7 +224,7 @@ export declare abstract class SinglePartyBeacon {
|
|
|
170
224
|
*
|
|
171
225
|
* Composed from the three extracted phases ({@link buildSinglePartyTx},
|
|
172
226
|
* {@link signSinglePartyTx}, {@link broadcastRawTx}) so each piece can be exercised
|
|
173
|
-
* in isolation. Aggregation beacons use {@link buildAggregationBeaconTx} instead
|
|
227
|
+
* in isolation. Aggregation beacons use {@link buildAggregationBeaconTx} instead:
|
|
174
228
|
* the multi-party path can't share the signing phase, but the tx-construction
|
|
175
229
|
* plumbing (UTXO fetch + OP_RETURN output + change output) is shared.
|
|
176
230
|
*
|
|
@@ -187,10 +241,11 @@ export declare abstract class SinglePartyBeacon {
|
|
|
187
241
|
*
|
|
188
242
|
* Detects the beacon address script kind (P2PKH / P2WPKH / P2TR) and configures
|
|
189
243
|
* the input accordingly. Validates that the signer's pubkey produces the beacon
|
|
190
|
-
* address under that script kind
|
|
244
|
+
* address under that script kind: without this check, a misconfigured caller
|
|
191
245
|
* would burn a real UTXO on a tx that fails at broadcast. Fees are computed from
|
|
192
|
-
* the per-kind {@link SINGLETON_BEACON_TX_VSIZE} constant
|
|
193
|
-
* round-trip
|
|
246
|
+
* the per-kind {@link SINGLETON_BEACON_TX_VSIZE} constant (via {@link beaconTxVsize}),
|
|
247
|
+
* avoiding any probe-sign round-trip; a change address of a different kind re-sizes
|
|
248
|
+
* the fee by the change output's size delta so it stays a valid upper bound.
|
|
194
249
|
*/
|
|
195
250
|
protected buildSinglePartyTx(opts: {
|
|
196
251
|
signalBytes: Uint8Array;
|
|
@@ -200,6 +255,7 @@ export declare abstract class SinglePartyBeacon {
|
|
|
200
255
|
signer: Signer;
|
|
201
256
|
bitcoin: BitcoinConnection;
|
|
202
257
|
feeEstimator: FeeEstimator;
|
|
258
|
+
changeAddress?: string;
|
|
203
259
|
}): Promise<BeaconTxPlan>;
|
|
204
260
|
/**
|
|
205
261
|
* Sign + finalize the unsigned single-party tx and return its raw hex.
|
|
@@ -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,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