@did-btcr2/method 0.37.0 → 0.39.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 +47868 -34771
- package/dist/browser.mjs +47867 -34770
- package/dist/cjs/index.js +462 -6060
- package/dist/esm/core/beacon/beacon.js +101 -10
- package/dist/esm/core/beacon/beacon.js.map +1 -1
- package/dist/esm/core/beacon/fee-estimator.js +12 -27
- package/dist/esm/core/beacon/fee-estimator.js.map +1 -1
- package/dist/esm/core/did-sender-resolver.js +26 -0
- package/dist/esm/core/did-sender-resolver.js.map +1 -0
- package/dist/esm/index.js +3 -17
- package/dist/esm/index.js.map +1 -1
- package/dist/types/core/beacon/beacon.d.ts +59 -3
- package/dist/types/core/beacon/beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/fee-estimator.d.ts +10 -37
- package/dist/types/core/beacon/fee-estimator.d.ts.map +1 -1
- package/dist/types/core/did-sender-resolver.d.ts +14 -0
- package/dist/types/core/did-sender-resolver.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -16
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/core/beacon/beacon.ts +131 -12
- package/src/core/beacon/fee-estimator.ts +15 -49
- package/src/core/did-sender-resolver.ts +25 -0
- package/src/index.ts +3 -17
- package/dist/esm/core/aggregation/beacon-strategy.js +0 -76
- package/dist/esm/core/aggregation/beacon-strategy.js.map +0 -1
- package/dist/esm/core/aggregation/cohort.js +0 -316
- package/dist/esm/core/aggregation/cohort.js.map +0 -1
- package/dist/esm/core/aggregation/conditions.js +0 -102
- package/dist/esm/core/aggregation/conditions.js.map +0 -1
- package/dist/esm/core/aggregation/errors.js +0 -22
- package/dist/esm/core/aggregation/errors.js.map +0 -1
- package/dist/esm/core/aggregation/fallback-spend.js +0 -132
- package/dist/esm/core/aggregation/fallback-spend.js.map +0 -1
- package/dist/esm/core/aggregation/logger.js +0 -15
- package/dist/esm/core/aggregation/logger.js.map +0 -1
- package/dist/esm/core/aggregation/messages/base.js +0 -36
- package/dist/esm/core/aggregation/messages/base.js.map +0 -1
- package/dist/esm/core/aggregation/messages/bodies.js +0 -149
- package/dist/esm/core/aggregation/messages/bodies.js.map +0 -1
- package/dist/esm/core/aggregation/messages/constants.js +0 -37
- package/dist/esm/core/aggregation/messages/constants.js.map +0 -1
- package/dist/esm/core/aggregation/messages/factories.js +0 -139
- package/dist/esm/core/aggregation/messages/factories.js.map +0 -1
- package/dist/esm/core/aggregation/messages/guards.js +0 -40
- package/dist/esm/core/aggregation/messages/guards.js.map +0 -1
- package/dist/esm/core/aggregation/messages/index.js +0 -6
- package/dist/esm/core/aggregation/messages/index.js.map +0 -1
- package/dist/esm/core/aggregation/participant.js +0 -588
- package/dist/esm/core/aggregation/participant.js.map +0 -1
- package/dist/esm/core/aggregation/phases.js +0 -45
- package/dist/esm/core/aggregation/phases.js.map +0 -1
- package/dist/esm/core/aggregation/recovery-policy.js +0 -156
- package/dist/esm/core/aggregation/recovery-policy.js.map +0 -1
- package/dist/esm/core/aggregation/recovery-spend.js +0 -106
- package/dist/esm/core/aggregation/recovery-spend.js.map +0 -1
- package/dist/esm/core/aggregation/runner/aggregation-runner.js +0 -74
- package/dist/esm/core/aggregation/runner/aggregation-runner.js.map +0 -1
- package/dist/esm/core/aggregation/runner/events.js +0 -2
- package/dist/esm/core/aggregation/runner/events.js.map +0 -1
- package/dist/esm/core/aggregation/runner/index.js +0 -6
- package/dist/esm/core/aggregation/runner/index.js.map +0 -1
- package/dist/esm/core/aggregation/runner/participant-runner.js +0 -407
- package/dist/esm/core/aggregation/runner/participant-runner.js.map +0 -1
- package/dist/esm/core/aggregation/runner/service-runner.js +0 -694
- package/dist/esm/core/aggregation/runner/service-runner.js.map +0 -1
- package/dist/esm/core/aggregation/runner/typed-emitter.js +0 -80
- package/dist/esm/core/aggregation/runner/typed-emitter.js.map +0 -1
- package/dist/esm/core/aggregation/service.js +0 -774
- package/dist/esm/core/aggregation/service.js.map +0 -1
- package/dist/esm/core/aggregation/signer.js +0 -33
- package/dist/esm/core/aggregation/signer.js.map +0 -1
- package/dist/esm/core/aggregation/signing-session.js +0 -195
- package/dist/esm/core/aggregation/signing-session.js.map +0 -1
- package/dist/esm/core/aggregation/transport/didcomm.js +0 -41
- package/dist/esm/core/aggregation/transport/didcomm.js.map +0 -1
- package/dist/esm/core/aggregation/transport/error.js +0 -12
- package/dist/esm/core/aggregation/transport/error.js.map +0 -1
- package/dist/esm/core/aggregation/transport/factory.js +0 -29
- package/dist/esm/core/aggregation/transport/factory.js.map +0 -1
- package/dist/esm/core/aggregation/transport/http/client.js +0 -350
- package/dist/esm/core/aggregation/transport/http/client.js.map +0 -1
- package/dist/esm/core/aggregation/transport/http/envelope.js +0 -126
- package/dist/esm/core/aggregation/transport/http/envelope.js.map +0 -1
- package/dist/esm/core/aggregation/transport/http/errors.js +0 -11
- package/dist/esm/core/aggregation/transport/http/errors.js.map +0 -1
- package/dist/esm/core/aggregation/transport/http/inbox-buffer.js +0 -45
- package/dist/esm/core/aggregation/transport/http/inbox-buffer.js.map +0 -1
- package/dist/esm/core/aggregation/transport/http/index.js +0 -12
- package/dist/esm/core/aggregation/transport/http/index.js.map +0 -1
- package/dist/esm/core/aggregation/transport/http/nonce-cache.js +0 -38
- package/dist/esm/core/aggregation/transport/http/nonce-cache.js.map +0 -1
- package/dist/esm/core/aggregation/transport/http/protocol.js +0 -28
- package/dist/esm/core/aggregation/transport/http/protocol.js.map +0 -1
- package/dist/esm/core/aggregation/transport/http/rate-limiter.js +0 -45
- package/dist/esm/core/aggregation/transport/http/rate-limiter.js.map +0 -1
- package/dist/esm/core/aggregation/transport/http/request-auth.js +0 -100
- package/dist/esm/core/aggregation/transport/http/request-auth.js.map +0 -1
- package/dist/esm/core/aggregation/transport/http/server.js +0 -481
- package/dist/esm/core/aggregation/transport/http/server.js.map +0 -1
- package/dist/esm/core/aggregation/transport/http/sse-stream.js +0 -110
- package/dist/esm/core/aggregation/transport/http/sse-stream.js.map +0 -1
- package/dist/esm/core/aggregation/transport/http/sse-writer.js +0 -25
- package/dist/esm/core/aggregation/transport/http/sse-writer.js.map +0 -1
- package/dist/esm/core/aggregation/transport/in-memory.js +0 -149
- package/dist/esm/core/aggregation/transport/in-memory.js.map +0 -1
- package/dist/esm/core/aggregation/transport/index.js +0 -8
- package/dist/esm/core/aggregation/transport/index.js.map +0 -1
- package/dist/esm/core/aggregation/transport/nostr.js +0 -491
- package/dist/esm/core/aggregation/transport/nostr.js.map +0 -1
- package/dist/esm/core/aggregation/transport/transport.js +0 -2
- package/dist/esm/core/aggregation/transport/transport.js.map +0 -1
- package/dist/types/core/aggregation/beacon-strategy.d.ts +0 -56
- package/dist/types/core/aggregation/beacon-strategy.d.ts.map +0 -1
- package/dist/types/core/aggregation/cohort.d.ts +0 -182
- package/dist/types/core/aggregation/cohort.d.ts.map +0 -1
- package/dist/types/core/aggregation/conditions.d.ts +0 -86
- package/dist/types/core/aggregation/conditions.d.ts.map +0 -1
- package/dist/types/core/aggregation/errors.d.ts +0 -14
- package/dist/types/core/aggregation/errors.d.ts.map +0 -1
- package/dist/types/core/aggregation/fallback-spend.d.ts +0 -94
- package/dist/types/core/aggregation/fallback-spend.d.ts.map +0 -1
- package/dist/types/core/aggregation/logger.d.ts +0 -22
- package/dist/types/core/aggregation/logger.d.ts.map +0 -1
- package/dist/types/core/aggregation/messages/base.d.ts +0 -58
- package/dist/types/core/aggregation/messages/base.d.ts.map +0 -1
- package/dist/types/core/aggregation/messages/bodies.d.ts +0 -177
- package/dist/types/core/aggregation/messages/bodies.d.ts.map +0 -1
- package/dist/types/core/aggregation/messages/constants.d.ts +0 -31
- package/dist/types/core/aggregation/messages/constants.d.ts.map +0 -1
- package/dist/types/core/aggregation/messages/factories.d.ts +0 -217
- package/dist/types/core/aggregation/messages/factories.d.ts.map +0 -1
- package/dist/types/core/aggregation/messages/guards.d.ts +0 -11
- package/dist/types/core/aggregation/messages/guards.d.ts.map +0 -1
- package/dist/types/core/aggregation/messages/index.d.ts +0 -6
- package/dist/types/core/aggregation/messages/index.d.ts.map +0 -1
- package/dist/types/core/aggregation/participant.d.ts +0 -162
- package/dist/types/core/aggregation/participant.d.ts.map +0 -1
- package/dist/types/core/aggregation/phases.d.ts +0 -55
- package/dist/types/core/aggregation/phases.d.ts.map +0 -1
- package/dist/types/core/aggregation/recovery-policy.d.ts +0 -132
- package/dist/types/core/aggregation/recovery-policy.d.ts.map +0 -1
- package/dist/types/core/aggregation/recovery-spend.d.ts +0 -94
- package/dist/types/core/aggregation/recovery-spend.d.ts.map +0 -1
- package/dist/types/core/aggregation/runner/aggregation-runner.d.ts +0 -66
- package/dist/types/core/aggregation/runner/aggregation-runner.d.ts.map +0 -1
- package/dist/types/core/aggregation/runner/events.d.ts +0 -147
- package/dist/types/core/aggregation/runner/events.d.ts.map +0 -1
- package/dist/types/core/aggregation/runner/index.d.ts +0 -6
- package/dist/types/core/aggregation/runner/index.d.ts.map +0 -1
- package/dist/types/core/aggregation/runner/participant-runner.d.ts +0 -122
- package/dist/types/core/aggregation/runner/participant-runner.d.ts.map +0 -1
- package/dist/types/core/aggregation/runner/service-runner.d.ts +0 -211
- package/dist/types/core/aggregation/runner/service-runner.d.ts.map +0 -1
- package/dist/types/core/aggregation/runner/typed-emitter.d.ts +0 -41
- package/dist/types/core/aggregation/runner/typed-emitter.d.ts.map +0 -1
- package/dist/types/core/aggregation/service.d.ts +0 -177
- package/dist/types/core/aggregation/service.d.ts.map +0 -1
- package/dist/types/core/aggregation/signer.d.ts +0 -50
- package/dist/types/core/aggregation/signer.d.ts.map +0 -1
- package/dist/types/core/aggregation/signing-session.d.ts +0 -81
- package/dist/types/core/aggregation/signing-session.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/didcomm.d.ts +0 -23
- package/dist/types/core/aggregation/transport/didcomm.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/error.d.ts +0 -8
- package/dist/types/core/aggregation/transport/error.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/factory.d.ts +0 -28
- package/dist/types/core/aggregation/transport/factory.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/http/client.d.ts +0 -48
- package/dist/types/core/aggregation/transport/http/client.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/http/envelope.d.ts +0 -64
- package/dist/types/core/aggregation/transport/http/envelope.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/http/errors.d.ts +0 -9
- package/dist/types/core/aggregation/transport/http/errors.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/http/inbox-buffer.d.ts +0 -32
- package/dist/types/core/aggregation/transport/http/inbox-buffer.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/http/index.d.ts +0 -12
- package/dist/types/core/aggregation/transport/http/index.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/http/nonce-cache.d.ts +0 -26
- package/dist/types/core/aggregation/transport/http/nonce-cache.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/http/protocol.d.ts +0 -53
- package/dist/types/core/aggregation/transport/http/protocol.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/http/rate-limiter.d.ts +0 -41
- package/dist/types/core/aggregation/transport/http/rate-limiter.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/http/request-auth.d.ts +0 -50
- package/dist/types/core/aggregation/transport/http/request-auth.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/http/server.d.ts +0 -110
- package/dist/types/core/aggregation/transport/http/server.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/http/sse-stream.d.ts +0 -34
- package/dist/types/core/aggregation/transport/http/sse-stream.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/http/sse-writer.d.ts +0 -12
- package/dist/types/core/aggregation/transport/http/sse-writer.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/in-memory.d.ts +0 -64
- package/dist/types/core/aggregation/transport/in-memory.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/index.d.ts +0 -8
- package/dist/types/core/aggregation/transport/index.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/nostr.d.ts +0 -153
- package/dist/types/core/aggregation/transport/nostr.d.ts.map +0 -1
- package/dist/types/core/aggregation/transport/transport.d.ts +0 -62
- package/dist/types/core/aggregation/transport/transport.d.ts.map +0 -1
- package/src/core/aggregation/beacon-strategy.ts +0 -142
- package/src/core/aggregation/cohort.ts +0 -415
- package/src/core/aggregation/conditions.ts +0 -172
- package/src/core/aggregation/errors.ts +0 -25
- package/src/core/aggregation/fallback-spend.ts +0 -223
- package/src/core/aggregation/logger.ts +0 -33
- package/src/core/aggregation/messages/base.ts +0 -80
- package/src/core/aggregation/messages/bodies.ts +0 -328
- package/src/core/aggregation/messages/constants.ts +0 -40
- package/src/core/aggregation/messages/factories.ts +0 -297
- package/src/core/aggregation/messages/guards.ts +0 -61
- package/src/core/aggregation/messages/index.ts +0 -5
- package/src/core/aggregation/participant.ts +0 -779
- package/src/core/aggregation/phases.ts +0 -91
- package/src/core/aggregation/recovery-policy.ts +0 -237
- package/src/core/aggregation/recovery-spend.ts +0 -192
- package/src/core/aggregation/runner/aggregation-runner.ts +0 -118
- package/src/core/aggregation/runner/events.ts +0 -129
- package/src/core/aggregation/runner/index.ts +0 -5
- package/src/core/aggregation/runner/participant-runner.ts +0 -488
- package/src/core/aggregation/runner/service-runner.ts +0 -866
- package/src/core/aggregation/runner/typed-emitter.ts +0 -87
- package/src/core/aggregation/service.ts +0 -1000
- package/src/core/aggregation/signer.ts +0 -67
- package/src/core/aggregation/signing-session.ts +0 -290
- package/src/core/aggregation/transport/didcomm.ts +0 -59
- package/src/core/aggregation/transport/error.ts +0 -13
- package/src/core/aggregation/transport/factory.ts +0 -65
- package/src/core/aggregation/transport/http/client.ts +0 -409
- package/src/core/aggregation/transport/http/envelope.ts +0 -204
- package/src/core/aggregation/transport/http/errors.ts +0 -11
- package/src/core/aggregation/transport/http/inbox-buffer.ts +0 -53
- package/src/core/aggregation/transport/http/index.ts +0 -11
- package/src/core/aggregation/transport/http/nonce-cache.ts +0 -43
- package/src/core/aggregation/transport/http/protocol.ts +0 -57
- package/src/core/aggregation/transport/http/rate-limiter.ts +0 -75
- package/src/core/aggregation/transport/http/request-auth.ts +0 -164
- package/src/core/aggregation/transport/http/server.ts +0 -615
- package/src/core/aggregation/transport/http/sse-stream.ts +0 -121
- package/src/core/aggregation/transport/http/sse-writer.ts +0 -23
- package/src/core/aggregation/transport/in-memory.ts +0 -178
- package/src/core/aggregation/transport/index.ts +0 -7
- package/src/core/aggregation/transport/nostr.ts +0 -576
- package/src/core/aggregation/transport/transport.ts +0 -79
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { concatBytes, hexToBytes } from '@noble/hashes/utils.js';
|
|
2
2
|
import { Address, OutScript, p2pkh, p2tr, p2wpkh, Script, SigHash, Transaction } from '@scure/btc-signer';
|
|
3
3
|
import { BeaconError } from './error.js';
|
|
4
|
-
import {
|
|
5
|
-
/** Default fee estimator used when none is supplied. ~5 sat/vB static rate. */
|
|
6
|
-
const DEFAULT_FEE_ESTIMATOR = new StaticFeeEstimator(5);
|
|
4
|
+
import { DEFAULT_FEE_ESTIMATOR } from './fee-estimator.js';
|
|
7
5
|
/**
|
|
8
6
|
* Conservative vsize estimate for a 1-input P2TR key-path to 1 P2TR change + 1 OP_RETURN(32) tx.
|
|
9
7
|
* Stripped 137 + witness ≈ 68 (marker + flag + stack-count + sig-len + 64 BIP-340 sig).
|
|
@@ -29,6 +27,48 @@ export const SINGLETON_BEACON_TX_VSIZE = {
|
|
|
29
27
|
p2wpkh: P2WPKH_BEACON_TX_VSIZE,
|
|
30
28
|
p2tr: P2TR_BEACON_TX_VSIZE,
|
|
31
29
|
};
|
|
30
|
+
/**
|
|
31
|
+
* Serialized size (vbytes) of a single change output, by script kind:
|
|
32
|
+
* 8 (value) + 1 (scriptPubKey length) + scriptPubKey bytes. P2PKH 25, P2WPKH 22,
|
|
33
|
+
* P2TR 34. These are non-witness bytes, so each contributes its full byte count to
|
|
34
|
+
* the transaction vsize. The {@link SINGLETON_BEACON_TX_VSIZE} constants bake in a
|
|
35
|
+
* same-kind change output; {@link beaconTxVsize} uses these deltas to re-size the
|
|
36
|
+
* fee when a caller routes change to an address of a different kind (ADR 044).
|
|
37
|
+
*/
|
|
38
|
+
export const CHANGE_OUTPUT_VBYTES = {
|
|
39
|
+
p2pkh: 34,
|
|
40
|
+
p2wpkh: 31,
|
|
41
|
+
p2tr: 43,
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Dust threshold (sats) below which a change output is not worth creating, by script
|
|
45
|
+
* kind (the standard Bitcoin Core dust relay thresholds at the default 3 sat/vB dust
|
|
46
|
+
* rate). When the change after fees falls below this, the builders omit the change
|
|
47
|
+
* output and let the remainder fall into the fee rather than emit an unspendable,
|
|
48
|
+
* relay-rejected dust output (ADR 044).
|
|
49
|
+
*/
|
|
50
|
+
export const DUST_LIMIT_SATS = {
|
|
51
|
+
p2pkh: 546,
|
|
52
|
+
p2wpkh: 294,
|
|
53
|
+
p2tr: 330,
|
|
54
|
+
};
|
|
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 function beaconTxVsize(beaconKind, changeKind) {
|
|
69
|
+
const base = SINGLETON_BEACON_TX_VSIZE[beaconKind] - CHANGE_OUTPUT_VBYTES[beaconKind];
|
|
70
|
+
return base + CHANGE_OUTPUT_VBYTES[changeKind];
|
|
71
|
+
}
|
|
32
72
|
/**
|
|
33
73
|
* Detect the singleton script kind of a Bitcoin address (P2PKH / P2WPKH / P2TR).
|
|
34
74
|
* The deterministic-DID document emits all three kinds; the broadcast path needs
|
|
@@ -58,6 +98,37 @@ export function deriveSingletonAddress(kind, pubkey, network) {
|
|
|
58
98
|
// P2TR key-path: x-only internal key (drop the SEC prefix byte).
|
|
59
99
|
return p2tr(pubkey.slice(1, 33), undefined, network).address;
|
|
60
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Resolve the change-output recipient for a beacon transaction. Returns the beacon
|
|
103
|
+
* address when no change address is supplied (preserving the prior behavior of
|
|
104
|
+
* returning change to the spent address), otherwise validates the caller-supplied
|
|
105
|
+
* address against the network and returns it. Validating here fails fast rather than
|
|
106
|
+
* burning a real UTXO on a transaction that breaks at broadcast (ADR 044).
|
|
107
|
+
*/
|
|
108
|
+
export function resolveChangeAddress(beaconAddress, network, changeAddress) {
|
|
109
|
+
if (!changeAddress || changeAddress === beaconAddress)
|
|
110
|
+
return beaconAddress;
|
|
111
|
+
try {
|
|
112
|
+
Address(network).decode(changeAddress);
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
throw new BeaconError(`Invalid change address "${changeAddress}" for network "${network}".`, 'INVALID_CHANGE_ADDRESS', { changeAddress, network });
|
|
116
|
+
}
|
|
117
|
+
return changeAddress;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Detect the change output's script kind for fee sizing. A change address that is not
|
|
121
|
+
* one of the three singleton kinds (for example P2SH or P2WSH) is sized as P2TR, the
|
|
122
|
+
* largest standard change output, so the estimated fee stays a valid upper bound.
|
|
123
|
+
*/
|
|
124
|
+
function changeOutputKind(changeAddress, network) {
|
|
125
|
+
try {
|
|
126
|
+
return detectSingletonScriptKind(changeAddress, network);
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
return 'p2tr';
|
|
130
|
+
}
|
|
131
|
+
}
|
|
61
132
|
/**
|
|
62
133
|
* Build an OP_RETURN script carrying a 32-byte beacon signal.
|
|
63
134
|
* Exported as a utility so callers building txs outside SinglePartyBeacon (e.g., the aggregation
|
|
@@ -105,6 +176,7 @@ async function fetchSpendableUtxo(bitcoinAddress, bitcoin) {
|
|
|
105
176
|
export async function buildAggregationBeaconTx(opts) {
|
|
106
177
|
const feeEstimator = opts.feeEstimator ?? DEFAULT_FEE_ESTIMATOR;
|
|
107
178
|
const { utxo, prevTxBytes } = await fetchSpendableUtxo(opts.beaconAddress, opts.bitcoin);
|
|
179
|
+
const changeAddress = resolveChangeAddress(opts.beaconAddress, opts.network, opts.changeAddress);
|
|
108
180
|
// The funded beacon output is a Taproot script-tree output: key path is the
|
|
109
181
|
// MuSig2 aggregate, script path is the k-of-n fallback + CSV recovery leaves
|
|
110
182
|
// (see cohort.ts and ADR 042). Derive the witnessUtxo scriptPubKey from the
|
|
@@ -112,8 +184,11 @@ export async function buildAggregationBeaconTx(opts) {
|
|
|
112
184
|
// would not match the script-tree UTXO on chain and would invalidate both the
|
|
113
185
|
// key-path sighash and the fallback script-path sighash.
|
|
114
186
|
const witnessScript = OutScript.encode(Address(opts.network).decode(opts.beaconAddress));
|
|
115
|
-
//
|
|
116
|
-
|
|
187
|
+
// The fee cannot be probe-measured (no secret key until the downstream MuSig2
|
|
188
|
+
// round), so size it analytically. The input is the cohort's P2TR key path; only
|
|
189
|
+
// the change output's kind varies, so the vsize follows the change address (ADR 045).
|
|
190
|
+
const changeKind = changeOutputKind(changeAddress, opts.network);
|
|
191
|
+
const feeSats = await feeEstimator.estimateFee(beaconTxVsize('p2tr', changeKind));
|
|
117
192
|
if (BigInt(utxo.value) <= feeSats) {
|
|
118
193
|
throw new BeaconError(`UTXO value (${utxo.value}) insufficient to cover fee (${feeSats}).`, 'INSUFFICIENT_FUNDS', { address: opts.beaconAddress, valueSats: utxo.value, feeSats });
|
|
119
194
|
}
|
|
@@ -128,13 +203,19 @@ export async function buildAggregationBeaconTx(opts) {
|
|
|
128
203
|
witnessUtxo: { amount: BigInt(utxo.value), script: witnessScript },
|
|
129
204
|
tapInternalKey: opts.internalPubkey,
|
|
130
205
|
});
|
|
131
|
-
|
|
206
|
+
// Change first (omitted when it would be dust, sweeping the remainder into the
|
|
207
|
+
// fee), then the OP_RETURN signal, which the spec requires to be the last output.
|
|
208
|
+
const changeValue = BigInt(utxo.value) - feeSats;
|
|
209
|
+
if (changeValue >= BigInt(DUST_LIMIT_SATS[changeKind])) {
|
|
210
|
+
tx.addOutputAddress(changeAddress, changeValue, opts.network);
|
|
211
|
+
}
|
|
132
212
|
tx.addOutput({ script: opReturnScript(opts.signalBytes), amount: 0n });
|
|
133
213
|
return {
|
|
134
214
|
tx,
|
|
135
215
|
prevOutScripts: [witnessScript],
|
|
136
216
|
prevOutValues: [BigInt(utxo.value)],
|
|
137
217
|
beaconAddress: opts.beaconAddress,
|
|
218
|
+
changeAddress,
|
|
138
219
|
utxo,
|
|
139
220
|
feeSats,
|
|
140
221
|
scriptKind: 'p2tr',
|
|
@@ -252,6 +333,7 @@ export class SinglePartyBeacon {
|
|
|
252
333
|
const { utxo, prevTxBytes } = await fetchSpendableUtxo(beaconAddress, bitcoin);
|
|
253
334
|
const plan = await this.buildSinglePartyTx({
|
|
254
335
|
signalBytes, beaconAddress, utxo, prevTxBytes, signer, bitcoin, feeEstimator,
|
|
336
|
+
changeAddress: options?.changeAddress,
|
|
255
337
|
});
|
|
256
338
|
const signedHex = await this.signSinglePartyTx(plan, signer);
|
|
257
339
|
return this.broadcastRawTx(bitcoin, signedHex);
|
|
@@ -263,18 +345,21 @@ export class SinglePartyBeacon {
|
|
|
263
345
|
* the input accordingly. Validates that the signer's pubkey produces the beacon
|
|
264
346
|
* address under that script kind: without this check, a misconfigured caller
|
|
265
347
|
* would burn a real UTXO on a tx that fails at broadcast. Fees are computed from
|
|
266
|
-
* the per-kind {@link SINGLETON_BEACON_TX_VSIZE} constant
|
|
267
|
-
* round-trip
|
|
348
|
+
* the per-kind {@link SINGLETON_BEACON_TX_VSIZE} constant (via {@link beaconTxVsize}),
|
|
349
|
+
* avoiding any probe-sign round-trip; a change address of a different kind re-sizes
|
|
350
|
+
* the fee by the change output's size delta so it stays a valid upper bound.
|
|
268
351
|
*/
|
|
269
352
|
async buildSinglePartyTx(opts) {
|
|
270
353
|
const network = opts.bitcoin.data;
|
|
271
354
|
const pubkey = opts.signer.publicKey;
|
|
272
355
|
const kind = detectSingletonScriptKind(opts.beaconAddress, network);
|
|
356
|
+
const changeAddress = resolveChangeAddress(opts.beaconAddress, network, opts.changeAddress);
|
|
273
357
|
const derivedAddress = deriveSingletonAddress(kind, pubkey, network);
|
|
274
358
|
if (derivedAddress !== opts.beaconAddress) {
|
|
275
359
|
throw new BeaconError(`Signer pubkey produces ${kind.toUpperCase()} address "${derivedAddress}", but beacon address is "${opts.beaconAddress}".`, 'SIGNER_KEY_MISMATCH', { kind, address: opts.beaconAddress, derivedAddress });
|
|
276
360
|
}
|
|
277
|
-
const
|
|
361
|
+
const changeKind = changeOutputKind(changeAddress, network);
|
|
362
|
+
const feeSats = await opts.feeEstimator.estimateFee(beaconTxVsize(kind, changeKind));
|
|
278
363
|
const amount = BigInt(opts.utxo.value);
|
|
279
364
|
if (amount <= feeSats) {
|
|
280
365
|
throw new BeaconError(`UTXO value (${opts.utxo.value}) insufficient to cover fee (${feeSats}).`, 'INSUFFICIENT_FUNDS', { address: opts.beaconAddress, valueSats: opts.utxo.value, feeSats });
|
|
@@ -315,13 +400,19 @@ export class SinglePartyBeacon {
|
|
|
315
400
|
tapInternalKey: internalKey,
|
|
316
401
|
});
|
|
317
402
|
}
|
|
318
|
-
|
|
403
|
+
// Change first (omitted when it would be dust, sweeping the remainder into the
|
|
404
|
+
// fee), then the OP_RETURN signal, which the spec requires to be the last output.
|
|
405
|
+
const changeValue = amount - feeSats;
|
|
406
|
+
if (changeValue >= BigInt(DUST_LIMIT_SATS[changeKind])) {
|
|
407
|
+
tx.addOutputAddress(changeAddress, changeValue, network);
|
|
408
|
+
}
|
|
319
409
|
tx.addOutput({ script: opReturnScript(opts.signalBytes), amount: 0n });
|
|
320
410
|
return {
|
|
321
411
|
tx,
|
|
322
412
|
prevOutScripts: [prevOutScript],
|
|
323
413
|
prevOutValues: [amount],
|
|
324
414
|
beaconAddress: opts.beaconAddress,
|
|
415
|
+
changeAddress,
|
|
325
416
|
utxo: opts.utxo,
|
|
326
417
|
feeSats,
|
|
327
418
|
scriptKind: kind,
|
|
@@ -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,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAIxD,+EAA+E;AAC/E,MAAM,qBAAqB,GAAiB,IAAI,kBAAkB,CAAC,CAAC,CAAC,CAAC;AAUtE;;;;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,oBAAo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C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;CACF"}
|
|
@@ -1,30 +1,15 @@
|
|
|
1
|
+
// The FeeEstimator contract and the StaticFeeEstimator implementation live in
|
|
2
|
+
// @did-btcr2/bitcoin, the natural home for a sat/vB fee primitive shared by the
|
|
3
|
+
// single-party and aggregated beacon broadcast paths. They are re-exported here so
|
|
4
|
+
// the @did-btcr2/method public surface is unchanged.
|
|
5
|
+
import { StaticFeeEstimator } from '@did-btcr2/bitcoin';
|
|
6
|
+
export { StaticFeeEstimator };
|
|
1
7
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* - Environments where a fee rate is supplied out-of-band
|
|
8
|
-
*
|
|
9
|
-
* For mainnet production use, prefer a dynamic estimator that queries current
|
|
10
|
-
* network conditions (mempool APIs, Bitcoin Core RPC).
|
|
8
|
+
* Default fee estimator used when a caller supplies none: a static 5 sat/vB rate.
|
|
9
|
+
* Suitable for tests and regtest. Production callers should inject a dynamic
|
|
10
|
+
* estimator (a mempool API, or Bitcoin Core `estimatesmartfee`) at the point the
|
|
11
|
+
* beacon transaction is built (single-party broadcast options, or the aggregation
|
|
12
|
+
* service runner's fee estimator).
|
|
11
13
|
*/
|
|
12
|
-
export
|
|
13
|
-
satsPerVbyte;
|
|
14
|
-
/**
|
|
15
|
-
* @param satsPerVbyte Fee rate in satoshis per virtual byte. Default: 5 sat/vB.
|
|
16
|
-
*/
|
|
17
|
-
constructor(satsPerVbyte = 5) {
|
|
18
|
-
if (satsPerVbyte < 0 || !Number.isFinite(satsPerVbyte)) {
|
|
19
|
-
throw new Error(`Invalid satsPerVbyte: ${satsPerVbyte}`);
|
|
20
|
-
}
|
|
21
|
-
this.satsPerVbyte = satsPerVbyte;
|
|
22
|
-
}
|
|
23
|
-
async estimateFee(vsize) {
|
|
24
|
-
if (vsize < 0 || !Number.isFinite(vsize)) {
|
|
25
|
-
throw new Error(`Invalid vsize: ${vsize}`);
|
|
26
|
-
}
|
|
27
|
-
return BigInt(Math.ceil(vsize * this.satsPerVbyte));
|
|
28
|
-
}
|
|
29
|
-
}
|
|
14
|
+
export const DEFAULT_FEE_ESTIMATOR = new StaticFeeEstimator(5);
|
|
30
15
|
//# sourceMappingURL=fee-estimator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fee-estimator.js","sourceRoot":"","sources":["../../../../src/core/beacon/fee-estimator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fee-estimator.js","sourceRoot":"","sources":["../../../../src/core/beacon/fee-estimator.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,gFAAgF;AAChF,mFAAmF;AACnF,qDAAqD;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAGxD,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAG9B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAiB,IAAI,kBAAkB,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CompressedSecp256k1PublicKey } from '@did-btcr2/keypair';
|
|
2
|
+
import { Identifier } from './identifier.js';
|
|
3
|
+
/**
|
|
4
|
+
* 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.
|
|
9
|
+
*
|
|
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).
|
|
13
|
+
*/
|
|
14
|
+
export function resolveBtcr2SenderPk(did) {
|
|
15
|
+
try {
|
|
16
|
+
const components = Identifier.decode(did);
|
|
17
|
+
if (components.idType === 'KEY') {
|
|
18
|
+
return new CompressedSecp256k1PublicKey(components.genesisBytes);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
// Not a decodable did:btcr2 KEY identifier.
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=did-sender-resolver.js.map
|
|
@@ -0,0 +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"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
// Aggregation
|
|
2
|
-
export * from '
|
|
3
|
-
export * from './core/aggregation/participant.js';
|
|
4
|
-
export * from './core/aggregation/signer.js';
|
|
5
|
-
export * from './core/aggregation/conditions.js';
|
|
6
|
-
export * from './core/aggregation/recovery-policy.js';
|
|
7
|
-
export * from './core/aggregation/recovery-spend.js';
|
|
8
|
-
export * from './core/aggregation/fallback-spend.js';
|
|
9
|
-
export * from './core/aggregation/cohort.js';
|
|
10
|
-
export * from './core/aggregation/signing-session.js';
|
|
11
|
-
export * from './core/aggregation/phases.js';
|
|
12
|
-
export * from './core/aggregation/errors.js';
|
|
13
|
-
export * from './core/aggregation/beacon-strategy.js';
|
|
14
|
-
export * from './core/aggregation/logger.js';
|
|
15
|
-
export * from './core/aggregation/messages/index.js';
|
|
16
|
-
export * from './core/aggregation/transport/index.js';
|
|
17
|
-
export * from './core/aggregation/runner/index.js';
|
|
1
|
+
// Aggregation (extracted to @did-btcr2/aggregation; re-exported here for backward compatibility)
|
|
2
|
+
export * from '@did-btcr2/aggregation';
|
|
18
3
|
// Beacons
|
|
19
4
|
export * from './core/beacon/beacon.js';
|
|
20
5
|
export * from './core/beacon/cas-beacon.js';
|
|
@@ -27,6 +12,7 @@ export * from './core/beacon/singleton-beacon.js';
|
|
|
27
12
|
export * from './core/beacon/smt-beacon.js';
|
|
28
13
|
export * from './core/beacon/utils.js';
|
|
29
14
|
// Core
|
|
15
|
+
export * from './core/did-sender-resolver.js';
|
|
30
16
|
export * from './core/identifier.js';
|
|
31
17
|
export * from './core/interfaces.js';
|
|
32
18
|
export * from './core/resolver.js';
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,cAAc,wBAAwB,CAAC;AAEvC,UAAU;AACV,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AAEvC,OAAO;AACP,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAElC,QAAQ;AACR,cAAc,qBAAqB,CAAC;AACpC,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AAExC,SAAS;AACT,cAAc,gBAAgB,CAAC"}
|
|
@@ -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. */
|
|
@@ -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
|
|
@@ -189,8 +243,9 @@ export declare abstract class SinglePartyBeacon {
|
|
|
189
243
|
* the input accordingly. Validates that the signer's pubkey produces the beacon
|
|
190
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,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAA4D,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC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;;;;;;;;;OAUG;cACa,kBAAkB,CAAC,IAAI,EAAE;QACvC,WAAW,EAAE,UAAU,CAAC;QACxB,aAAa,EAAE,MAAM,CAAC;QACtB,IAAI,EAAE,WAAW,CAAC;QAClB,WAAW,EAAE,UAAU,CAAC;QACxB,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,iBAAiB,CAAC;QAC3B,YAAY,EAAE,YAAY,CAAC;QAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,GAAG,OAAO,CAAC,YAAY,CAAC;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,40 +1,13 @@
|
|
|
1
|
+
import { StaticFeeEstimator } from '@did-btcr2/bitcoin';
|
|
2
|
+
import type { FeeEstimator } from '@did-btcr2/bitcoin';
|
|
3
|
+
export { StaticFeeEstimator };
|
|
4
|
+
export type { FeeEstimator };
|
|
1
5
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* etc.
|
|
8
|
-
*
|
|
9
|
-
* Implementations return the **total fee in satoshis** for a transaction of
|
|
10
|
-
* the given virtual size (`vsize`). Callers pass the vsize; the estimator
|
|
11
|
-
* decides the fee rate and computes the total.
|
|
6
|
+
* Default fee estimator used when a caller supplies none: a static 5 sat/vB rate.
|
|
7
|
+
* Suitable for tests and regtest. Production callers should inject a dynamic
|
|
8
|
+
* estimator (a mempool API, or Bitcoin Core `estimatesmartfee`) at the point the
|
|
9
|
+
* beacon transaction is built (single-party broadcast options, or the aggregation
|
|
10
|
+
* service runner's fee estimator).
|
|
12
11
|
*/
|
|
13
|
-
export
|
|
14
|
-
/**
|
|
15
|
-
* Estimate the total fee in satoshis for a transaction of the given vsize.
|
|
16
|
-
* @param vsize Transaction virtual size in vbytes.
|
|
17
|
-
* @returns Total fee in satoshis.
|
|
18
|
-
*/
|
|
19
|
-
estimateFee(vsize: number): Promise<bigint>;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Fee estimator that returns a fixed fee rate regardless of network conditions.
|
|
23
|
-
*
|
|
24
|
-
* Suitable for:
|
|
25
|
-
* - Tests (deterministic outputs)
|
|
26
|
-
* - Regtest (no real fee market)
|
|
27
|
-
* - Environments where a fee rate is supplied out-of-band
|
|
28
|
-
*
|
|
29
|
-
* For mainnet production use, prefer a dynamic estimator that queries current
|
|
30
|
-
* network conditions (mempool APIs, Bitcoin Core RPC).
|
|
31
|
-
*/
|
|
32
|
-
export declare class StaticFeeEstimator implements FeeEstimator {
|
|
33
|
-
readonly satsPerVbyte: number;
|
|
34
|
-
/**
|
|
35
|
-
* @param satsPerVbyte Fee rate in satoshis per virtual byte. Default: 5 sat/vB.
|
|
36
|
-
*/
|
|
37
|
-
constructor(satsPerVbyte?: number);
|
|
38
|
-
estimateFee(vsize: number): Promise<bigint>;
|
|
39
|
-
}
|
|
12
|
+
export declare const DEFAULT_FEE_ESTIMATOR: FeeEstimator;
|
|
40
13
|
//# sourceMappingURL=fee-estimator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fee-estimator.d.ts","sourceRoot":"","sources":["../../../../src/core/beacon/fee-estimator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fee-estimator.d.ts","sourceRoot":"","sources":["../../../../src/core/beacon/fee-estimator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAC9B,YAAY,EAAE,YAAY,EAAE,CAAC;AAE7B;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,EAAE,YAAwC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CompressedSecp256k1PublicKey } from '@did-btcr2/keypair';
|
|
2
|
+
/**
|
|
3
|
+
* 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).
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveBtcr2SenderPk(did: string): CompressedSecp256k1PublicKey | undefined;
|
|
14
|
+
//# sourceMappingURL=did-sender-resolver.d.ts.map
|
|
@@ -0,0 +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"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,19 +1,4 @@
|
|
|
1
|
-
export * from '
|
|
2
|
-
export * from './core/aggregation/participant.js';
|
|
3
|
-
export * from './core/aggregation/signer.js';
|
|
4
|
-
export * from './core/aggregation/conditions.js';
|
|
5
|
-
export * from './core/aggregation/recovery-policy.js';
|
|
6
|
-
export * from './core/aggregation/recovery-spend.js';
|
|
7
|
-
export * from './core/aggregation/fallback-spend.js';
|
|
8
|
-
export * from './core/aggregation/cohort.js';
|
|
9
|
-
export * from './core/aggregation/signing-session.js';
|
|
10
|
-
export * from './core/aggregation/phases.js';
|
|
11
|
-
export * from './core/aggregation/errors.js';
|
|
12
|
-
export * from './core/aggregation/beacon-strategy.js';
|
|
13
|
-
export * from './core/aggregation/logger.js';
|
|
14
|
-
export * from './core/aggregation/messages/index.js';
|
|
15
|
-
export * from './core/aggregation/transport/index.js';
|
|
16
|
-
export * from './core/aggregation/runner/index.js';
|
|
1
|
+
export * from '@did-btcr2/aggregation';
|
|
17
2
|
export * from './core/beacon/beacon.js';
|
|
18
3
|
export * from './core/beacon/cas-beacon.js';
|
|
19
4
|
export * from './core/beacon/error.js';
|
|
@@ -24,6 +9,7 @@ export * from './core/beacon/signal-discovery.js';
|
|
|
24
9
|
export * from './core/beacon/singleton-beacon.js';
|
|
25
10
|
export * from './core/beacon/smt-beacon.js';
|
|
26
11
|
export * from './core/beacon/utils.js';
|
|
12
|
+
export * from './core/did-sender-resolver.js';
|
|
27
13
|
export * from './core/identifier.js';
|
|
28
14
|
export * from './core/interfaces.js';
|
|
29
15
|
export * from './core/resolver.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,wBAAwB,CAAC;AAGvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AAGvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AAGxC,cAAc,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@did-btcr2/method",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.39.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Reference implementation for the did:btcr2 DID method written in TypeScript and JavaScript. did:btcr2 is a censorship resistant DID Method using the Bitcoin blockchain as a Verifiable Data Registry to announce changes to the DID document. This is the core method implementation for the did-btcr2-js monorepo.",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -80,11 +80,12 @@
|
|
|
80
80
|
"helia": "^5.5.1",
|
|
81
81
|
"multiformats": "^13.4.2",
|
|
82
82
|
"nostr-tools": "^2.23.3",
|
|
83
|
-
"@did-btcr2/bitcoin": "^0.
|
|
84
|
-
"@did-btcr2/common": "^9.1.0",
|
|
85
|
-
"@did-btcr2/smt": "^0.3.0",
|
|
83
|
+
"@did-btcr2/bitcoin": "^0.7.0",
|
|
86
84
|
"@did-btcr2/cryptosuite": "^8.0.0",
|
|
87
|
-
"@did-btcr2/
|
|
85
|
+
"@did-btcr2/common": "^9.1.0",
|
|
86
|
+
"@did-btcr2/aggregation": "^0.1.0",
|
|
87
|
+
"@did-btcr2/keypair": "^0.13.1",
|
|
88
|
+
"@did-btcr2/smt": "^0.3.0"
|
|
88
89
|
},
|
|
89
90
|
"devDependencies": {
|
|
90
91
|
"@eslint/js": "^9.39.4",
|