dash-platform-sdk 1.4.0 → 1.5.0-dev.10
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/README.md +16 -15
- package/bundle.min.js +1 -21
- package/package.json +4 -3
- package/proto/generated/platform.client.d.ts +110 -0
- package/proto/generated/platform.client.js +89 -12
- package/proto/generated/platform.d.ts +1671 -0
- package/proto/generated/platform.js +3381 -1
- package/src/DashPlatformSDK.d.ts +2 -0
- package/src/DashPlatformSDK.js +3 -0
- package/src/constants.d.ts +2 -1
- package/src/constants.js +2 -1
- package/src/identities/createStateTransition.js +2 -2
- package/src/keyPair/index.d.ts +87 -0
- package/src/keyPair/index.js +128 -0
- package/src/node/{epochs.d.ts → epochInfos.d.ts} +1 -1
- package/src/node/{epochs.js → epochInfos.js} +1 -1
- package/src/node/finalizedEpochInfos.d.ts +21 -0
- package/src/node/finalizedEpochInfos.js +54 -0
- package/src/node/index.d.ts +9 -1
- package/src/node/index.js +11 -1
- package/src/platformAddresses/createStateTransition.d.ts +12 -0
- package/src/platformAddresses/createStateTransition.js +62 -0
- package/src/platformAddresses/getAddressesBranchState.d.ts +3 -0
- package/src/platformAddresses/getAddressesBranchState.js +21 -0
- package/src/platformAddresses/getAddressesTrunkState.d.ts +3 -0
- package/src/platformAddresses/getAddressesTrunkState.js +33 -0
- package/src/platformAddresses/getRecentAddressBalanceChanges.d.ts +3 -0
- package/src/platformAddresses/getRecentAddressBalanceChanges.js +38 -0
- package/src/platformAddresses/getRecentCompactedAddressBalanceChanges.d.ts +3 -0
- package/src/platformAddresses/getRecentCompactedAddressBalanceChanges.js +37 -0
- package/src/platformAddresses/index.d.ts +63 -2
- package/src/platformAddresses/index.js +76 -0
- package/src/shielded/createStateTransition.d.ts +3 -0
- package/src/shielded/createStateTransition.js +60 -0
- package/src/shielded/getMostRecentShieldedAnchor.d.ts +2 -0
- package/src/shielded/getMostRecentShieldedAnchor.js +36 -0
- package/src/shielded/getShieldedAnchors.d.ts +2 -0
- package/src/shielded/getShieldedAnchors.js +36 -0
- package/src/shielded/getShieldedEncryptedNotes.d.ts +3 -0
- package/src/shielded/getShieldedEncryptedNotes.js +43 -0
- package/src/shielded/getShieldedNotesCount.d.ts +2 -0
- package/src/shielded/getShieldedNotesCount.js +36 -0
- package/src/shielded/getShieldedNullifiers.d.ts +3 -0
- package/src/shielded/getShieldedNullifiers.js +40 -0
- package/src/shielded/getShieldedPoolState.d.ts +2 -0
- package/src/shielded/getShieldedPoolState.js +36 -0
- package/src/shielded/index.d.ts +131 -0
- package/src/shielded/index.js +188 -0
- package/src/utils/verifyTenderdashProof.js +3 -0
- package/test/unit/Identity.spec.js +1 -1
- package/test/unit/KeyPair.spec.js +80 -0
- package/test/unit/Node.spec.js +6 -0
- package/test/unit/PlatformAddress.spec.js +155 -1
- package/test/unit/Shielded.spec.d.ts +1 -0
- package/test/unit/Shielded.spec.js +237 -0
- package/types.d.ts +153 -2
- package/types.js +1 -1
package/src/DashPlatformSDK.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { TokensController } from './tokens/index.js';
|
|
|
12
12
|
import { VotingController } from './voting/index.js';
|
|
13
13
|
import { Network } from '../types.js';
|
|
14
14
|
import { PlatformAddressesController } from './platformAddresses/index.js';
|
|
15
|
+
import { ShieldedController } from './shielded/index.js';
|
|
15
16
|
export interface GRPCOptions {
|
|
16
17
|
poolLimit: 5;
|
|
17
18
|
dapiUrl?: string | string[];
|
|
@@ -33,6 +34,7 @@ export declare class DashPlatformSDK {
|
|
|
33
34
|
options?: SDKOptions;
|
|
34
35
|
contestedResources: ContestedResourcesController;
|
|
35
36
|
platformAddresses: PlatformAddressesController;
|
|
37
|
+
shielded: ShieldedController;
|
|
36
38
|
stateTransitions: StateTransitionsController;
|
|
37
39
|
dataContracts: DataContractsController;
|
|
38
40
|
identities: IdentitiesController;
|
package/src/DashPlatformSDK.js
CHANGED
|
@@ -11,6 +11,7 @@ import { ContestedResourcesController } from './contestedResources/index.js';
|
|
|
11
11
|
import { TokensController } from './tokens/index.js';
|
|
12
12
|
import { VotingController } from './voting/index.js';
|
|
13
13
|
import { PlatformAddressesController } from './platformAddresses/index.js';
|
|
14
|
+
import { ShieldedController } from './shielded/index.js';
|
|
14
15
|
/**
|
|
15
16
|
* Javascript SDK for that let you interact with a Dash Platform blockchain
|
|
16
17
|
*/
|
|
@@ -22,6 +23,7 @@ export class DashPlatformSDK {
|
|
|
22
23
|
options;
|
|
23
24
|
contestedResources;
|
|
24
25
|
platformAddresses;
|
|
26
|
+
shielded;
|
|
25
27
|
stateTransitions;
|
|
26
28
|
dataContracts;
|
|
27
29
|
identities;
|
|
@@ -65,6 +67,7 @@ export class DashPlatformSDK {
|
|
|
65
67
|
this.grpcPool = grpcPool;
|
|
66
68
|
this.contestedResources = new ContestedResourcesController(grpcPool);
|
|
67
69
|
this.platformAddresses = new PlatformAddressesController(grpcPool);
|
|
70
|
+
this.shielded = new ShieldedController(grpcPool);
|
|
68
71
|
this.stateTransitions = new StateTransitionsController(grpcPool);
|
|
69
72
|
this.dataContracts = new DataContractsController(grpcPool);
|
|
70
73
|
this.identities = new IdentitiesController(grpcPool);
|
package/src/constants.d.ts
CHANGED
|
@@ -3,10 +3,11 @@ import { PlatformVersionWASM } from 'pshenmic-dpp';
|
|
|
3
3
|
* Default amount of documents to retrieve from DAPI
|
|
4
4
|
*/
|
|
5
5
|
export declare const DAPI_DEFAULT_LIMIT = 100;
|
|
6
|
+
export declare const SHIELDED_MAX_NOTES_PER_QUERY = 8192;
|
|
6
7
|
export declare const HALVING_INTERVAL = 210240;
|
|
7
8
|
export declare const TESTNET_ACTIVATION_HEIGHT = 1066900;
|
|
8
9
|
export declare const MAINNET_ACTIVATION_HEIGHT = 2128896;
|
|
9
10
|
export declare const GRPC_DEFAULT_POOL_LIMIT = 5;
|
|
10
11
|
export declare const DPNS_DATA_CONTRACT_ID = "GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec";
|
|
11
12
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zIGNoYXJzIGxlbmd0aCBhcyBkZWZpbmVkIGJ5IFJGQyAxMDM1LiBEb21haW4gZG9jdW1lbnRzIGFyZSBpbW11dGFibGU6IG1vZGlmaWNhdGlvbiBhbmQgZGVsZXRpb24gYXJlIHJlc3RyaWN0ZWQIcHJlb3JkZXIWCBIQZG9jdW1lbnRzTXV0YWJsZRMAEgxjYW5CZURlbGV0ZWQTARIEdHlwZRIGb2JqZWN0EgdpbmRpY2VzFQEWAxIEbmFtZRIKc2FsdGVkSGFzaBIKcHJvcGVydGllcxUBFgESEHNhbHRlZERvbWFpbkhhc2gSA2FzYxIGdW5pcXVlEwESCnByb3BlcnRpZXMWARIQc2FsdGVkRG9tYWluSGFzaBYGEgR0eXBlEgVhcnJheRIJYnl0ZUFycmF5EwESCG1pbkl0ZW1zAiASCG1heEl0ZW1zAiASCHBvc2l0aW9uAgASC2Rlc2NyaXB0aW9uEllEb3VibGUgc2hhLTI1NiBvZiB0aGUgY29uY2F0ZW5hdGlvbiBvZiBhIDMyIGJ5dGUgcmFuZG9tIHNhbHQgYW5kIGEgbm9ybWFsaXplZCBkb21haW4gbmFtZRIIcmVxdWlyZWQVARIQc2FsdGVkRG9tYWluSGFzaBIUYWRkaXRpb25hbFByb3BlcnRpZXMTABIIJGNvbW1lbnQSSlByZW9yZGVyIGRvY3VtZW50cyBhcmUgaW1tdXRhYmxlOiBtb2RpZmljYXRpb24gYW5kIGRlbGV0aW9uIGFyZSByZXN0cmljdGVkAAAAAAAAAAAAAA==";
|
|
12
|
-
export declare const LATEST_PLATFORM_VERSION = PlatformVersionWASM.
|
|
13
|
+
export declare const LATEST_PLATFORM_VERSION = PlatformVersionWASM.PLATFORM_V13;
|
package/src/constants.js
CHANGED
|
@@ -3,10 +3,11 @@ import { PlatformVersionWASM } from 'pshenmic-dpp';
|
|
|
3
3
|
* Default amount of documents to retrieve from DAPI
|
|
4
4
|
*/
|
|
5
5
|
export const DAPI_DEFAULT_LIMIT = 100;
|
|
6
|
+
export const SHIELDED_MAX_NOTES_PER_QUERY = 8192;
|
|
6
7
|
export const HALVING_INTERVAL = 210240;
|
|
7
8
|
export const TESTNET_ACTIVATION_HEIGHT = 1066900;
|
|
8
9
|
export const MAINNET_ACTIVATION_HEIGHT = 2128896;
|
|
9
10
|
export const GRPC_DEFAULT_POOL_LIMIT = 5;
|
|
10
11
|
export const DPNS_DATA_CONTRACT_ID = 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec';
|
|
11
12
|
export const DPNS_DATA_CONTRACT_BYTES = 'AeZoxlmvZq7h5ywYbd57W34KHXEqCcQNVyH2Ir9TxTFVAAAAAAABAQAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIGZG9tYWluFgsSEGRvY3VtZW50c011dGFibGUTABIMY2FuQmVEZWxldGVkEwESDHRyYW5zZmVyYWJsZQIBEgl0cmFkZU1vZGUCARIEdHlwZRIGb2JqZWN0EgdpbmRpY2VzFQIWBBIEbmFtZRIScGFyZW50TmFtZUFuZExhYmVsEgpwcm9wZXJ0aWVzFQIWARIabm9ybWFsaXplZFBhcmVudERvbWFpbk5hbWUSA2FzYxYBEg9ub3JtYWxpemVkTGFiZWwSA2FzYxIGdW5pcXVlEwESCWNvbnRlc3RlZBYDEgxmaWVsZE1hdGNoZXMVARYCEgVmaWVsZBIPbm9ybWFsaXplZExhYmVsEgxyZWdleFBhdHRlcm4SE15bYS16QS1aMDEtXXszLDE5fSQSCnJlc29sdXRpb24CABILZGVzY3JpcHRpb24SqklmIHRoZSBub3JtYWxpemVkIGxhYmVsIHBhcnQgb2YgdGhpcyBpbmRleCBpcyBsZXNzIHRoYW4gMjAgY2hhcmFjdGVycyAoYWxsIGFscGhhYmV0IGEteiwgQS1aLCAwLCAxLCBhbmQgLSkgdGhlbiBhIG1hc3Rlcm5vZGUgdm90ZSBjb250ZXN0IHRha2VzIHBsYWNlIHRvIGdpdmUgb3V0IHRoZSBuYW1lFgMSBG5hbW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AAAAAAA==';
|
|
12
|
-
export const LATEST_PLATFORM_VERSION = PlatformVersionWASM.
|
|
13
|
+
export const LATEST_PLATFORM_VERSION = PlatformVersionWASM.PLATFORM_V13;
|
|
@@ -23,7 +23,7 @@ const identityTransitionsMap = {
|
|
|
23
23
|
withdrawal: {
|
|
24
24
|
class: IdentityCreditWithdrawalTransitionWASM,
|
|
25
25
|
arguments: ['identityId', 'amount', 'coreFeePerByte', 'pooling', 'identityNonce', 'outputScript'],
|
|
26
|
-
optionalArguments: ['userFeeIncrease']
|
|
26
|
+
optionalArguments: ['outputScript', 'userFeeIncrease']
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
export default function createStateTransition(type, params) {
|
|
@@ -35,7 +35,7 @@ export default function createStateTransition(type, params) {
|
|
|
35
35
|
.filter((classArgument) => params[classArgument] == null &&
|
|
36
36
|
!(optionalArguments).includes(classArgument));
|
|
37
37
|
if (missingArgument != null) {
|
|
38
|
-
throw new Error(`
|
|
38
|
+
throw new Error(`Transition param "${missingArgument}" is missing`);
|
|
39
39
|
}
|
|
40
40
|
const transitionParams = classArguments.map((classArgument) => params[classArgument]);
|
|
41
41
|
// @ts-expect-error
|
package/src/keyPair/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HDKey } from '@scure/bip32';
|
|
2
2
|
import { Network } from '../../types.js';
|
|
3
|
+
import { OrchardAddressWASM, PlatformAddressWASM, PrivateKeyWASM } from 'pshenmic-dpp';
|
|
3
4
|
/**
|
|
4
5
|
* Collection of functions to work with private keys and seed phrases
|
|
5
6
|
*
|
|
@@ -64,4 +65,90 @@ export declare class KeyPairController {
|
|
|
64
65
|
* @returns {string}
|
|
65
66
|
*/
|
|
66
67
|
p2pkhAddress(publicKey: Uint8Array, network: Network): string;
|
|
68
|
+
/**
|
|
69
|
+
* Converts a public key to a transparent platform P2PKH address (DIP-18):
|
|
70
|
+
* the canonical `variantByte || Hash160(pubkey)` PlatformAddress.
|
|
71
|
+
*
|
|
72
|
+
* @param publicKey {Uint8Array}
|
|
73
|
+
* @param network {Network}
|
|
74
|
+
*
|
|
75
|
+
* @returns {PlatformAddressWASM}
|
|
76
|
+
*/
|
|
77
|
+
platformAddress(publicKey: Uint8Array, network: Network): PlatformAddressWASM;
|
|
78
|
+
/**
|
|
79
|
+
* Derives a shielded (Orchard) address from a BIP-39 seed via ZIP-32
|
|
80
|
+
* (m/32'/coinType'/account').
|
|
81
|
+
*
|
|
82
|
+
* @param seed {Uint8Array} - BIP-39 seed bytes
|
|
83
|
+
* @param network {Network} - network (selects the SLIP-44 coin type)
|
|
84
|
+
* @param account {number} - ZIP-32 account index
|
|
85
|
+
* @param diversifierIndex {number=} - optional diversifier index
|
|
86
|
+
*
|
|
87
|
+
* @returns {OrchardAddressWASM}
|
|
88
|
+
*/
|
|
89
|
+
deriveShieldedAddress(seed: Uint8Array, network: Network, account: number, diversifierIndex?: number): OrchardAddressWASM;
|
|
90
|
+
/**
|
|
91
|
+
* Derives the sender's Orchard outgoing viewing key (OVK, 32 bytes) from a
|
|
92
|
+
* BIP-39 seed via ZIP-32 (m/32'/coinType'/account'). Used to recover the
|
|
93
|
+
* outgoing notes a wallet sent.
|
|
94
|
+
*
|
|
95
|
+
* @param seed {Uint8Array} - BIP-39 seed bytes
|
|
96
|
+
* @param network {Network} - network (selects the SLIP-44 coin type)
|
|
97
|
+
* @param account {number} - ZIP-32 account index
|
|
98
|
+
*
|
|
99
|
+
* @returns {Uint8Array} 32-byte outgoing viewing key
|
|
100
|
+
*/
|
|
101
|
+
deriveShieldedOutgoingViewingKey(seed: Uint8Array, network: Network, account: number): Uint8Array;
|
|
102
|
+
/**
|
|
103
|
+
* Derives the DIP-17 account-level extended public key (xpub) for the
|
|
104
|
+
* clear-funds key class: m/9'/coinType'/17'/account'/0'. The seed is only
|
|
105
|
+
* needed once per account — the returned xpub derives every address index
|
|
106
|
+
* publicly (see {@link derivePlatformAddressFromXpub}), with no further access
|
|
107
|
+
* to the seed.
|
|
108
|
+
*
|
|
109
|
+
* @param seed {Uint8Array} - BIP-39 seed bytes
|
|
110
|
+
* @param network {Network} - network (selects the SLIP-44 coin type)
|
|
111
|
+
* @param account {number} - DIP-17 account index
|
|
112
|
+
*
|
|
113
|
+
* @returns {Promise<string>} account-level extended public key
|
|
114
|
+
*/
|
|
115
|
+
derivePlatformAccountXpub(seed: Uint8Array, network: Network, account: number): Promise<string>;
|
|
116
|
+
/**
|
|
117
|
+
* Derives a transparent platform P2PKH address from a BIP-39 seed via DIP-17
|
|
118
|
+
* (m/9'/coinType'/17'/account'/0'/index).
|
|
119
|
+
*
|
|
120
|
+
* @param seed {Uint8Array} - BIP-39 seed bytes
|
|
121
|
+
* @param network {Network} - network (selects the SLIP-44 coin type)
|
|
122
|
+
* @param account {number} - DIP-17 account index
|
|
123
|
+
* @param index {number} - address index
|
|
124
|
+
*
|
|
125
|
+
* @returns {Promise<PlatformAddressWASM>}
|
|
126
|
+
*/
|
|
127
|
+
derivePlatformAddress(seed: Uint8Array, network: Network, account: number, index: number): Promise<PlatformAddressWASM>;
|
|
128
|
+
/**
|
|
129
|
+
* Derives a transparent platform P2PKH address from an account-level xpub (see
|
|
130
|
+
* {@link derivePlatformAccountXpub}). The address index is non-hardened, so
|
|
131
|
+
* public-only derivation reproduces the exact same address as the seed-based
|
|
132
|
+
* path — no seed required.
|
|
133
|
+
*
|
|
134
|
+
* @param xpub {string} - account-level extended public key
|
|
135
|
+
* @param network {Network} - network (selects the extended-key version bytes)
|
|
136
|
+
* @param index {number} - address index
|
|
137
|
+
*
|
|
138
|
+
* @returns {PlatformAddressWASM}
|
|
139
|
+
*/
|
|
140
|
+
derivePlatformAddressFromXpub(xpub: string, network: Network, index: number): PlatformAddressWASM;
|
|
141
|
+
/**
|
|
142
|
+
* Derives the private key for a DIP-17 platform address by its index
|
|
143
|
+
* (m/9'/coinType'/17'/account'/0'/index). Used to sign a transfer that spends
|
|
144
|
+
* from that address.
|
|
145
|
+
*
|
|
146
|
+
* @param seed {Uint8Array} - BIP-39 seed bytes
|
|
147
|
+
* @param network {Network} - network (selects the SLIP-44 coin type)
|
|
148
|
+
* @param account {number} - DIP-17 account index
|
|
149
|
+
* @param index {number} - address index
|
|
150
|
+
*
|
|
151
|
+
* @returns {Promise<PrivateKeyWASM>}
|
|
152
|
+
*/
|
|
153
|
+
derivePlatformAddressPrivateKey(seed: Uint8Array, network: Network, account: number, index: number): Promise<PrivateKeyWASM>;
|
|
67
154
|
}
|
package/src/keyPair/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import mnemonicToSeed from './mnemonicToSeed.js';
|
|
|
3
3
|
import deriveChild from './deriveChild.js';
|
|
4
4
|
import derivePath from './derivePath.js';
|
|
5
5
|
import { p2pkh } from '@scure/btc-signer';
|
|
6
|
+
import { OrchardAddressWASM, orchardOvkFromSeed, PlatformAddressWASM, PrivateKeyWASM } from 'pshenmic-dpp';
|
|
6
7
|
const DASH_VERSIONS = {
|
|
7
8
|
mainnet: { pubKeyHash: 0x4c, scriptHash: 0x10, bech32: 'dc', wif: 0xcc, private: 0x0488ade4, public: 0x0488b21e },
|
|
8
9
|
testnet: { pubKeyHash: 0x8c, scriptHash: 0x13, bech32: 'dc', wif: 0xef, private: 0x04358394, public: 0x043587cf }
|
|
@@ -86,4 +87,131 @@ export class KeyPairController {
|
|
|
86
87
|
const P2PKH = p2pkh(publicKey, DASH_VERSIONS[network]);
|
|
87
88
|
return P2PKH.address;
|
|
88
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Converts a public key to a transparent platform P2PKH address (DIP-18):
|
|
92
|
+
* the canonical `variantByte || Hash160(pubkey)` PlatformAddress.
|
|
93
|
+
*
|
|
94
|
+
* @param publicKey {Uint8Array}
|
|
95
|
+
* @param network {Network}
|
|
96
|
+
*
|
|
97
|
+
* @returns {PlatformAddressWASM}
|
|
98
|
+
*/
|
|
99
|
+
platformAddress(publicKey, network) {
|
|
100
|
+
const { hash } = p2pkh(publicKey, DASH_VERSIONS[network]);
|
|
101
|
+
// variant byte 0x00 = P2PKH
|
|
102
|
+
return PlatformAddressWASM.fromBytes(Uint8Array.from([0x00, ...hash]));
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Derives a shielded (Orchard) address from a BIP-39 seed via ZIP-32
|
|
106
|
+
* (m/32'/coinType'/account').
|
|
107
|
+
*
|
|
108
|
+
* @param seed {Uint8Array} - BIP-39 seed bytes
|
|
109
|
+
* @param network {Network} - network (selects the SLIP-44 coin type)
|
|
110
|
+
* @param account {number} - ZIP-32 account index
|
|
111
|
+
* @param diversifierIndex {number=} - optional diversifier index
|
|
112
|
+
*
|
|
113
|
+
* @returns {OrchardAddressWASM}
|
|
114
|
+
*/
|
|
115
|
+
deriveShieldedAddress(seed, network, account, diversifierIndex) {
|
|
116
|
+
// SLIP-44 coin type: 5 = Dash mainnet, 1 = testnets. Orchard derives via ZIP-32
|
|
117
|
+
const coinType = network === 'mainnet' ? 5 : 1;
|
|
118
|
+
return OrchardAddressWASM.fromSeed(seed, coinType, account, diversifierIndex);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Derives the sender's Orchard outgoing viewing key (OVK, 32 bytes) from a
|
|
122
|
+
* BIP-39 seed via ZIP-32 (m/32'/coinType'/account'). Used to recover the
|
|
123
|
+
* outgoing notes a wallet sent.
|
|
124
|
+
*
|
|
125
|
+
* @param seed {Uint8Array} - BIP-39 seed bytes
|
|
126
|
+
* @param network {Network} - network (selects the SLIP-44 coin type)
|
|
127
|
+
* @param account {number} - ZIP-32 account index
|
|
128
|
+
*
|
|
129
|
+
* @returns {Uint8Array} 32-byte outgoing viewing key
|
|
130
|
+
*/
|
|
131
|
+
deriveShieldedOutgoingViewingKey(seed, network, account) {
|
|
132
|
+
// SLIP-44 coin type: 5 = Dash mainnet, 1 = testnets. Orchard derives via ZIP-32
|
|
133
|
+
const coinType = network === 'mainnet' ? 5 : 1;
|
|
134
|
+
return orchardOvkFromSeed(seed, coinType, account);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Derives the DIP-17 account-level extended public key (xpub) for the
|
|
138
|
+
* clear-funds key class: m/9'/coinType'/17'/account'/0'. The seed is only
|
|
139
|
+
* needed once per account — the returned xpub derives every address index
|
|
140
|
+
* publicly (see {@link derivePlatformAddressFromXpub}), with no further access
|
|
141
|
+
* to the seed.
|
|
142
|
+
*
|
|
143
|
+
* @param seed {Uint8Array} - BIP-39 seed bytes
|
|
144
|
+
* @param network {Network} - network (selects the SLIP-44 coin type)
|
|
145
|
+
* @param account {number} - DIP-17 account index
|
|
146
|
+
*
|
|
147
|
+
* @returns {Promise<string>} account-level extended public key
|
|
148
|
+
*/
|
|
149
|
+
async derivePlatformAccountXpub(seed, network, account) {
|
|
150
|
+
const coinType = network === 'mainnet' ? 5 : 1;
|
|
151
|
+
const hdKey = this.seedToHdKey(seed, network);
|
|
152
|
+
const accountNode = await this.derivePath(hdKey, `m/9'/${coinType}'/17'/${account}'/0'`);
|
|
153
|
+
return accountNode.publicExtendedKey;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Derives a transparent platform P2PKH address from a BIP-39 seed via DIP-17
|
|
157
|
+
* (m/9'/coinType'/17'/account'/0'/index).
|
|
158
|
+
*
|
|
159
|
+
* @param seed {Uint8Array} - BIP-39 seed bytes
|
|
160
|
+
* @param network {Network} - network (selects the SLIP-44 coin type)
|
|
161
|
+
* @param account {number} - DIP-17 account index
|
|
162
|
+
* @param index {number} - address index
|
|
163
|
+
*
|
|
164
|
+
* @returns {Promise<PlatformAddressWASM>}
|
|
165
|
+
*/
|
|
166
|
+
async derivePlatformAddress(seed, network, account, index) {
|
|
167
|
+
const coinType = network === 'mainnet' ? 5 : 1;
|
|
168
|
+
const hdKey = this.seedToHdKey(seed, network);
|
|
169
|
+
const childNode = await this.derivePath(hdKey, `m/9'/${coinType}'/17'/${account}'/0'/${index}`);
|
|
170
|
+
if (childNode.publicKey == null) {
|
|
171
|
+
throw new Error(`Could not derive platform address public key at index ${index}`);
|
|
172
|
+
}
|
|
173
|
+
return this.platformAddress(childNode.publicKey, network);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Derives a transparent platform P2PKH address from an account-level xpub (see
|
|
177
|
+
* {@link derivePlatformAccountXpub}). The address index is non-hardened, so
|
|
178
|
+
* public-only derivation reproduces the exact same address as the seed-based
|
|
179
|
+
* path — no seed required.
|
|
180
|
+
*
|
|
181
|
+
* @param xpub {string} - account-level extended public key
|
|
182
|
+
* @param network {Network} - network (selects the extended-key version bytes)
|
|
183
|
+
* @param index {number} - address index
|
|
184
|
+
*
|
|
185
|
+
* @returns {PlatformAddressWASM}
|
|
186
|
+
*/
|
|
187
|
+
derivePlatformAddressFromXpub(xpub, network, index) {
|
|
188
|
+
const accountNode = HDKey.fromExtendedKey(xpub, DASH_VERSIONS[network]);
|
|
189
|
+
const childNode = accountNode.deriveChild(index);
|
|
190
|
+
if (childNode.publicKey == null) {
|
|
191
|
+
throw new Error(`Could not derive platform address public key at index ${index}`);
|
|
192
|
+
}
|
|
193
|
+
return this.platformAddress(childNode.publicKey, network);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Derives the private key for a DIP-17 platform address by its index
|
|
197
|
+
* (m/9'/coinType'/17'/account'/0'/index). Used to sign a transfer that spends
|
|
198
|
+
* from that address.
|
|
199
|
+
*
|
|
200
|
+
* @param seed {Uint8Array} - BIP-39 seed bytes
|
|
201
|
+
* @param network {Network} - network (selects the SLIP-44 coin type)
|
|
202
|
+
* @param account {number} - DIP-17 account index
|
|
203
|
+
* @param index {number} - address index
|
|
204
|
+
*
|
|
205
|
+
* @returns {Promise<PrivateKeyWASM>}
|
|
206
|
+
*/
|
|
207
|
+
async derivePlatformAddressPrivateKey(seed, network, account, index) {
|
|
208
|
+
const coinType = network === 'mainnet' ? 5 : 1;
|
|
209
|
+
const hdKey = this.seedToHdKey(seed, network);
|
|
210
|
+
const path = `m/9'/${coinType}'/17'/${account}'/0'/${index}`;
|
|
211
|
+
const { privateKey } = await this.derivePath(hdKey, path);
|
|
212
|
+
if (privateKey == null) {
|
|
213
|
+
throw new Error(`Could not derive platform address key at ${path}`);
|
|
214
|
+
}
|
|
215
|
+
return PrivateKeyWASM.fromBytes(privateKey, network);
|
|
216
|
+
}
|
|
89
217
|
}
|
|
@@ -7,4 +7,4 @@ export interface EpochInfo {
|
|
|
7
7
|
feeMultiplier: bigint;
|
|
8
8
|
protocolVersion: 9;
|
|
9
9
|
}
|
|
10
|
-
export default function
|
|
10
|
+
export default function epochInfos(grpcPool: GRPCConnectionPool, count: number, ascending: boolean, start?: number): Promise<EpochInfo[]>;
|
|
@@ -5,7 +5,7 @@ import bytesToHex from '../utils/bytesToHex.js';
|
|
|
5
5
|
import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
|
|
6
6
|
import { UInt32Value } from '../../proto/generated/google/protobuf/wrappers.js';
|
|
7
7
|
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
8
|
-
export default async function
|
|
8
|
+
export default async function epochInfos(grpcPool, count, ascending, start) {
|
|
9
9
|
const getEpochsInfoRequest = GetEpochsInfoRequest.create({
|
|
10
10
|
version: {
|
|
11
11
|
oneofKind: 'v0',
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
2
|
+
import { IdentifierWASM } from 'pshenmic-dpp';
|
|
3
|
+
export interface FinalizedEpochInfo {
|
|
4
|
+
epochIndex: number;
|
|
5
|
+
firstBlockTime: Date;
|
|
6
|
+
firstBlockHeight: bigint;
|
|
7
|
+
totalBlocksInEpoch: bigint;
|
|
8
|
+
firstCoreBlockHeight: number;
|
|
9
|
+
nextEpochStartCoreBlockHeight: number;
|
|
10
|
+
totalProcessingFees: bigint;
|
|
11
|
+
totalDistributedStorageFees: bigint;
|
|
12
|
+
totalCreatedStorageFees: bigint;
|
|
13
|
+
coreBlockRewards: bigint;
|
|
14
|
+
blockProposers: {
|
|
15
|
+
proposer: IdentifierWASM;
|
|
16
|
+
count: bigint;
|
|
17
|
+
}[];
|
|
18
|
+
feeMultiplier: bigint;
|
|
19
|
+
protocolVersion: number;
|
|
20
|
+
}
|
|
21
|
+
export default function getFinalizedEpochsInfo(grpcPool: GRPCConnectionPool, startEpochIndex: number, startEpochIndexIncluded: boolean, endEpochIndex: number, endEpochIndexIncluded: boolean): Promise<FinalizedEpochInfo[]>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { GetFinalizedEpochInfosRequest } from '../../proto/generated/platform.js';
|
|
2
|
+
import { verifyFinalizedEpochInfosProof } from 'pshenmic-dpp';
|
|
3
|
+
import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
|
|
4
|
+
import bytesToHex from '../utils/bytesToHex.js';
|
|
5
|
+
import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
|
|
6
|
+
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
7
|
+
export default async function getFinalizedEpochsInfo(grpcPool, startEpochIndex, startEpochIndexIncluded, endEpochIndex, endEpochIndexIncluded) {
|
|
8
|
+
const getEpochsInfoRequest = GetFinalizedEpochInfosRequest.create({
|
|
9
|
+
version: {
|
|
10
|
+
oneofKind: 'v0',
|
|
11
|
+
v0: {
|
|
12
|
+
startEpochIndex,
|
|
13
|
+
startEpochIndexIncluded,
|
|
14
|
+
endEpochIndex,
|
|
15
|
+
endEpochIndexIncluded,
|
|
16
|
+
prove: true
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const { response } = await grpcPool.getClient().getFinalizedEpochInfos(getEpochsInfoRequest);
|
|
21
|
+
const { version } = response;
|
|
22
|
+
if (version.oneofKind !== 'v0') {
|
|
23
|
+
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
24
|
+
}
|
|
25
|
+
const { v0 } = version;
|
|
26
|
+
if (v0.result.oneofKind !== 'proof') {
|
|
27
|
+
throw new Error('Unexpected oneOf type returned from DAPI (must be proof)');
|
|
28
|
+
}
|
|
29
|
+
const { result: { proof }, metadata } = v0;
|
|
30
|
+
if (metadata == null) {
|
|
31
|
+
throw new Error('Metadata not found');
|
|
32
|
+
}
|
|
33
|
+
const { rootHash, epochInfos } = verifyFinalizedEpochInfosProof(proof.grovedbProof, startEpochIndex, startEpochIndexIncluded, endEpochIndex, endEpochIndexIncluded, LATEST_PLATFORM_VERSION);
|
|
34
|
+
const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
|
|
35
|
+
const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
|
|
36
|
+
if (!verify) {
|
|
37
|
+
throw new Error('Failed to verify query');
|
|
38
|
+
}
|
|
39
|
+
return epochInfos.map(info => ({
|
|
40
|
+
epochIndex: info.epochIndex,
|
|
41
|
+
firstBlockTime: info.firstBlockTime,
|
|
42
|
+
firstBlockHeight: info.firstBlockHeight,
|
|
43
|
+
totalBlocksInEpoch: info.totalBlocksInEpoch,
|
|
44
|
+
firstCoreBlockHeight: info.firstCoreBlockHeight,
|
|
45
|
+
nextEpochStartCoreBlockHeight: info.nextEpochStartCoreBlockHeight,
|
|
46
|
+
totalProcessingFees: info.totalProcessingFees,
|
|
47
|
+
totalDistributedStorageFees: info.totalDistributedStorageFees,
|
|
48
|
+
totalCreatedStorageFees: info.totalCreatedStorageFees,
|
|
49
|
+
coreBlockRewards: info.coreBlockRewards,
|
|
50
|
+
blockProposers: info.blockProposers,
|
|
51
|
+
feeMultiplier: info.feeMultiplierPermille,
|
|
52
|
+
protocolVersion: info.protocolVersion
|
|
53
|
+
}));
|
|
54
|
+
}
|
package/src/node/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
2
2
|
import { NodeStatus } from '../../types.js';
|
|
3
|
-
import { EpochInfo } from './
|
|
3
|
+
import { EpochInfo } from './epochInfos.js';
|
|
4
|
+
import { FinalizedEpochInfo } from './finalizedEpochInfos.js';
|
|
4
5
|
/**
|
|
5
6
|
* Node controller for requesting information about DAPI node
|
|
6
7
|
*
|
|
@@ -30,4 +31,11 @@ export declare class NodeController {
|
|
|
30
31
|
* @return {Promise<EpochInfo[]>}
|
|
31
32
|
*/
|
|
32
33
|
getEpochsInfo(count: number, ascending: boolean, start?: number): Promise<EpochInfo[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Retrieves an finalized info about epochs
|
|
36
|
+
* Includes information about first block height, time, fee multiplier, number
|
|
37
|
+
*
|
|
38
|
+
* @return {Promise<FinalizedEpochInfo[]>}
|
|
39
|
+
*/
|
|
40
|
+
getFinalizedEpochsInfo(startEpochIndex: number, startEpochIndexIncluded: boolean, endEpochIndex: number, endEpochIndexIncluded: boolean): Promise<FinalizedEpochInfo[]>;
|
|
33
41
|
}
|
package/src/node/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import getStatus from './status.js';
|
|
2
|
-
import getEpochsInfo from './
|
|
2
|
+
import getEpochsInfo from './epochInfos.js';
|
|
3
|
+
import getFinalizedEpochsInfo from './finalizedEpochInfos.js';
|
|
3
4
|
import getTotalCredits from './totalCredits.js';
|
|
4
5
|
/**
|
|
5
6
|
* Node controller for requesting information about DAPI node
|
|
@@ -38,4 +39,13 @@ export class NodeController {
|
|
|
38
39
|
async getEpochsInfo(count, ascending, start) {
|
|
39
40
|
return await getEpochsInfo(this.grpcPool, count, ascending, start);
|
|
40
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Retrieves an finalized info about epochs
|
|
44
|
+
* Includes information about first block height, time, fee multiplier, number
|
|
45
|
+
*
|
|
46
|
+
* @return {Promise<FinalizedEpochInfo[]>}
|
|
47
|
+
*/
|
|
48
|
+
async getFinalizedEpochsInfo(startEpochIndex, startEpochIndexIncluded, endEpochIndex, endEpochIndexIncluded) {
|
|
49
|
+
return await getFinalizedEpochsInfo(this.grpcPool, startEpochIndex, startEpochIndexIncluded, endEpochIndex, endEpochIndexIncluded);
|
|
50
|
+
}
|
|
41
51
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StateTransitionWASM } from 'pshenmic-dpp';
|
|
2
|
+
import { PlatformAddressTransitionParamsMap, PlatformAddressTransitionType } from '../../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Helper function that assembles a {StateTransitionWASM} for Platform Address transitions
|
|
5
|
+
* out of already-built params. The builder is pure: it does not sign, broadcast or
|
|
6
|
+
* mutate the passed params. Producing witnesses / signatures stays the caller's
|
|
7
|
+
* responsibility (they are passed in via the `inputWitness` / `signature` params).
|
|
8
|
+
*
|
|
9
|
+
* @param type {string} type of transition
|
|
10
|
+
* @param params {PlatformAddressTransitionParamsMap[K]} params required by that transition type
|
|
11
|
+
*/
|
|
12
|
+
export default function createStateTransition<K extends PlatformAddressTransitionType>(type: K, params: PlatformAddressTransitionParamsMap[K]): StateTransitionWASM;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { IdentityCreditTransferToAddressesTransitionWASM, IdentityCreateFromAddressesTransitionWASM, IdentityTopUpFromAddressesTransitionWASM, AddressFundsTransferTransitionWASM, AddressFundingFromAssetLockTransitionWASM, AddressCreditWithdrawalTransitionWASM } from 'pshenmic-dpp';
|
|
2
|
+
const platformAddressTransitionsMap = {
|
|
3
|
+
identityCreditTransferToAddresses: {
|
|
4
|
+
class: IdentityCreditTransferToAddressesTransitionWASM,
|
|
5
|
+
arguments: ['identityId', 'recipients', 'nonce', 'userFeeIncrease'],
|
|
6
|
+
optionalArguments: ['userFeeIncrease']
|
|
7
|
+
},
|
|
8
|
+
identityCreateFromAddresses: {
|
|
9
|
+
class: IdentityCreateFromAddressesTransitionWASM,
|
|
10
|
+
arguments: ['publicKeys', 'inputs', 'feeStrategy', 'userFeeIncrease', 'inputWitness', 'output'],
|
|
11
|
+
optionalArguments: ['userFeeIncrease', 'output']
|
|
12
|
+
},
|
|
13
|
+
identityTopUpFromAddresses: {
|
|
14
|
+
class: IdentityTopUpFromAddressesTransitionWASM,
|
|
15
|
+
arguments: ['identityId', 'inputs', 'feeStrategy', 'userFeeIncrease', 'inputWitness', 'output'],
|
|
16
|
+
optionalArguments: ['userFeeIncrease', 'output']
|
|
17
|
+
},
|
|
18
|
+
addressFundsTransfer: {
|
|
19
|
+
class: AddressFundsTransferTransitionWASM,
|
|
20
|
+
arguments: ['inputs', 'feeStrategy', 'userFeeIncrease', 'inputWitness', 'outputs'],
|
|
21
|
+
optionalArguments: ['userFeeIncrease']
|
|
22
|
+
},
|
|
23
|
+
addressFundingFromAssetLock: {
|
|
24
|
+
class: AddressFundingFromAssetLockTransitionWASM,
|
|
25
|
+
arguments: ['assetLockProof', 'inputs', 'feeStrategy', 'userFeeIncrease', 'inputWitness', 'outputs'],
|
|
26
|
+
optionalArguments: ['userFeeIncrease']
|
|
27
|
+
},
|
|
28
|
+
addressCreditWithdrawal: {
|
|
29
|
+
class: AddressCreditWithdrawalTransitionWASM,
|
|
30
|
+
arguments: ['inputs', 'feeStrategy', 'coreFeePerByte', 'pooling', 'outputScript', 'userFeeIncrease', 'inputWitness', 'output'],
|
|
31
|
+
optionalArguments: ['userFeeIncrease', 'output']
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Helper function that assembles a {StateTransitionWASM} for Platform Address transitions
|
|
36
|
+
* out of already-built params. The builder is pure: it does not sign, broadcast or
|
|
37
|
+
* mutate the passed params. Producing witnesses / signatures stays the caller's
|
|
38
|
+
* responsibility (they are passed in via the `inputWitness` / `signature` params).
|
|
39
|
+
*
|
|
40
|
+
* @param type {string} type of transition
|
|
41
|
+
* @param params {PlatformAddressTransitionParamsMap[K]} params required by that transition type
|
|
42
|
+
*/
|
|
43
|
+
export default function createStateTransition(type, params) {
|
|
44
|
+
const { class: TransitionClass, arguments: classArguments, optionalArguments } = platformAddressTransitionsMap[type] ?? {};
|
|
45
|
+
if (TransitionClass == null) {
|
|
46
|
+
throw new Error(`Unimplemented transition type: ${type}`);
|
|
47
|
+
}
|
|
48
|
+
const [missingArgument] = classArguments
|
|
49
|
+
.filter((classArgument) => params[classArgument] == null &&
|
|
50
|
+
!optionalArguments.includes(classArgument));
|
|
51
|
+
if (missingArgument != null) {
|
|
52
|
+
throw new Error(`Platform address transition param "${missingArgument}" is missing`);
|
|
53
|
+
}
|
|
54
|
+
// userFeeIncrease is a required positional `number` in every WASM constructor,
|
|
55
|
+
// so coerce a missing value to 0 to keep the positional order intact.
|
|
56
|
+
const transitionParams = classArguments.map((classArgument) => classArgument === 'userFeeIncrease'
|
|
57
|
+
? (params[classArgument] ?? 0)
|
|
58
|
+
: params[classArgument]);
|
|
59
|
+
// @ts-expect-error
|
|
60
|
+
const platformAddressTransition = new TransitionClass(...transitionParams);
|
|
61
|
+
return platformAddressTransition.toStateTransition();
|
|
62
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
2
|
+
import { VerifiedAddressesBranchState } from 'pshenmic-dpp';
|
|
3
|
+
export declare function getAddressesBranchState(grpcPool: GRPCConnectionPool, key: Uint8Array, depth: number, checkpointHeight: bigint, expectedRootHash: Uint8Array): Promise<VerifiedAddressesBranchState>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { verifyAddressesBranchState } from 'pshenmic-dpp';
|
|
2
|
+
import { GetAddressesBranchStateRequest } from '../../proto/generated/platform.js';
|
|
3
|
+
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
4
|
+
export async function getAddressesBranchState(grpcPool, key, depth, checkpointHeight, expectedRootHash) {
|
|
5
|
+
const getAddressesBranchStateRequest = GetAddressesBranchStateRequest.create({
|
|
6
|
+
version: {
|
|
7
|
+
oneofKind: 'v0',
|
|
8
|
+
v0: {
|
|
9
|
+
key,
|
|
10
|
+
depth,
|
|
11
|
+
checkpointHeight: checkpointHeight.toString()
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
const { response } = await grpcPool.getClient().getAddressesBranchState(getAddressesBranchStateRequest);
|
|
16
|
+
const { version } = response;
|
|
17
|
+
if (version.oneofKind !== 'v0') {
|
|
18
|
+
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
19
|
+
}
|
|
20
|
+
return verifyAddressesBranchState(version.v0.merkProof, key, depth, expectedRootHash, LATEST_PLATFORM_VERSION);
|
|
21
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { verifyAddressesTrunkState } from 'pshenmic-dpp';
|
|
2
|
+
import { GetAddressesTrunkStateRequest } from '../../proto/generated/platform.js';
|
|
3
|
+
import { LATEST_PLATFORM_VERSION } from '../constants.js';
|
|
4
|
+
import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
|
|
5
|
+
import bytesToHex from '../utils/bytesToHex.js';
|
|
6
|
+
import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
|
|
7
|
+
export async function getAddressesTrunkState(grpcPool) {
|
|
8
|
+
const getAddressesTrunkStateRequest = GetAddressesTrunkStateRequest.create({
|
|
9
|
+
version: {
|
|
10
|
+
oneofKind: 'v0',
|
|
11
|
+
v0: {}
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
const { response } = await grpcPool.getClient().getAddressesTrunkState(getAddressesTrunkStateRequest);
|
|
15
|
+
const { version } = response;
|
|
16
|
+
if (version.oneofKind !== 'v0') {
|
|
17
|
+
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
18
|
+
}
|
|
19
|
+
const { v0: { proof, metadata } } = version;
|
|
20
|
+
if (proof == null) {
|
|
21
|
+
throw new Error('Proof not found');
|
|
22
|
+
}
|
|
23
|
+
if (metadata == null) {
|
|
24
|
+
throw new Error('Metadata not found');
|
|
25
|
+
}
|
|
26
|
+
const trunk = verifyAddressesTrunkState(proof.grovedbProof, LATEST_PLATFORM_VERSION);
|
|
27
|
+
const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
|
|
28
|
+
const verify = await verifyTenderdashProof(proof, metadata, trunk.rootHash, quorumPublicKey);
|
|
29
|
+
if (!verify) {
|
|
30
|
+
throw new Error('Failed to verify query');
|
|
31
|
+
}
|
|
32
|
+
return { trunk, metadata };
|
|
33
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import GRPCConnectionPool from '../grpcConnectionPool.js';
|
|
2
|
+
import { BlockAddressBalanceChanges } from 'pshenmic-dpp';
|
|
3
|
+
export declare function getRecentAddressBalanceChanges(grpcPool: GRPCConnectionPool, startHeight: bigint, startHeightExclusive?: boolean): Promise<BlockAddressBalanceChanges[]>;
|