@did-btcr2/method 0.25.3 → 0.26.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 -0
- package/dist/browser.js +125307 -122227
- package/dist/browser.mjs +125266 -122186
- package/dist/cjs/index.js +5043 -43
- package/dist/esm/core/beacon/aggregation/cohort/index.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js +1 -2
- package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/coordinator.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/participant.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/session/index.js.map +1 -1
- package/dist/esm/core/beacon/cas-beacon.js +6 -4
- package/dist/esm/core/beacon/cas-beacon.js.map +1 -1
- package/dist/esm/core/beacon/signal-discovery.js +1 -1
- package/dist/esm/core/beacon/signal-discovery.js.map +1 -1
- package/dist/esm/core/beacon/singleton-beacon.js +3 -3
- package/dist/esm/core/beacon/singleton-beacon.js.map +1 -1
- package/dist/esm/core/beacon/utils.js.map +1 -1
- package/dist/esm/core/identifier.js.map +1 -1
- package/dist/esm/core/resolver.js +41 -35
- package/dist/esm/core/resolver.js.map +1 -1
- package/dist/esm/core/update.js.map +1 -1
- package/dist/esm/did-btcr2.js +1 -1
- package/dist/esm/did-btcr2.js.map +1 -1
- package/dist/esm/utils/appendix.js +7 -6
- package/dist/esm/utils/appendix.js.map +1 -1
- package/dist/esm/utils/did-document-builder.js.map +1 -1
- package/dist/esm/utils/did-document.js +2 -2
- package/dist/esm/utils/did-document.js.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/index.d.ts +2 -2
- package/dist/types/core/beacon/aggregation/cohort/index.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts +10 -10
- package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts +4 -4
- package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts +6 -6
- package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/communication/factory.d.ts +1 -1
- package/dist/types/core/beacon/aggregation/communication/factory.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/communication/service.d.ts +3 -3
- package/dist/types/core/beacon/aggregation/communication/service.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/coordinator.d.ts +3 -3
- package/dist/types/core/beacon/aggregation/coordinator.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/participant.d.ts +6 -6
- package/dist/types/core/beacon/aggregation/participant.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/session/index.d.ts +2 -2
- package/dist/types/core/beacon/aggregation/session/index.d.ts.map +1 -1
- package/dist/types/core/beacon/beacon.d.ts +5 -5
- package/dist/types/core/beacon/beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/cas-beacon.d.ts +5 -5
- package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/factory.d.ts +2 -2
- package/dist/types/core/beacon/factory.d.ts.map +1 -1
- package/dist/types/core/beacon/interfaces.d.ts +3 -3
- package/dist/types/core/beacon/interfaces.d.ts.map +1 -1
- package/dist/types/core/beacon/signal-discovery.d.ts +3 -3
- package/dist/types/core/beacon/signal-discovery.d.ts.map +1 -1
- package/dist/types/core/beacon/singleton-beacon.d.ts +5 -5
- package/dist/types/core/beacon/singleton-beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/smt-beacon.d.ts +5 -5
- package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/utils.d.ts +4 -4
- package/dist/types/core/beacon/utils.d.ts.map +1 -1
- package/dist/types/core/identifier.d.ts +2 -2
- package/dist/types/core/identifier.d.ts.map +1 -1
- package/dist/types/core/interfaces.d.ts +2 -2
- package/dist/types/core/interfaces.d.ts.map +1 -1
- package/dist/types/core/resolver.d.ts +8 -8
- package/dist/types/core/resolver.d.ts.map +1 -1
- package/dist/types/core/types.d.ts +6 -5
- package/dist/types/core/types.d.ts.map +1 -1
- package/dist/types/core/update.d.ts +5 -5
- package/dist/types/core/update.d.ts.map +1 -1
- package/dist/types/did-btcr2.d.ts +6 -6
- package/dist/types/did-btcr2.d.ts.map +1 -1
- package/dist/types/utils/appendix.d.ts +7 -7
- package/dist/types/utils/appendix.d.ts.map +1 -1
- package/dist/types/utils/did-document-builder.d.ts +3 -2
- package/dist/types/utils/did-document-builder.d.ts.map +1 -1
- package/dist/types/utils/did-document.d.ts +3 -3
- package/dist/types/utils/did-document.d.ts.map +1 -1
- package/package.json +7 -6
- package/src/core/beacon/aggregation/cohort/index.ts +3 -2
- package/src/core/beacon/aggregation/cohort/messages/index.ts +10 -10
- package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.ts +2 -1
- package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.ts +2 -1
- package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.ts +2 -1
- package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in.ts +2 -1
- package/src/core/beacon/aggregation/cohort/messages/keygen/subscribe.ts +2 -1
- package/src/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.ts +2 -1
- package/src/core/beacon/aggregation/cohort/messages/sign/authorization-request.ts +2 -1
- package/src/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.ts +2 -1
- package/src/core/beacon/aggregation/cohort/messages/sign/request-signature.ts +2 -1
- package/src/core/beacon/aggregation/cohort/messages/sign/signature-authorization.ts +2 -1
- package/src/core/beacon/aggregation/communication/adapter/did-comm.ts +5 -4
- package/src/core/beacon/aggregation/communication/adapter/nostr.ts +9 -7
- package/src/core/beacon/aggregation/communication/factory.ts +1 -1
- package/src/core/beacon/aggregation/communication/service.ts +3 -3
- package/src/core/beacon/aggregation/coordinator.ts +12 -8
- package/src/core/beacon/aggregation/participant.ts +12 -7
- package/src/core/beacon/aggregation/session/index.ts +3 -2
- package/src/core/beacon/beacon.ts +5 -5
- package/src/core/beacon/cas-beacon.ts +13 -9
- package/src/core/beacon/factory.ts +2 -2
- package/src/core/beacon/interfaces.ts +3 -3
- package/src/core/beacon/signal-discovery.ts +5 -4
- package/src/core/beacon/singleton-beacon.ts +8 -7
- package/src/core/beacon/smt-beacon.ts +5 -5
- package/src/core/beacon/utils.ts +6 -4
- package/src/core/identifier.ts +3 -2
- package/src/core/interfaces.ts +2 -2
- package/src/core/resolver.ts +59 -51
- package/src/core/types.ts +6 -5
- package/src/core/update.ts +11 -7
- package/src/did-btcr2.ts +12 -10
- package/src/utils/appendix.ts +14 -16
- package/src/utils/did-document-builder.ts +3 -2
- package/src/utils/did-document.ts +10 -8
- package/dist/cjs/core/beacon/aggregation/cohort/index.js +0 -237
- package/dist/cjs/core/beacon/aggregation/cohort/index.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js +0 -26
- package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/constants.js +0 -11
- package/dist/cjs/core/beacon/aggregation/cohort/messages/constants.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/index.js +0 -98
- package/dist/cjs/core/beacon/aggregation/cohort/messages/index.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +0 -31
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +0 -29
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +0 -27
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +0 -23
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +0 -28
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +0 -29
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +0 -30
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +0 -30
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js +0 -30
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +0 -31
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/cohort/status.js +0 -8
- package/dist/cjs/core/beacon/aggregation/cohort/status.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/communication/adapter/did-comm.js +0 -121
- package/dist/cjs/core/beacon/aggregation/communication/adapter/did-comm.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js +0 -246
- package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/communication/error.js +0 -12
- package/dist/cjs/core/beacon/aggregation/communication/error.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/communication/factory.js +0 -21
- package/dist/cjs/core/beacon/aggregation/communication/factory.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/communication/service.js +0 -2
- package/dist/cjs/core/beacon/aggregation/communication/service.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/coordinator.js +0 -343
- package/dist/cjs/core/beacon/aggregation/coordinator.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/participant.js +0 -435
- package/dist/cjs/core/beacon/aggregation/participant.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/session/index.js +0 -244
- package/dist/cjs/core/beacon/aggregation/session/index.js.map +0 -1
- package/dist/cjs/core/beacon/aggregation/session/status.js +0 -11
- package/dist/cjs/core/beacon/aggregation/session/status.js.map +0 -1
- package/dist/cjs/core/beacon/beacon.js +0 -25
- package/dist/cjs/core/beacon/beacon.js.map +0 -1
- package/dist/cjs/core/beacon/cas-beacon.js +0 -152
- package/dist/cjs/core/beacon/cas-beacon.js.map +0 -1
- package/dist/cjs/core/beacon/error.js +0 -37
- package/dist/cjs/core/beacon/error.js.map +0 -1
- package/dist/cjs/core/beacon/factory.js +0 -29
- package/dist/cjs/core/beacon/factory.js.map +0 -1
- package/dist/cjs/core/beacon/interfaces.js +0 -2
- package/dist/cjs/core/beacon/interfaces.js.map +0 -1
- package/dist/cjs/core/beacon/signal-discovery.js +0 -183
- package/dist/cjs/core/beacon/signal-discovery.js.map +0 -1
- package/dist/cjs/core/beacon/singleton-beacon.js +0 -107
- package/dist/cjs/core/beacon/singleton-beacon.js.map +0 -1
- package/dist/cjs/core/beacon/smt-beacon.js +0 -39
- package/dist/cjs/core/beacon/smt-beacon.js.map +0 -1
- package/dist/cjs/core/beacon/utils.js +0 -163
- package/dist/cjs/core/beacon/utils.js.map +0 -1
- package/dist/cjs/core/identifier.js +0 -248
- package/dist/cjs/core/identifier.js.map +0 -1
- package/dist/cjs/core/interfaces.js +0 -2
- package/dist/cjs/core/interfaces.js.map +0 -1
- package/dist/cjs/core/resolver.js +0 -476
- package/dist/cjs/core/resolver.js.map +0 -1
- package/dist/cjs/core/types.js +0 -2
- package/dist/cjs/core/types.js.map +0 -1
- package/dist/cjs/core/update.js +0 -112
- package/dist/cjs/core/update.js.map +0 -1
- package/dist/cjs/did-btcr2.js +0 -193
- package/dist/cjs/did-btcr2.js.map +0 -1
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/utils/appendix.js +0 -203
- package/dist/cjs/utils/appendix.js.map +0 -1
- package/dist/cjs/utils/did-document-builder.js +0 -60
- package/dist/cjs/utils/did-document-builder.js.map +0 -1
- package/dist/cjs/utils/did-document.js +0 -424
- package/dist/cjs/utils/did-document.js.map +0 -1
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { GENESIS_TX_ID, TXIN_WITNESS_COINBASE } from '@did-btcr2/bitcoin';
|
|
2
|
-
import { ResolveError } from '@did-btcr2/common';
|
|
3
|
-
import { BeaconUtils } from './utils.js';
|
|
4
|
-
/**
|
|
5
|
-
* Static utility class for discovering Beacon Signals on the Bitcoin blockchain.
|
|
6
|
-
* Extracted from {@link Resolve} for single-responsibility and independent testability.
|
|
7
|
-
*
|
|
8
|
-
* @class BeaconSignalDiscovery
|
|
9
|
-
*/
|
|
10
|
-
export class BeaconSignalDiscovery {
|
|
11
|
-
/**
|
|
12
|
-
* Retrieves the beacon signals for the given array of BeaconService objects
|
|
13
|
-
* using an esplora/electrs REST API connection via a bitcoin I/O driver.
|
|
14
|
-
* @param {Array<BeaconService>} beaconServices Array of BeaconService objects to retrieve signals for
|
|
15
|
-
* @param {BitcoinConnection} bitcoin Bitcoin network connection to use for REST calls
|
|
16
|
-
* @returns {Promise<Map<BeaconService, Array<BeaconSignal>>>} Map of beacon service to its discovered signals
|
|
17
|
-
*/
|
|
18
|
-
static async indexer(beaconServices, bitcoin) {
|
|
19
|
-
const beaconServiceSignals = new Map();
|
|
20
|
-
// Fetch the current block count once before the loop
|
|
21
|
-
const currentBlockCount = await bitcoin.rest.block.count();
|
|
22
|
-
// Iterate over each beacon
|
|
23
|
-
for (const beaconService of beaconServices) {
|
|
24
|
-
beaconServiceSignals.set(beaconService, []);
|
|
25
|
-
// Get the transactions for the beacon address via REST
|
|
26
|
-
const beaconSignals = await bitcoin.rest.address.getTxs(BeaconUtils.parseBitcoinAddress(beaconService.serviceEndpoint));
|
|
27
|
-
// If no signals are found, continue
|
|
28
|
-
if (!beaconSignals || !beaconSignals.length) {
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
// Iterate over each signal
|
|
32
|
-
for (const beaconSignal of beaconSignals) {
|
|
33
|
-
// Get the last vout in the transaction
|
|
34
|
-
const signalVout = beaconSignal.vout.slice(-1)[0];
|
|
35
|
-
/**
|
|
36
|
-
* Look for OP_RETURN in last vout scriptpubkey_asm
|
|
37
|
-
* Vout (rest) format:
|
|
38
|
-
* {
|
|
39
|
-
* scriptpubkey: '6a20570f177c65e64fb5cf61180b664cdddf09ab76153c2b192e22006e5b22a3917a',
|
|
40
|
-
* scriptpubkey_asm: 'OP_RETURN OP_PUSHBYTES_32 570f177c65e64fb5cf61180b664cdddf09ab76153c2b192e22006e5b22a3917a',
|
|
41
|
-
* scriptpubkey_type: 'op_return',
|
|
42
|
-
* value: 0
|
|
43
|
-
* }
|
|
44
|
-
*/
|
|
45
|
-
if (!signalVout || !signalVout.scriptpubkey_asm.includes('OP_RETURN')) {
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
// Construct output map for easier access
|
|
49
|
-
const outputMap = new Map(Object.entries(signalVout));
|
|
50
|
-
// Grab the signal vout scriptpubkey
|
|
51
|
-
const signalVoutScriptPubkey = outputMap.get('scriptpubkey_asm');
|
|
52
|
-
// If the signal vout scriptpubkey does not exist, continue to next signal
|
|
53
|
-
if (!signalVoutScriptPubkey) {
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
// Extract hex string hash of the signal bytes from the scriptpubkey
|
|
57
|
-
const updateHash = signalVoutScriptPubkey.split(' ').slice(-1)[0];
|
|
58
|
-
if (!updateHash) {
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
// Use the pre-fetched block count instead of calling per-signal
|
|
62
|
-
const confirmations = currentBlockCount - beaconSignal.status.block_height + 1;
|
|
63
|
-
// Push the beacon signal object to the signals array for the beacon service
|
|
64
|
-
beaconServiceSignals.get(beaconService)?.push({
|
|
65
|
-
tx: beaconSignal,
|
|
66
|
-
signalBytes: updateHash,
|
|
67
|
-
blockMetadata: {
|
|
68
|
-
confirmations,
|
|
69
|
-
height: beaconSignal.status.block_height,
|
|
70
|
-
time: beaconSignal.status.block_time,
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return beaconServiceSignals;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Traverse the full blockchain from genesis to chain top looking for beacon signals.
|
|
79
|
-
* @param {Array<BeaconService>} beaconServices Array of BeaconService objects to search for signals.
|
|
80
|
-
* @param {BitcoinConnection} bitcoin Bitcoin network connection to use for RPC calls.
|
|
81
|
-
* @returns {Promise<Map<BeaconService, Array<BeaconSignal>>>} Map of beacon service to its discovered signals.
|
|
82
|
-
*/
|
|
83
|
-
static async fullnode(beaconServices, bitcoin) {
|
|
84
|
-
const beaconServiceSignals = new Map();
|
|
85
|
-
for (const beaconService of beaconServices) {
|
|
86
|
-
beaconServiceSignals.set(beaconService, []);
|
|
87
|
-
}
|
|
88
|
-
// Get the RPC connection from the bitcoin network
|
|
89
|
-
const rpc = bitcoin.rpc;
|
|
90
|
-
// Ensure that the RPC connection is available
|
|
91
|
-
if (!rpc) {
|
|
92
|
-
throw new ResolveError('RPC connection is not available', 'RPC_CONNECTION_ERROR', bitcoin);
|
|
93
|
-
}
|
|
94
|
-
// Get the current block height once before the loop
|
|
95
|
-
const targetHeight = await rpc.getBlockCount();
|
|
96
|
-
// Hoist the beacon services map before the loop
|
|
97
|
-
const beaconServicesMap = BeaconUtils.getBeaconServicesMap(beaconServices);
|
|
98
|
-
// Set genesis height
|
|
99
|
-
let height = 0;
|
|
100
|
-
// Opt into rpc connection to get the block data at the blockhash
|
|
101
|
-
let block = await bitcoin.rpc.getBlock({ height });
|
|
102
|
-
console.info(`Searching for beacon signals, please wait ...`);
|
|
103
|
-
while (block.height <= targetHeight) {
|
|
104
|
-
// Iterate over each transaction in the block
|
|
105
|
-
for (const tx of block.tx) {
|
|
106
|
-
// If the txid is a coinbase, continue ...
|
|
107
|
-
if (tx.txid === GENESIS_TX_ID) {
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
// Iterate over each input in the transaction
|
|
111
|
-
for (const vin of tx.vin) {
|
|
112
|
-
// If the vin is a coinbase transaction, continue ...
|
|
113
|
-
if (vin.coinbase) {
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
// If the vin txinwitness contains a coinbase did, continue ...
|
|
117
|
-
if (vin.txinwitness && vin.txinwitness.length === 1 && vin.txinwitness[0] === TXIN_WITNESS_COINBASE) {
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
// If the txid from the vin is undefined, continue ...
|
|
121
|
-
if (!vin.txid) {
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
// If the vout from the vin is undefined, continue ...
|
|
125
|
-
if (vin.vout === undefined) {
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
// Get the previous output transaction data
|
|
129
|
-
const prevout = await rpc.getRawTransaction(vin.txid, 2);
|
|
130
|
-
// If the previous output vout at the vin.vout index is undefined, continue ...
|
|
131
|
-
if (!prevout.vout[vin.vout]) {
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
// Get the address from the scriptPubKey from the prevvout
|
|
135
|
-
const scriptPubKey = prevout.vout[vin.vout].scriptPubKey;
|
|
136
|
-
// If the scriptPubKey.address is undefined, continue ...
|
|
137
|
-
if (!scriptPubKey.address) {
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
// Use the hoisted beaconServicesMap instead of rebuilding per-vin
|
|
141
|
-
const beaconService = beaconServicesMap.get(scriptPubKey.address);
|
|
142
|
-
if (!beaconService) {
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
// Look for 'OP_RETURN' in the scriptPubKey asm
|
|
146
|
-
const txVoutScriptPubkeyAsm = prevout.vout[vin.vout].scriptPubKey.asm;
|
|
147
|
-
if (!txVoutScriptPubkeyAsm.includes('OP_RETURN')) {
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
// Log the found txid and beacon
|
|
151
|
-
console.info(`Tx ${tx.txid} contains beacon service address ${scriptPubKey.address} and OP_RETURN!`, tx);
|
|
152
|
-
// Extract hex string hash of the signal bytes from the scriptpubkey
|
|
153
|
-
const updateHash = txVoutScriptPubkeyAsm.split(' ').slice(-1)[0];
|
|
154
|
-
if (!updateHash) {
|
|
155
|
-
continue;
|
|
156
|
-
}
|
|
157
|
-
// Push the beacon signal object to the beacon signals array for that beacon service
|
|
158
|
-
beaconServiceSignals.get(beaconService)?.push({
|
|
159
|
-
tx,
|
|
160
|
-
signalBytes: updateHash,
|
|
161
|
-
blockMetadata: {
|
|
162
|
-
height: block.height,
|
|
163
|
-
time: block.time,
|
|
164
|
-
confirmations: block.confirmations
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
;
|
|
169
|
-
}
|
|
170
|
-
// Increment the height
|
|
171
|
-
height += 1;
|
|
172
|
-
// Use pre-fetched targetHeight instead of calling rpc.getBlockCount() every iteration
|
|
173
|
-
if (height > targetHeight) {
|
|
174
|
-
console.info(`Chain tip reached ${height}, breaking ...`);
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
// Reset the block var to the next block data
|
|
178
|
-
block = await rpc.getBlock({ height });
|
|
179
|
-
}
|
|
180
|
-
return beaconServiceSignals;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
//# sourceMappingURL=signal-discovery.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signal-discovery.js","sourceRoot":"","sources":["../../../../src/core/beacon/signal-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EAEb,qBAAqB,EACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,OAAO,qBAAqB;IAEhC;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,OAAO,CAClB,cAAoC,EACpC,OAA0B;QAE1B,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAsC,CAAC;QAE3E,qDAAqD;QACrD,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QAE3D,2BAA2B;QAC3B,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE,CAAC;YAC3C,oBAAoB,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;YAC5C,uDAAuD;YACvD,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CACrD,WAAW,C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eyPair } from '@did-btcr2/keypair';
|
|
3
|
-
import { hexToBytes } from '@noble/hashes/utils';
|
|
4
|
-
import { opcodes, Psbt, script } from 'bitcoinjs-lib';
|
|
5
|
-
import { Beacon } from './beacon.js';
|
|
6
|
-
import { SingletonBeaconError } from './error.js';
|
|
7
|
-
/**
|
|
8
|
-
* Implements {@link https://dcdpr.github.io/did-btcr2/terminology.html#singleton-beacon | Singleton Beacon}.
|
|
9
|
-
* @class SingletonBeacon
|
|
10
|
-
* @type {SingletonBeacon}
|
|
11
|
-
* @extends {Beacon}
|
|
12
|
-
*/
|
|
13
|
-
export class SingletonBeacon extends Beacon {
|
|
14
|
-
/**
|
|
15
|
-
* Creates an instance of SingletonBeacon.
|
|
16
|
-
* @param {BeaconService} service The BeaconService object representing the funded beacon to announce the update to.
|
|
17
|
-
*/
|
|
18
|
-
constructor(service) {
|
|
19
|
-
super({ ...service, type: 'SingletonBeacon' });
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Processes an array of Beacon Signals associated with a Singleton Beacon Service.
|
|
23
|
-
* @param {Array<BeaconSignal>} signals The beacon signals discovered on-chain.
|
|
24
|
-
* @param {SidecarData} sidecar The processed sidecar data.
|
|
25
|
-
* @returns {BeaconProcessResult} Successfully resolved updates and any data needs.
|
|
26
|
-
*/
|
|
27
|
-
processSignals(signals, sidecar) {
|
|
28
|
-
const updates = new Array();
|
|
29
|
-
const needs = new Array();
|
|
30
|
-
for (const signal of signals) {
|
|
31
|
-
// Decode signal bytes from hex and re-encode to base64url for sidecar lookup
|
|
32
|
-
const updateHash = encode(decode(signal.signalBytes, 'hex'));
|
|
33
|
-
// Look up the signed update in sidecar updateMap
|
|
34
|
-
const signedUpdate = sidecar.updateMap.get(updateHash);
|
|
35
|
-
if (!signedUpdate) {
|
|
36
|
-
// Data not available — emit a need instead of throwing
|
|
37
|
-
needs.push({
|
|
38
|
-
kind: 'NeedSignedUpdate',
|
|
39
|
-
updateHash,
|
|
40
|
-
beaconServiceId: this.service.id
|
|
41
|
-
});
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
updates.push([signedUpdate, signal.blockMetadata]);
|
|
45
|
-
}
|
|
46
|
-
return { updates, needs };
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Broadcasts a SingletonBeacon signal to the Bitcoin network.
|
|
50
|
-
* @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
|
|
51
|
-
* @param {KeyBytes} secretKey The secret key for signing the Bitcoin transaction.
|
|
52
|
-
* @param {BitcoinConnection} bitcoin The Bitcoin network connection.
|
|
53
|
-
* @returns {Promise<SignedBTCR2Update>} The signed update that was broadcast.
|
|
54
|
-
* @throws {SingletonBeaconError} if the bitcoin address is invalid or unfunded.
|
|
55
|
-
*/
|
|
56
|
-
async broadcastSignal(signedUpdate, secretKey, bitcoin) {
|
|
57
|
-
// Convert the serviceEndpoint to a bitcoin address by removing the 'bitcoin:' prefix
|
|
58
|
-
const bitcoinAddress = this.service.serviceEndpoint.replace('bitcoin:', '');
|
|
59
|
-
// Query the Bitcoin network for UTXOs associated with the bitcoinAddress
|
|
60
|
-
const utxos = await bitcoin.rest.address.getUtxos(bitcoinAddress);
|
|
61
|
-
// If no utxos are found, throw an error indicating the address is unfunded.
|
|
62
|
-
if (!utxos.length) {
|
|
63
|
-
throw new SingletonBeaconError('No UTXOs found, please fund address!', 'UNFUNDED_BEACON_ADDRESS', { bitcoinAddress });
|
|
64
|
-
}
|
|
65
|
-
// Sort utxos by block height and take the most recent one
|
|
66
|
-
const utxo = utxos.sort((a, b) => b.status.block_height - a.status.block_height).shift();
|
|
67
|
-
// If no utxos are found, throw an error.
|
|
68
|
-
if (!utxo) {
|
|
69
|
-
throw new SingletonBeaconError('Beacon bitcoin address unfunded or utxos unconfirmed.', 'UNFUNDED_BEACON_ADDRESS', { bitcoinAddress });
|
|
70
|
-
}
|
|
71
|
-
// Get the previous tx to the utxo being spent
|
|
72
|
-
const prevTx = await bitcoin.rest.transaction.getHex(utxo.txid);
|
|
73
|
-
// Canonicalize and hash the signed update for OP_RETURN output
|
|
74
|
-
const updateHash = hash(canonicalize(signedUpdate));
|
|
75
|
-
// Construct a spend transaction
|
|
76
|
-
const spendTx = new Psbt({ network: bitcoin.data })
|
|
77
|
-
// Spend tx contains the utxo as its input
|
|
78
|
-
.addInput({
|
|
79
|
-
hash: utxo.txid,
|
|
80
|
-
index: utxo.vout,
|
|
81
|
-
nonWitnessUtxo: hexToBytes(prevTx)
|
|
82
|
-
})
|
|
83
|
-
// Add a change output minus a fee of 500 sats
|
|
84
|
-
// TODO: calculate fee based on transaction vsize and current fee rates
|
|
85
|
-
.addOutput({ address: bitcoinAddress, value: BigInt(utxo.value) - BigInt(500) })
|
|
86
|
-
// Add an OP_RETURN output containing the update hash
|
|
87
|
-
.addOutput({ script: script.compile([opcodes.OP_RETURN, updateHash]), value: 0n });
|
|
88
|
-
// Construct a key pair and PSBT signer from the secret key
|
|
89
|
-
const keyPair = SchnorrKeyPair.fromSecret(secretKey);
|
|
90
|
-
const signer = {
|
|
91
|
-
publicKey: keyPair.publicKey.compressed,
|
|
92
|
-
sign: (hash) => keyPair.secretKey.sign(hash, { scheme: 'ecdsa' }),
|
|
93
|
-
};
|
|
94
|
-
// Sign 0th input, finalize extract to hex in prep for broadcast
|
|
95
|
-
const signedTx = spendTx.signInput(0, signer)
|
|
96
|
-
.finalizeAllInputs()
|
|
97
|
-
.extractTransaction()
|
|
98
|
-
.toHex();
|
|
99
|
-
// Broadcast spendTx to the Bitcoin network.
|
|
100
|
-
const txid = await bitcoin.rest.transaction.send(signedTx);
|
|
101
|
-
// Log the txid of the broadcasted transaction
|
|
102
|
-
console.info(`Singleton Beacon Signal Broadcasted with txid: ${txid}`);
|
|
103
|
-
// Return the signed update
|
|
104
|
-
return signedUpdate;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
//# sourceMappingURL=singleton-beacon.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
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CAAC;QAEvE,2BAA2B;QAC3B,OAAO,YAAY,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Beacon } from './beacon.js';
|
|
2
|
-
import { SMTBeaconError } from './error.js';
|
|
3
|
-
/**
|
|
4
|
-
* Implements {@link https://dcdpr.github.io/did-btcr2/terminology.html#smt-beacon | SMTBeacon}.
|
|
5
|
-
* @class SMTBeacon
|
|
6
|
-
* @type {SMTBeacon}
|
|
7
|
-
* @extends {Beacon}
|
|
8
|
-
*/
|
|
9
|
-
export class SMTBeacon extends Beacon {
|
|
10
|
-
/**
|
|
11
|
-
* Creates an instance of SMTBeacon.
|
|
12
|
-
* @param {BeaconService} service The Beacon service.
|
|
13
|
-
*/
|
|
14
|
-
constructor(service) {
|
|
15
|
-
super({ ...service, type: 'SMTBeacon' });
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Implements {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process-smt-beacon | 7.2.e.1 Process SMT Beacon}.
|
|
19
|
-
* @param {Array<BeaconSignal>} signals The array of Beacon Signals to process.
|
|
20
|
-
* @param {SidecarData} sidecar The sidecar data associated with the SMT Beacon.
|
|
21
|
-
* @returns {BeaconProcessResult} The processed signals.
|
|
22
|
-
* @throws {SMTBeaconError} if processing fails.
|
|
23
|
-
*/
|
|
24
|
-
processSignals(signals, sidecar) {
|
|
25
|
-
throw new SMTBeaconError('Method not implemented.', `METHOD_NOT_IMPLEMENTED`, { signals, sidecar });
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Broadcast CAS Beacon signal to the Bitcoin network.
|
|
29
|
-
* @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
|
|
30
|
-
* @param {KeyBytes} secretKey The secret key for signing the Bitcoin transaction.
|
|
31
|
-
* @param {BitcoinConnection} bitcoin The Bitcoin network connection.
|
|
32
|
-
* @return {Promise<SignedBTCR2Update>} The signed update that was broadcasted.
|
|
33
|
-
* @throws {SMTBeaconError} if broadcasting fails.
|
|
34
|
-
*/
|
|
35
|
-
async broadcastSignal(signedUpdate, secretKey, bitcoin) {
|
|
36
|
-
throw new SMTBeaconError('Method not implemented.', `METHOD_NOT_IMPLEMENTED`, { signedUpdate, secretKey, bitcoin });
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=smt-beacon.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"smt-beacon.js","sourceRoot":"","sources":["../../../../src/core/beacon/smt-beacon.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C;;;;;GAKG;AACH,MAAM,OAAO,SAAU,SAAQ,MAAM;IACnC;;;OAGG;IACH,YAAY,OAAsB;QAChC,KAAK,CAAC,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;OAMG;IACH,cAAc,CACZ,OAA4B,EAC5B,OAAoB;QAEpB,MAAM,IAAI,cAAc,CAAC,yBAAyB,EAAE,wBAAwB,EAAE,EAAC,OAAO,EAAE,OAAO,EAAC,CAAC,CAAC;IACpG,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,eAAe,CACnB,YAA+B,EAC/B,SAAmB,EACnB,OAA0B;QAE1B,MAAM,IAAI,cAAc,CAAC,yBAAyB,EAAE,wBAAwB,EAAE,EAAC,YAAY,EAAE,SAAS,EAAE,OAAO,EAAC,CAAC,CAAC;IACpH,CAAC;CACF"}
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { getNetwork } from '@did-btcr2/bitcoin';
|
|
2
|
-
import { DidMethodError, MethodError } from '@did-btcr2/common';
|
|
3
|
-
import { payments } from 'bitcoinjs-lib';
|
|
4
|
-
import { Appendix } from '../../utils/appendix.js';
|
|
5
|
-
import { Identifier } from '../identifier.js';
|
|
6
|
-
import { BeaconError } from './error.js';
|
|
7
|
-
/**
|
|
8
|
-
* Static class of utility functions for the Beacon Service
|
|
9
|
-
* @class BeaconUtils
|
|
10
|
-
* @type {BeaconUtils}
|
|
11
|
-
*/
|
|
12
|
-
export class BeaconUtils {
|
|
13
|
-
/**
|
|
14
|
-
* Converts a BIP21 Bitcoin URI to a Bitcoin address
|
|
15
|
-
* @param {string} uri The BIP21 Bitcoin URI to convert
|
|
16
|
-
* @returns {string} The Bitcoin address extracted from the URI
|
|
17
|
-
* @throws {DidMethodError} if the URI is not a valid Bitcoin URI
|
|
18
|
-
*/
|
|
19
|
-
static parseBitcoinAddress(uri) {
|
|
20
|
-
if (!uri.startsWith('bitcoin:')) {
|
|
21
|
-
throw new MethodError('Invalid Bitcoin URI format', 'BEACON_SERVICE_ERROR', { uri });
|
|
22
|
-
}
|
|
23
|
-
return uri.replace('bitcoin:', '').split('?')[0];
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Validates that the given object is a Beacon Service
|
|
27
|
-
* @param {BeaconService} obj The object to validate
|
|
28
|
-
* @returns {boolean} A boolean indicating whether the object is a Beacon Service
|
|
29
|
-
*/
|
|
30
|
-
static isBeaconService(obj) {
|
|
31
|
-
// Return false if the given obj is not a valid DidService.
|
|
32
|
-
if (!Appendix.isDidService(obj))
|
|
33
|
-
return false;
|
|
34
|
-
// Return false if the type is not a valid beacon service type.
|
|
35
|
-
if (!['SingletonBeacon', 'CASBeacon', 'SMTBeacon'].includes(obj.type))
|
|
36
|
-
return false;
|
|
37
|
-
// Return false if the serviceEndpoint is not a valid BIP21 bitcoin address.
|
|
38
|
-
if ([obj.serviceEndpoint].flat().some(ep => typeof ep === 'string' && !ep.startsWith('bitcoin:')))
|
|
39
|
-
return false;
|
|
40
|
-
// Else return true
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Extracts the services from a given DID Document
|
|
45
|
-
* @param {DidDocument} didDocument The DID Document to extract the services from
|
|
46
|
-
* @returns {DidService[]} An array of DidService objects
|
|
47
|
-
* @throws {TypeError} if the didDocument is not provided
|
|
48
|
-
*/
|
|
49
|
-
static getBeaconServices(didDocument) {
|
|
50
|
-
// Filter for valid beacon service objects.
|
|
51
|
-
return (didDocument.service.filter(this.isBeaconService) ?? []);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Create the 3 default Beacon Service Endpoints for a given `k` (public-key-based) identifier.
|
|
55
|
-
* @param {string} did The DID for which to create the beacon services.
|
|
56
|
-
* @returns {Array<Array<string>>} 2D Array of bitcoin addresses (p2pkh, p2wpkh, p2tr).
|
|
57
|
-
* @throws {DidMethodError} if the bitcoin address is invalid.
|
|
58
|
-
*/
|
|
59
|
-
static createBeaconServices(did, beaconType) {
|
|
60
|
-
try {
|
|
61
|
-
// Get the Network class
|
|
62
|
-
const addrTypes = ['p2pkh', 'p2wpkh', 'p2tr'];
|
|
63
|
-
// Map over the address types and create the beacon services
|
|
64
|
-
return addrTypes.map((addrType) => this.createBeaconService(did, addrType, beaconType));
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
throw new BeaconError('Failed to create beacon services: ' + error.message, 'BEACON_SERVICE_ERROR', { did, beaconType });
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Generate a set of Beacon Services for a given public key.
|
|
72
|
-
* @param {string} did The did for the beacon service.
|
|
73
|
-
* @param {string} addressType The type of bitcoin address to generate (p2pkh, p2wpkh, p2tr).
|
|
74
|
-
* @param {string} beaconType The type of beacon service to create.
|
|
75
|
-
* @returns {BeaconService} A BeaconService object.
|
|
76
|
-
* @throws {DidMethodError} if the bitcoin address is invalid.
|
|
77
|
-
*/
|
|
78
|
-
static createBeaconService(did, addressType, beaconType) {
|
|
79
|
-
try {
|
|
80
|
-
// Decode the DID to get the network and genesis bytes
|
|
81
|
-
const components = Identifier.decode(did);
|
|
82
|
-
// Get the Network class
|
|
83
|
-
const network = getNetwork(components.network);
|
|
84
|
-
// Get the genesis bytes
|
|
85
|
-
const pubkey = components.genesisBytes;
|
|
86
|
-
// Build the id
|
|
87
|
-
const id = `${did}#initial${addressType.toUpperCase()}`;
|
|
88
|
-
// Generate the bitcoin address
|
|
89
|
-
const serviceEndpoint = `bitcoin:${payments[addressType]({ pubkey, network }).address}`;
|
|
90
|
-
// Return the beacon serviceD
|
|
91
|
-
return { id, type: beaconType, serviceEndpoint, };
|
|
92
|
-
}
|
|
93
|
-
catch (error) {
|
|
94
|
-
throw new BeaconError('Failed to create beacon service: ' + error.message, 'BEACON_SERVICE_ERROR', { did, beaconType });
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Generate three default Beacon Service Endpoints for a given `k` (public-key-based) identifier.
|
|
99
|
-
* @param {string} did The DID for which to create the beacon services.
|
|
100
|
-
* @returns {Array<Array<string>>} 2D Array of bitcoin addresses (p2pkh, p2wpkh, p2tr).
|
|
101
|
-
* @throws {DidMethodError} if the bitcoin address is invalid.
|
|
102
|
-
*/
|
|
103
|
-
static generateBeaconServices({ id, publicKey, network, beaconType }) {
|
|
104
|
-
try {
|
|
105
|
-
// Generate the bitcoin addresses for the given public key and network
|
|
106
|
-
const p2pkh = payments.p2pkh({ pubkey: publicKey, network }).address;
|
|
107
|
-
const p2wpkh = payments.p2wpkh({ pubkey: publicKey, network }).address;
|
|
108
|
-
const p2tr = payments.p2tr({ network, internalPubkey: publicKey.slice(1, 33) }).address;
|
|
109
|
-
// Check that all addresses were generated successfully
|
|
110
|
-
if (!p2pkh || !p2wpkh || !p2tr) {
|
|
111
|
-
throw new DidMethodError('Failed to generate bitcoin addresses');
|
|
112
|
-
}
|
|
113
|
-
// Return the beacon services with the generated addresses as service endpoints
|
|
114
|
-
return [
|
|
115
|
-
{
|
|
116
|
-
id: `${id}#initialP2PKH`,
|
|
117
|
-
type: beaconType,
|
|
118
|
-
serviceEndpoint: `bitcoin:${p2pkh}`
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
id: `${id}#initialP2WPKH`,
|
|
122
|
-
type: beaconType,
|
|
123
|
-
serviceEndpoint: `bitcoin:${p2wpkh}`
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
id: `${id}#initialP2TR`,
|
|
127
|
-
type: beaconType,
|
|
128
|
-
serviceEndpoint: `bitcoin:${p2tr}`
|
|
129
|
-
},
|
|
130
|
-
];
|
|
131
|
-
}
|
|
132
|
-
catch (error) {
|
|
133
|
-
throw new BeaconError('Failed to create beacon services: ' + error.message, 'BEACON_SERVICE_ERROR', { id, publicKey, network, beaconType });
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Convert beacon service endpoints from BIP-21 URIs to addresses.
|
|
138
|
-
* @param {BeaconService} beacon The beacon service to parse.
|
|
139
|
-
* @returns {BeaconServiceAddress} The beacon service with the address field extracted from the serviceEndpoint.
|
|
140
|
-
*/
|
|
141
|
-
static parseBeaconServiceEndpoint(beacon) {
|
|
142
|
-
return { ...beacon, serviceEndpoint: beacon.serviceEndpoint.replace('bitcoin:', '') };
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Create a map of address => beaconService with address field.
|
|
146
|
-
* @param {Array<BeaconService>} beacons The list of beacon services.
|
|
147
|
-
* @returns {Map<string, BeaconService>} A map of address => beaconService.
|
|
148
|
-
*/
|
|
149
|
-
static getBeaconServicesMap(beacons) {
|
|
150
|
-
return new Map(beacons
|
|
151
|
-
.map(this.parseBeaconServiceEndpoint)
|
|
152
|
-
.map((beacon) => ([beacon.serviceEndpoint, beacon])));
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Get the beacon service ids from a list of beacon services.
|
|
156
|
-
* @param {DidDocument} didDocument The DID Document to extract the services from.
|
|
157
|
-
* @returns {string[]} An array of beacon service ids.
|
|
158
|
-
*/
|
|
159
|
-
static getBeaconServiceIds(didDocument) {
|
|
160
|
-
return this.getBeaconServices(didDocument).map((beacon) => beacon.id);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/core/beacon/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAmB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAY,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC;;;;GAIG;AACH,MAAM,OAAO,WAAW;IACtB;;;;;OAKG;IACH,MAAM,CAAC,mBAAmB,CAAC,GAAW;QACpC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,WAAW,CAAC,4BAA4B,EAAE,sBAAsB,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;QACvF,CAAC;QACD,OAAO,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACnD,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,eAAe,CAAC,GAAyB;QAC9C,2DAA2D;QAC3D,IAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;QAE7C,+DAA+D;QAC/D,IAAG,CAAC,CAAC,iBAAiB,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO,KAAK,CAAC;QAEnF,4EAA4E;QAC5E,IAAI,C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