@florent-uzio/custody 2.2.0 → 2.4.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/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/models/custody-types.d.ts +565 -338
- package/dist/models/custody-types.d.ts.map +1 -1
- package/dist/ripple-custody.d.ts +55 -10
- package/dist/ripple-custody.d.ts.map +1 -1
- package/dist/ripple-custody.js +54 -21
- package/dist/ripple-custody.js.map +1 -1
- package/dist/services/xrpl/index.d.ts +2 -0
- package/dist/services/xrpl/index.d.ts.map +1 -1
- package/dist/services/xrpl/index.js +2 -4
- package/dist/services/xrpl/index.js.map +1 -1
- package/dist/services/xrpl/xrpl.adapters.d.ts +23 -5
- package/dist/services/xrpl/xrpl.adapters.d.ts.map +1 -1
- package/dist/services/xrpl/xrpl.adapters.js +244 -161
- package/dist/services/xrpl/xrpl.adapters.js.map +1 -1
- package/dist/services/xrpl/xrpl.builders.d.ts +22 -0
- package/dist/services/xrpl/xrpl.builders.d.ts.map +1 -0
- package/dist/services/xrpl/xrpl.builders.js +109 -0
- package/dist/services/xrpl/xrpl.builders.js.map +1 -0
- package/dist/services/xrpl/xrpl.crypto.d.ts +6 -0
- package/dist/services/xrpl/xrpl.crypto.d.ts.map +1 -0
- package/dist/services/xrpl/xrpl.crypto.js +19 -0
- package/dist/services/xrpl/xrpl.crypto.js.map +1 -0
- package/dist/services/xrpl/xrpl.http-adapters.d.ts.map +1 -1
- package/dist/services/xrpl/xrpl.http-adapters.js +5 -0
- package/dist/services/xrpl/xrpl.http-adapters.js.map +1 -1
- package/dist/services/xrpl/xrpl.ports.d.ts +7 -1
- package/dist/services/xrpl/xrpl.ports.d.ts.map +1 -1
- package/dist/services/xrpl/xrpl.service.d.ts +79 -36
- package/dist/services/xrpl/xrpl.service.d.ts.map +1 -1
- package/dist/services/xrpl/xrpl.service.js +182 -182
- package/dist/services/xrpl/xrpl.service.js.map +1 -1
- package/dist/services/xrpl/xrpl.types.d.ts +112 -7
- package/dist/services/xrpl/xrpl.types.d.ts.map +1 -1
- package/dist/services/xrpl/xrpl.types.js +0 -28
- package/dist/services/xrpl/xrpl.types.js.map +1 -1
- package/dist/services/xrpl/xrpl.validators.d.ts +23 -0
- package/dist/services/xrpl/xrpl.validators.d.ts.map +1 -0
- package/dist/services/xrpl/xrpl.validators.js +43 -0
- package/dist/services/xrpl/xrpl.validators.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { createPublicKey } from "crypto";
|
|
2
1
|
import dayjs from "dayjs";
|
|
3
2
|
import { v7 as uuidv7 } from "uuid";
|
|
4
|
-
import { encodeForSigning,
|
|
3
|
+
import { encodeForSigning, isValidAddress } from "xrpl";
|
|
5
4
|
import { sleep } from "../../helpers/async/async.js";
|
|
6
5
|
import { isUndefined } from "../../helpers/index.js";
|
|
7
6
|
import { CustodyError } from "../../models/index.js";
|
|
7
|
+
import { buildBatchOperation, buildDryRunBody, buildSignBatchPayloadResult, buildTransactionIntent, } from "./xrpl.builders.js";
|
|
8
|
+
import { compressPublicKey } from "./xrpl.crypto.js";
|
|
9
|
+
import { validateBatchSequencing } from "./xrpl.validators.js";
|
|
8
10
|
export class XrplService {
|
|
9
11
|
ports;
|
|
10
12
|
constructor(ports) {
|
|
@@ -30,7 +32,7 @@ export class XrplService {
|
|
|
30
32
|
domainId: options.domainId,
|
|
31
33
|
ledgerId: options.ledgerId,
|
|
32
34
|
});
|
|
33
|
-
const intent =
|
|
35
|
+
const intent = buildTransactionIntent({
|
|
34
36
|
operation: params.operation,
|
|
35
37
|
context,
|
|
36
38
|
options,
|
|
@@ -115,137 +117,167 @@ export class XrplService {
|
|
|
115
117
|
};
|
|
116
118
|
}
|
|
117
119
|
/**
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
120
|
+
* Step 1 of the XLS-56 Batch flow — dry-runs a Batch transaction order and
|
|
121
|
+
* returns the canonical signing data. Each participant must sign
|
|
122
|
+
* `signingPayload` with their own XRPL key; collect those signatures and pass
|
|
123
|
+
* them to `proposeBatch` (Step 3).
|
|
122
124
|
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
+
* Use `signBatchPayloadAndWait` to sign for inner accounts managed by this
|
|
126
|
+
* custody instance.
|
|
125
127
|
*
|
|
126
|
-
* @param
|
|
127
|
-
* @param
|
|
128
|
-
* @
|
|
129
|
-
* @
|
|
130
|
-
* @throws {CustodyError} If signerAddress is not in the batch, or the account is not found
|
|
128
|
+
* @param payload - Submitter address, execution mode, and inner entries
|
|
129
|
+
* @param options - Optional configuration for the dry-run intent
|
|
130
|
+
* @returns The batch signing data (`signingPayload`, `signingPayloadHash`, resolved transactions)
|
|
131
|
+
* @throws {CustodyError} If the dry run fails or does not return batch signing data
|
|
131
132
|
*/
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
133
|
+
async dryRunBatch(payload, options = {}) {
|
|
134
|
+
validateBatchSequencing(payload);
|
|
135
|
+
const context = await this.ports.resolveContext(payload.Account, {
|
|
136
|
+
domainId: options.domainId,
|
|
137
|
+
});
|
|
138
|
+
const operation = buildBatchOperation(payload, []);
|
|
139
|
+
const body = buildDryRunBody(operation, context, options);
|
|
140
|
+
const response = await this.ports.dryRunIntent(body);
|
|
141
|
+
if (response.type !== "v0_CreateTransactionOrder") {
|
|
142
|
+
throw new CustodyError({
|
|
143
|
+
reason: `Unexpected dry-run response type: ${response.type}`,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
if (!response.success) {
|
|
147
|
+
throw new CustodyError({
|
|
148
|
+
reason: `Batch dry run failed: ${response.errors?.join(", ") ?? "unknown error"}`,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
if (response.estimate.type !== "XRPL" || !response.estimate.batchSigningData) {
|
|
152
|
+
throw new CustodyError({
|
|
153
|
+
reason: "Dry run did not return batchSigningData — confirm the operation type is Batch",
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
return response.estimate.batchSigningData;
|
|
157
|
+
}
|
|
143
158
|
/**
|
|
144
|
-
*
|
|
145
|
-
* for
|
|
159
|
+
* Step 2 of the XLS-56 Batch flow — signs the `signingPayload` returned by
|
|
160
|
+
* `dryRunBatch` for a single inner account managed by this custody instance,
|
|
161
|
+
* and waits for the manifest signature.
|
|
146
162
|
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
* Inner accounts on other custody instances sign independently with their own SDK.
|
|
163
|
+
* Inner accounts on other custody instances (or non-custody participants)
|
|
164
|
+
* sign independently with their own keys.
|
|
150
165
|
*
|
|
151
|
-
* @param
|
|
152
|
-
* @param signerAddress -
|
|
166
|
+
* @param signingPayload - Hex-encoded `signingPayload` from `dryRunBatch` response
|
|
167
|
+
* @param signerAddress - XRPL address of the inner account to sign for
|
|
153
168
|
* @param options - Optional configuration for the raw sign intent and polling
|
|
154
|
-
* @returns The signature
|
|
155
|
-
* @throws {CustodyError} If
|
|
156
|
-
*
|
|
169
|
+
* @returns The signature, signing public key, and pre-built BatchSigner shapes
|
|
170
|
+
* @throws {CustodyError} If the signer account is not found, or the signature is not
|
|
171
|
+
* available after maximum retries
|
|
157
172
|
*/
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
// this.validateBatchSigner(batch, signerAddress)
|
|
164
|
-
// const context = await this.resolveInnerBatchContext(signerAddress, options)
|
|
165
|
-
// const signingPubKey = await this.getPublicKey({
|
|
166
|
-
// domainId: context.domainId,
|
|
167
|
-
// accountId: context.accountId,
|
|
168
|
-
// })
|
|
169
|
-
// const base64Encoded = this.encodeBatchForSigning(batch)
|
|
170
|
-
// const { payloadId } = await this.proposeRawSignIntent(base64Encoded, context, options)
|
|
171
|
-
// const signature = await this.waitForManifestSignature(
|
|
172
|
-
// context.domainId,
|
|
173
|
-
// context.accountId,
|
|
174
|
-
// payloadId,
|
|
175
|
-
// options.polling,
|
|
176
|
-
// )
|
|
177
|
-
// return {
|
|
178
|
-
// signature,
|
|
179
|
-
// signingPubKey,
|
|
180
|
-
// batchSigner: {
|
|
181
|
-
// BatchSigner: {
|
|
182
|
-
// Account: signerAddress,
|
|
183
|
-
// SigningPubKey: signingPubKey,
|
|
184
|
-
// TxnSignature: signature,
|
|
185
|
-
// },
|
|
186
|
-
// },
|
|
187
|
-
// custodyBatchSigner: {
|
|
188
|
-
// account: signerAddress,
|
|
189
|
-
// signingPubKey,
|
|
190
|
-
// txnSignature: signature,
|
|
191
|
-
// },
|
|
192
|
-
// }
|
|
193
|
-
// }
|
|
173
|
+
async signBatchPayloadAndWait(signingPayload, signerAddress, options = {}) {
|
|
174
|
+
const handle = await this.signBatchPayload(signingPayload, signerAddress, options);
|
|
175
|
+
const signature = await this.waitForManifestSignature(handle.domainId, handle.accountId, handle.payloadId, options.polling);
|
|
176
|
+
return buildSignBatchPayloadResult(handle, signature);
|
|
177
|
+
}
|
|
194
178
|
/**
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
179
|
+
* Step 2 of the XLS-56 Batch flow (non-blocking variant) — proposes the raw
|
|
180
|
+
* sign intent for the `signingPayload` returned by `dryRunBatch` for a single
|
|
181
|
+
* inner account managed by this custody instance, then returns immediately
|
|
182
|
+
* without waiting for the manifest signature.
|
|
183
|
+
*
|
|
184
|
+
* Use this when the custody instance operator approves signatures
|
|
185
|
+
* out-of-band: persist the returned `SignBatchPayloadHandle` and pass it to
|
|
186
|
+
* `getBatchSignature` later (possibly from another process) to fetch the
|
|
187
|
+
* signature once it is available.
|
|
188
|
+
*
|
|
189
|
+
* @param signingPayload - Hex-encoded `signingPayload` from `dryRunBatch` response
|
|
190
|
+
* @param signerAddress - XRPL address of the inner account to sign for
|
|
191
|
+
* @param options - Optional configuration for the raw sign intent
|
|
192
|
+
* @returns A handle with the manifest ID and the fields needed to retrieve the signature
|
|
193
|
+
* @throws {CustodyError} If the signer account is not found
|
|
198
194
|
*/
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
// })
|
|
220
|
-
// }
|
|
195
|
+
async signBatchPayload(signingPayload, signerAddress, options = {}) {
|
|
196
|
+
if (!isValidAddress(signerAddress)) {
|
|
197
|
+
throw new CustodyError({ reason: `Invalid signerAddress: ${signerAddress}` });
|
|
198
|
+
}
|
|
199
|
+
const context = await this.resolveSignerContext(signerAddress, options);
|
|
200
|
+
const signingPubKey = await this.getPublicKey({
|
|
201
|
+
domainId: context.domainId,
|
|
202
|
+
accountId: context.accountId,
|
|
203
|
+
});
|
|
204
|
+
const base64Encoded = Buffer.from(signingPayload, "hex").toString("base64");
|
|
205
|
+
const { intentResponse, payloadId } = await this.proposeRawSignIntent(base64Encoded, context, options);
|
|
206
|
+
return {
|
|
207
|
+
payloadId,
|
|
208
|
+
domainId: context.domainId,
|
|
209
|
+
accountId: context.accountId,
|
|
210
|
+
signerAddress,
|
|
211
|
+
signingPubKey,
|
|
212
|
+
intentResponse,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
221
215
|
/**
|
|
222
|
-
*
|
|
223
|
-
*
|
|
216
|
+
* Retrieves the signature for a payload proposed via `signBatchPayload`,
|
|
217
|
+
* building the BatchSigner shapes when it is available.
|
|
218
|
+
*
|
|
219
|
+
* Performs a single fetch by default (`maxRetries: 1`); the operator may not
|
|
220
|
+
* have approved the signature yet, in which case `undefined` is returned and
|
|
221
|
+
* the caller decides when to retry. Pass `maxRetries`/`intervalMs` to opt into
|
|
222
|
+
* light polling.
|
|
223
|
+
*
|
|
224
|
+
* @param params - Fields from the `SignBatchPayloadHandle` (a handle may be passed directly)
|
|
225
|
+
* @param options - Optional polling configuration (defaults to a single attempt)
|
|
226
|
+
* @returns The signature and BatchSigner shapes, or `undefined` if not yet signed
|
|
227
|
+
* @throws {CustodyError} On any non-404 error fetching the manifest
|
|
224
228
|
*/
|
|
225
|
-
|
|
226
|
-
const
|
|
227
|
-
if (
|
|
228
|
-
|
|
229
|
-
reason: `Address ${signerAddress} is not involved in any inner transaction of the Batch`,
|
|
230
|
-
});
|
|
229
|
+
async getBatchSignature(params, options = {}) {
|
|
230
|
+
const signature = await this.pollManifestSignature(params.domainId, params.accountId, params.payloadId, { maxRetries: 1, ...options });
|
|
231
|
+
if (isUndefined(signature)) {
|
|
232
|
+
return undefined;
|
|
231
233
|
}
|
|
234
|
+
return buildSignBatchPayloadResult(params, signature);
|
|
232
235
|
}
|
|
233
236
|
/**
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
+
* Step 3 of the XLS-56 Batch flow — submits the Batch as a real intent with
|
|
238
|
+
* collected `batchSigners`. The payload must match the one used for
|
|
239
|
+
* `dryRunBatch`; reuse `options.payloadId` and `options.requestId` if you
|
|
240
|
+
* need referential identity with the dry-run.
|
|
241
|
+
*
|
|
242
|
+
* @param payload - Same submitter, execution mode, and entries as the dry-run
|
|
243
|
+
* @param batchSigners - Signatures collected in Step 2 (one per participant)
|
|
244
|
+
* @param options - Optional configuration for the intent
|
|
245
|
+
* @returns The proposed intent response
|
|
246
|
+
* @throws {CustodyError} If validation fails or the submitter account is not found
|
|
237
247
|
*/
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
248
|
+
async proposeBatch(payload, batchSigners, options = {}) {
|
|
249
|
+
validateBatchSequencing(payload);
|
|
250
|
+
const context = await this.ports.resolveContext(payload.Account, {
|
|
251
|
+
domainId: options.domainId,
|
|
252
|
+
ledgerId: options.ledgerId,
|
|
243
253
|
});
|
|
244
|
-
|
|
254
|
+
const operation = buildBatchOperation(payload, batchSigners);
|
|
255
|
+
const body = buildTransactionIntent({ operation, context, options });
|
|
256
|
+
return this.ports.submitIntent(body);
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Resolves the intent context for an inner-batch signer. Skips the address
|
|
260
|
+
* lookup when `accountId` and `ledgerId` are provided.
|
|
261
|
+
* @private
|
|
262
|
+
*/
|
|
263
|
+
async resolveSignerContext(signerAddress, options) {
|
|
264
|
+
if (options.accountId && options.ledgerId) {
|
|
265
|
+
const fullContext = await this.ports.resolveContext(signerAddress, {
|
|
266
|
+
domainId: options.domainId,
|
|
267
|
+
});
|
|
268
|
+
return {
|
|
269
|
+
domainId: fullContext.domainId,
|
|
270
|
+
userId: fullContext.userId,
|
|
271
|
+
accountId: options.accountId,
|
|
272
|
+
ledgerId: options.ledgerId,
|
|
273
|
+
address: signerAddress,
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
return this.ports.resolveContext(signerAddress, { domainId: options.domainId });
|
|
245
277
|
}
|
|
246
278
|
/**
|
|
247
279
|
* Proposes a raw sign intent with base64-encoded bytes.
|
|
248
|
-
* Shared by rawSign, rawSignAndWait, and
|
|
280
|
+
* Shared by rawSign, rawSignAndWait, and signBatchPayloadAndWait.
|
|
249
281
|
* @private
|
|
250
282
|
*/
|
|
251
283
|
async proposeRawSignIntent(base64Bytes, context, options) {
|
|
@@ -262,6 +294,7 @@ export class XrplService {
|
|
|
262
294
|
.toISOString(),
|
|
263
295
|
targetDomainId: context.domainId,
|
|
264
296
|
id: requestId,
|
|
297
|
+
...(!isUndefined(options.description) && { description: options.description }),
|
|
265
298
|
customProperties: options.requestCustomProperties ?? {},
|
|
266
299
|
payload: {
|
|
267
300
|
id: payloadId,
|
|
@@ -282,89 +315,56 @@ export class XrplService {
|
|
|
282
315
|
}
|
|
283
316
|
/**
|
|
284
317
|
* Polls the manifest until a signature is available, then returns it as uppercase hex.
|
|
285
|
-
*
|
|
286
|
-
* but not yet having a signature.
|
|
318
|
+
* Throws if the signature is still unavailable after the maximum retries.
|
|
287
319
|
* @private
|
|
288
320
|
*/
|
|
289
321
|
async waitForManifestSignature(domainId, accountId, manifestId, options = {}) {
|
|
322
|
+
const signature = await this.pollManifestSignature(domainId, accountId, manifestId, options);
|
|
323
|
+
if (isUndefined(signature)) {
|
|
324
|
+
throw new CustodyError({
|
|
325
|
+
reason: "Manifest signature not available after maximum retries",
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
return signature;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Polls the manifest for a signature, returning it as uppercase hex once
|
|
332
|
+
* available, or `undefined` if still unavailable after the maximum retries.
|
|
333
|
+
* @private
|
|
334
|
+
*/
|
|
335
|
+
async pollManifestSignature(domainId, accountId, manifestId, options = {}) {
|
|
290
336
|
const { maxRetries = 3, intervalMs = 3000, onAttempt } = options;
|
|
291
337
|
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
292
338
|
onAttempt?.(attempt);
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
if (value && value.type === "Unsafe") {
|
|
297
|
-
return Buffer.from(value.signature, "base64").toString("hex").toUpperCase();
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
catch (error) {
|
|
301
|
-
if (!(error instanceof CustodyError && error.statusCode === 404)) {
|
|
302
|
-
throw error;
|
|
303
|
-
}
|
|
339
|
+
const signature = await this.fetchManifestSignature(domainId, accountId, manifestId);
|
|
340
|
+
if (!isUndefined(signature)) {
|
|
341
|
+
return signature;
|
|
304
342
|
}
|
|
305
343
|
if (attempt < maxRetries) {
|
|
306
344
|
await sleep(intervalMs);
|
|
307
345
|
}
|
|
308
346
|
}
|
|
309
|
-
|
|
310
|
-
reason: "Manifest signature not available after maximum retries",
|
|
311
|
-
});
|
|
347
|
+
return undefined;
|
|
312
348
|
}
|
|
313
349
|
/**
|
|
314
|
-
*
|
|
350
|
+
* Fetches the manifest once and returns its signature as uppercase hex, or
|
|
351
|
+
* `undefined` if the manifest does not exist yet (404) or has no signature.
|
|
315
352
|
* @private
|
|
316
353
|
*/
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
payload: {
|
|
332
|
-
accountId: context.accountId,
|
|
333
|
-
customProperties: options.payloadCustomProperties ?? {},
|
|
334
|
-
id: payloadId,
|
|
335
|
-
ledgerId: context.ledgerId,
|
|
336
|
-
parameters: {
|
|
337
|
-
feeStrategy: {
|
|
338
|
-
priority: feePriority,
|
|
339
|
-
type: "Priority",
|
|
340
|
-
},
|
|
341
|
-
memos: [],
|
|
342
|
-
operation,
|
|
343
|
-
type: "XRPL",
|
|
344
|
-
},
|
|
345
|
-
type: "v0_CreateTransactionOrder",
|
|
346
|
-
},
|
|
347
|
-
targetDomainId: context.domainId,
|
|
348
|
-
type: "Propose",
|
|
349
|
-
},
|
|
350
|
-
};
|
|
354
|
+
async fetchManifestSignature(domainId, accountId, manifestId) {
|
|
355
|
+
try {
|
|
356
|
+
const manifest = await this.ports.getManifest(domainId, accountId, manifestId);
|
|
357
|
+
const { value } = manifest.data;
|
|
358
|
+
if (value && value.type === "Unsafe") {
|
|
359
|
+
return Buffer.from(value.signature, "base64").toString("hex").toUpperCase();
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
catch (error) {
|
|
363
|
+
if (!(error instanceof CustodyError && error.statusCode === 404)) {
|
|
364
|
+
throw error;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
return undefined;
|
|
351
368
|
}
|
|
352
369
|
}
|
|
353
|
-
/**
|
|
354
|
-
* Compresses a base64-encoded SPKI/DER secp256k1 public key to its compressed hex form.
|
|
355
|
-
* Uses Node.js built-in crypto via JWK export to extract the raw EC point coordinates.
|
|
356
|
-
*/
|
|
357
|
-
function compressPublicKey(base64PublicKey) {
|
|
358
|
-
const publicKey = createPublicKey({
|
|
359
|
-
key: Buffer.from(base64PublicKey, "base64"),
|
|
360
|
-
format: "der",
|
|
361
|
-
type: "spki",
|
|
362
|
-
});
|
|
363
|
-
const jwk = publicKey.export({ format: "jwk" });
|
|
364
|
-
const x = Buffer.from(jwk.x, "base64url");
|
|
365
|
-
const y = Buffer.from(jwk.y, "base64url");
|
|
366
|
-
const lastByte = y[y.length - 1];
|
|
367
|
-
const prefix = lastByte % 2 === 0 ? "02" : "03";
|
|
368
|
-
return (prefix + x.toString("hex")).toUpperCase();
|
|
369
|
-
}
|
|
370
370
|
//# sourceMappingURL=xrpl.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xrpl.service.js","sourceRoot":"","sources":["../../../src/services/xrpl/xrpl.service.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"xrpl.service.js","sourceRoot":"","sources":["../../../src/services/xrpl/xrpl.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAA+B,MAAM,MAAM,CAAA;AACpF,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEpD,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAiBpD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