@unicitylabs/sphere-sdk 0.7.1-dev.3 → 0.7.1
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 +63 -77
- package/dist/core/index.cjs +541 -37
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +117 -1
- package/dist/core/index.d.ts +117 -1
- package/dist/core/index.js +540 -37
- package/dist/core/index.js.map +1 -1
- package/dist/impl/browser/index.cjs.map +1 -1
- package/dist/impl/browser/index.js.map +1 -1
- package/dist/impl/nodejs/index.cjs.map +1 -1
- package/dist/impl/nodejs/index.js.map +1 -1
- package/dist/index.cjs +669 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +258 -1
- package/dist/index.d.ts +258 -1
- package/dist/index.js +651 -37
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/core/index.d.cts
CHANGED
|
@@ -4313,6 +4313,42 @@ declare class PaymentsModule {
|
|
|
4313
4313
|
* @returns MintNametagResult with success status and token if successful
|
|
4314
4314
|
*/
|
|
4315
4315
|
mintNametag(nametag: string): Promise<MintNametagResult>;
|
|
4316
|
+
/**
|
|
4317
|
+
* Mint a fungible token directly to this wallet (genesis mint).
|
|
4318
|
+
*
|
|
4319
|
+
* Useful for test setups that need to seed a wallet with specific token
|
|
4320
|
+
* balances WITHOUT depending on the testnet faucet HTTP service. The
|
|
4321
|
+
* resulting token has the canonical CoinId bytes (passed in `coinIdHex`)
|
|
4322
|
+
* — when those bytes match a registered symbol in the TokenRegistry,
|
|
4323
|
+
* the token shows up under the symbol's name (e.g. "UCT"). There is no
|
|
4324
|
+
* cryptographic restriction on which key may issue a given CoinId; the
|
|
4325
|
+
* aggregator records the mint regardless of issuer identity.
|
|
4326
|
+
*
|
|
4327
|
+
* The flow:
|
|
4328
|
+
* 1. Generate a random TokenId.
|
|
4329
|
+
* 2. Build TokenCoinData with [(coinId, amount)].
|
|
4330
|
+
* 3. Build MintTransactionData with recipient = self (UnmaskedPredicate
|
|
4331
|
+
* from this wallet's signing service).
|
|
4332
|
+
* 4. Submit MintCommitment to the aggregator.
|
|
4333
|
+
* 5. Wait for the inclusion proof.
|
|
4334
|
+
* 6. Construct an SDK Token via Token.mint().
|
|
4335
|
+
* 7. Convert to wallet Token format and call addToken().
|
|
4336
|
+
*
|
|
4337
|
+
* @param coinIdHex - 64-char lowercase hex CoinId. Must match the bytes
|
|
4338
|
+
* used by the registered symbol if you want the wallet to recognize
|
|
4339
|
+
* the token as that symbol (e.g. UCT's coinId from the public registry).
|
|
4340
|
+
* @param amount - Amount in smallest units (multiply by 10^decimals
|
|
4341
|
+
* when converting from human values).
|
|
4342
|
+
* @returns Result with the resulting wallet Token and its on-chain id.
|
|
4343
|
+
*/
|
|
4344
|
+
mintFungibleToken(coinIdHex: string, amount: bigint): Promise<{
|
|
4345
|
+
success: true;
|
|
4346
|
+
token: Token;
|
|
4347
|
+
tokenId: string;
|
|
4348
|
+
} | {
|
|
4349
|
+
success: false;
|
|
4350
|
+
error: string;
|
|
4351
|
+
}>;
|
|
4316
4352
|
/**
|
|
4317
4353
|
* Check if a nametag is available for minting
|
|
4318
4354
|
* @param nametag - The nametag to check (e.g., "alice" or "@alice")
|
|
@@ -4792,6 +4828,24 @@ declare class AccountingModule {
|
|
|
4792
4828
|
private dirtyLedgerEntries;
|
|
4793
4829
|
/** Count of unknown (not in invoiceTermsCache) invoice IDs in the ledger. */
|
|
4794
4830
|
private unknownLedgerCount;
|
|
4831
|
+
/**
|
|
4832
|
+
* Per-unknown-invoice first-seen timestamp for TTL eviction.
|
|
4833
|
+
*
|
|
4834
|
+
* W1 (steelman round-4): without TTL, an attacker who can deliver 500
|
|
4835
|
+
* inbound transfers with synthesized memo invoiceIds permanently exhausts
|
|
4836
|
+
* the unknown-ledger cap, after which legitimate orphan transfers (out-of-
|
|
4837
|
+
* order delivery for real swaps) are silently dropped at the cap-check.
|
|
4838
|
+
*
|
|
4839
|
+
* Round-5 perf: gated by `unknownLedgerNextSweepMs` to amortize the
|
|
4840
|
+
* sweep cost. The naive every-call sweep is O(N) where N=cap=500;
|
|
4841
|
+
* combined with the per-token cleanup loop inside the sweep it became
|
|
4842
|
+
* O(N×M) on every transfer under flood. Now we sweep at most every
|
|
4843
|
+
* `UNKNOWN_LEDGER_SWEEP_INTERVAL_MS` (60s) UNLESS the cap is currently
|
|
4844
|
+
* full, in which case we sweep on each call (the only path that can
|
|
4845
|
+
* actually drop a legitimate orphan).
|
|
4846
|
+
*/
|
|
4847
|
+
private unknownLedgerFirstSeen;
|
|
4848
|
+
private unknownLedgerNextSweepMs;
|
|
4795
4849
|
/** W17: Tracks whether tokenScanState has been mutated since last flush. */
|
|
4796
4850
|
private tokenScanDirty;
|
|
4797
4851
|
/** W2 fix: Serialization guard for _flushDirtyLedgerEntries. */
|
|
@@ -4976,6 +5030,21 @@ declare class AccountingModule {
|
|
|
4976
5030
|
* @throws {SphereError} `NOT_INITIALIZED` — module not initialized.
|
|
4977
5031
|
*/
|
|
4978
5032
|
getInvoice(invoiceId: string): InvoiceRef | null;
|
|
5033
|
+
/**
|
|
5034
|
+
* Return the set of token IDs that are currently linked to the given
|
|
5035
|
+
* invoice. Populated by both the on-chain `_processTokenTransactions`
|
|
5036
|
+
* path (tokens with `inv:` references) and the transport-memo orphan
|
|
5037
|
+
* buffering path in `_handleIncomingTransfer`.
|
|
5038
|
+
*
|
|
5039
|
+
* Used by callers that want to scope per-invoice operations (e.g.
|
|
5040
|
+
* SwapModule.verifyPayout's L3 validation) to only the tokens that
|
|
5041
|
+
* cover this invoice — avoiding false negatives when the wallet
|
|
5042
|
+
* contains unrelated tokens of the same currency in unconfirmed or
|
|
5043
|
+
* spent state.
|
|
5044
|
+
*
|
|
5045
|
+
* Returns an empty set if no tokens are currently linked.
|
|
5046
|
+
*/
|
|
5047
|
+
getTokenIdsForInvoice(invoiceId: string): Set<string>;
|
|
4979
5048
|
/**
|
|
4980
5049
|
* Explicitly close an invoice. Only target parties may close (§8.3).
|
|
4981
5050
|
*
|
|
@@ -5323,6 +5392,35 @@ declare class AccountingModule {
|
|
|
5323
5392
|
* await and the null assignment, so we loop until the field is null.
|
|
5324
5393
|
*/
|
|
5325
5394
|
private _drainFlushPromise;
|
|
5395
|
+
/**
|
|
5396
|
+
* Synchronously persist any pending provisional ledger entry for `invoiceId`
|
|
5397
|
+
* before returning to the caller. Used by `payInvoice` and
|
|
5398
|
+
* `returnInvoicePayment` to make the in-memory provisional entry durable
|
|
5399
|
+
* inside the same per-invoice gate that wrote it, closing the
|
|
5400
|
+
* crash-mid-conclude race that produces over-coverage on receivers.
|
|
5401
|
+
*
|
|
5402
|
+
* Implementation:
|
|
5403
|
+
* 1. Schedule a flush via the existing `_flushPromise` chain (so
|
|
5404
|
+
* concurrent `_handleTokenChange` callers waiting on the chain
|
|
5405
|
+
* observe ours as part of the sequence).
|
|
5406
|
+
* 2. Await OUR flush directly — NOT `_drainFlushPromise()`, which would
|
|
5407
|
+
* spin while concurrent token changes keep extending the chain and
|
|
5408
|
+
* hold the per-invoice gate for an unbounded number of additional
|
|
5409
|
+
* flushes. We only need OUR provisional entry durable.
|
|
5410
|
+
* 3. `_flushDirtyLedgerEntries` swallows per-invoice `storage.set`
|
|
5411
|
+
* rejections internally (sets a local `step1Failed` flag), leaving
|
|
5412
|
+
* the dirty entry on the set without re-throwing. So we post-check
|
|
5413
|
+
* `dirtyLedgerEntries.has(invoiceId)` and throw a `STORAGE_ERROR`
|
|
5414
|
+
* `SphereError` if our entry is still dirty — propagating to the
|
|
5415
|
+
* caller so they learn about the durability failure rather than
|
|
5416
|
+
* receiving a silent "success" return that lies on disk.
|
|
5417
|
+
*
|
|
5418
|
+
* @param invoiceId The invoice whose provisional entry must be durable.
|
|
5419
|
+
* @param callContext Used in the error message so the caller is named
|
|
5420
|
+
* ('payInvoice' / 'returnInvoicePayment') without
|
|
5421
|
+
* forcing a stack-trace inspection.
|
|
5422
|
+
*/
|
|
5423
|
+
private _persistProvisionalAndVerify;
|
|
5326
5424
|
/**
|
|
5327
5425
|
* Handle an incoming transfer event from PaymentsModule (§6.2).
|
|
5328
5426
|
*
|
|
@@ -6393,6 +6491,23 @@ type LegacyFileType = 'dat' | 'txt' | 'json' | 'mnemonic' | 'unknown';
|
|
|
6393
6491
|
*/
|
|
6394
6492
|
type DecryptionProgressCallback = (iteration: number, total: number) => Promise<void> | void;
|
|
6395
6493
|
|
|
6494
|
+
/**
|
|
6495
|
+
* Compute the Unicity L3 DIRECT:// address that corresponds to a given
|
|
6496
|
+
* compressed secp256k1 public key.
|
|
6497
|
+
*
|
|
6498
|
+
* Deterministic — the underlying primitive `UnmaskedPredicateReference.create`
|
|
6499
|
+
* only uses the public key, so the private key is never needed. This lets
|
|
6500
|
+
* a backend trust only one thing from the client (the chain pubkey, whose
|
|
6501
|
+
* ownership the client proves via signature) and derive everything else
|
|
6502
|
+
* locally. Closes the entire class of "client claims an identifier the
|
|
6503
|
+
* server can't verify" bugs at the API level.
|
|
6504
|
+
*
|
|
6505
|
+
* @param chainPubkey 33-byte compressed secp256k1 pubkey, hex-encoded
|
|
6506
|
+
* (66 chars, leading 02 or 03).
|
|
6507
|
+
* @throws if chainPubkey doesn't match the compressed-secp256k1 format.
|
|
6508
|
+
*/
|
|
6509
|
+
declare function computeDirectAddressFromChainPubkey(chainPubkey: string): Promise<string>;
|
|
6510
|
+
|
|
6396
6511
|
declare function isValidNametag(nametag: string): boolean;
|
|
6397
6512
|
|
|
6398
6513
|
/** Steps reported by the onProgress callback during wallet init/create/load/import */
|
|
@@ -6634,6 +6749,7 @@ interface SphereInitResult {
|
|
|
6634
6749
|
/** Generated mnemonic (only if autoGenerate was used) */
|
|
6635
6750
|
generatedMnemonic?: string;
|
|
6636
6751
|
}
|
|
6752
|
+
|
|
6637
6753
|
/**
|
|
6638
6754
|
* Holds all per-address module instances.
|
|
6639
6755
|
* Each HD address gets its own set so modules can run independently in background.
|
|
@@ -7880,4 +7996,4 @@ interface CheckNetworkHealthOptions {
|
|
|
7880
7996
|
*/
|
|
7881
7997
|
declare function checkNetworkHealth(network?: NetworkType, options?: CheckNetworkHealthOptions): Promise<NetworkHealthResult>;
|
|
7882
7998
|
|
|
7883
|
-
export { type AddressInfo, type AddressModuleSet, CHARSET, type CheckNetworkHealthOptions, CurrencyUtils, DEFAULT_DERIVATION_PATH, DEFAULT_TOKEN_DECIMALS, type DerivedKey, type DiscoverAddressProgress, type DiscoverAddressesOptions, type DiscoverAddressesResult, type DiscoveredAddress, type EncryptedData, type EncryptionOptions, type InitProgress, type InitProgressCallback, type InitProgressStep, type KeyPair, type L1Config, type LogHandler, type LogLevel, type LoggerConfig, type MasterKey, SIGN_MESSAGE_PREFIX, type ScanAddressProgress, type ScanAddressesOptions, type ScanAddressesResult, type ScannedAddressResult, Sphere, type SphereCreateOptions, SphereError, type SphereErrorCode, type SphereImportOptions, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, base58Decode, base58Encode, bytesToHex, checkNetworkHealth, computeHash160, convertBits, createAddress, createBech32, createKeyPair, createSphere, decodeBech32, decrypt, decryptJson, decryptMnemonic, decryptSimple, decryptWithSalt, deriveAddressInfo, deriveChildKey, deriveKeyAtPath, deserializeEncrypted, discoverAddressesImpl, doubleSha256, ec, encodeBech32, encrypt, encryptMnemonic, encryptSimple, entropyToMnemonic, extractFromText, findPattern, formatAmount, generateAddressInfo, generateMasterKey, generateMnemonic, generateRandomKey, getAddressHrp, getPublicKey, getSphere, hash160, hash160ToBytes, hashSignMessage, hexToBytes, identityFromMnemonic, identityFromMnemonicSync, importSphere, initSphere, isEncryptedData, isSphereError, isValidBech32, isValidNametag, isValidPrivateKey, loadSphere, logger, mnemonicToEntropy, mnemonicToSeed, mnemonicToSeedSync, privateKeyToAddressInfo, publicKeyToAddress, randomBytes, randomHex, randomUUID, ripemd160, scanAddressesImpl, serializeEncrypted, sha256, signMessage, sleep, sphereExists, toHumanReadable, toSmallestUnit, validateMnemonic, verifySignedMessage };
|
|
7999
|
+
export { type AddressInfo, type AddressModuleSet, CHARSET, type CheckNetworkHealthOptions, CurrencyUtils, DEFAULT_DERIVATION_PATH, DEFAULT_TOKEN_DECIMALS, type DerivedKey, type DiscoverAddressProgress, type DiscoverAddressesOptions, type DiscoverAddressesResult, type DiscoveredAddress, type EncryptedData, type EncryptionOptions, type InitProgress, type InitProgressCallback, type InitProgressStep, type KeyPair, type L1Config, type LogHandler, type LogLevel, type LoggerConfig, type MasterKey, SIGN_MESSAGE_PREFIX, type ScanAddressProgress, type ScanAddressesOptions, type ScanAddressesResult, type ScannedAddressResult, Sphere, type SphereCreateOptions, SphereError, type SphereErrorCode, type SphereImportOptions, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, base58Decode, base58Encode, bytesToHex, checkNetworkHealth, computeDirectAddressFromChainPubkey, computeHash160, convertBits, createAddress, createBech32, createKeyPair, createSphere, decodeBech32, decrypt, decryptJson, decryptMnemonic, decryptSimple, decryptWithSalt, deriveAddressInfo, deriveChildKey, deriveKeyAtPath, deserializeEncrypted, discoverAddressesImpl, doubleSha256, ec, encodeBech32, encrypt, encryptMnemonic, encryptSimple, entropyToMnemonic, extractFromText, findPattern, formatAmount, generateAddressInfo, generateMasterKey, generateMnemonic, generateRandomKey, getAddressHrp, getPublicKey, getSphere, hash160, hash160ToBytes, hashSignMessage, hexToBytes, identityFromMnemonic, identityFromMnemonicSync, importSphere, initSphere, isEncryptedData, isSphereError, isValidBech32, isValidNametag, isValidPrivateKey, loadSphere, logger, mnemonicToEntropy, mnemonicToSeed, mnemonicToSeedSync, privateKeyToAddressInfo, publicKeyToAddress, randomBytes, randomHex, randomUUID, ripemd160, scanAddressesImpl, serializeEncrypted, sha256, signMessage, sleep, sphereExists, toHumanReadable, toSmallestUnit, validateMnemonic, verifySignedMessage };
|
package/dist/core/index.d.ts
CHANGED
|
@@ -4313,6 +4313,42 @@ declare class PaymentsModule {
|
|
|
4313
4313
|
* @returns MintNametagResult with success status and token if successful
|
|
4314
4314
|
*/
|
|
4315
4315
|
mintNametag(nametag: string): Promise<MintNametagResult>;
|
|
4316
|
+
/**
|
|
4317
|
+
* Mint a fungible token directly to this wallet (genesis mint).
|
|
4318
|
+
*
|
|
4319
|
+
* Useful for test setups that need to seed a wallet with specific token
|
|
4320
|
+
* balances WITHOUT depending on the testnet faucet HTTP service. The
|
|
4321
|
+
* resulting token has the canonical CoinId bytes (passed in `coinIdHex`)
|
|
4322
|
+
* — when those bytes match a registered symbol in the TokenRegistry,
|
|
4323
|
+
* the token shows up under the symbol's name (e.g. "UCT"). There is no
|
|
4324
|
+
* cryptographic restriction on which key may issue a given CoinId; the
|
|
4325
|
+
* aggregator records the mint regardless of issuer identity.
|
|
4326
|
+
*
|
|
4327
|
+
* The flow:
|
|
4328
|
+
* 1. Generate a random TokenId.
|
|
4329
|
+
* 2. Build TokenCoinData with [(coinId, amount)].
|
|
4330
|
+
* 3. Build MintTransactionData with recipient = self (UnmaskedPredicate
|
|
4331
|
+
* from this wallet's signing service).
|
|
4332
|
+
* 4. Submit MintCommitment to the aggregator.
|
|
4333
|
+
* 5. Wait for the inclusion proof.
|
|
4334
|
+
* 6. Construct an SDK Token via Token.mint().
|
|
4335
|
+
* 7. Convert to wallet Token format and call addToken().
|
|
4336
|
+
*
|
|
4337
|
+
* @param coinIdHex - 64-char lowercase hex CoinId. Must match the bytes
|
|
4338
|
+
* used by the registered symbol if you want the wallet to recognize
|
|
4339
|
+
* the token as that symbol (e.g. UCT's coinId from the public registry).
|
|
4340
|
+
* @param amount - Amount in smallest units (multiply by 10^decimals
|
|
4341
|
+
* when converting from human values).
|
|
4342
|
+
* @returns Result with the resulting wallet Token and its on-chain id.
|
|
4343
|
+
*/
|
|
4344
|
+
mintFungibleToken(coinIdHex: string, amount: bigint): Promise<{
|
|
4345
|
+
success: true;
|
|
4346
|
+
token: Token;
|
|
4347
|
+
tokenId: string;
|
|
4348
|
+
} | {
|
|
4349
|
+
success: false;
|
|
4350
|
+
error: string;
|
|
4351
|
+
}>;
|
|
4316
4352
|
/**
|
|
4317
4353
|
* Check if a nametag is available for minting
|
|
4318
4354
|
* @param nametag - The nametag to check (e.g., "alice" or "@alice")
|
|
@@ -4792,6 +4828,24 @@ declare class AccountingModule {
|
|
|
4792
4828
|
private dirtyLedgerEntries;
|
|
4793
4829
|
/** Count of unknown (not in invoiceTermsCache) invoice IDs in the ledger. */
|
|
4794
4830
|
private unknownLedgerCount;
|
|
4831
|
+
/**
|
|
4832
|
+
* Per-unknown-invoice first-seen timestamp for TTL eviction.
|
|
4833
|
+
*
|
|
4834
|
+
* W1 (steelman round-4): without TTL, an attacker who can deliver 500
|
|
4835
|
+
* inbound transfers with synthesized memo invoiceIds permanently exhausts
|
|
4836
|
+
* the unknown-ledger cap, after which legitimate orphan transfers (out-of-
|
|
4837
|
+
* order delivery for real swaps) are silently dropped at the cap-check.
|
|
4838
|
+
*
|
|
4839
|
+
* Round-5 perf: gated by `unknownLedgerNextSweepMs` to amortize the
|
|
4840
|
+
* sweep cost. The naive every-call sweep is O(N) where N=cap=500;
|
|
4841
|
+
* combined with the per-token cleanup loop inside the sweep it became
|
|
4842
|
+
* O(N×M) on every transfer under flood. Now we sweep at most every
|
|
4843
|
+
* `UNKNOWN_LEDGER_SWEEP_INTERVAL_MS` (60s) UNLESS the cap is currently
|
|
4844
|
+
* full, in which case we sweep on each call (the only path that can
|
|
4845
|
+
* actually drop a legitimate orphan).
|
|
4846
|
+
*/
|
|
4847
|
+
private unknownLedgerFirstSeen;
|
|
4848
|
+
private unknownLedgerNextSweepMs;
|
|
4795
4849
|
/** W17: Tracks whether tokenScanState has been mutated since last flush. */
|
|
4796
4850
|
private tokenScanDirty;
|
|
4797
4851
|
/** W2 fix: Serialization guard for _flushDirtyLedgerEntries. */
|
|
@@ -4976,6 +5030,21 @@ declare class AccountingModule {
|
|
|
4976
5030
|
* @throws {SphereError} `NOT_INITIALIZED` — module not initialized.
|
|
4977
5031
|
*/
|
|
4978
5032
|
getInvoice(invoiceId: string): InvoiceRef | null;
|
|
5033
|
+
/**
|
|
5034
|
+
* Return the set of token IDs that are currently linked to the given
|
|
5035
|
+
* invoice. Populated by both the on-chain `_processTokenTransactions`
|
|
5036
|
+
* path (tokens with `inv:` references) and the transport-memo orphan
|
|
5037
|
+
* buffering path in `_handleIncomingTransfer`.
|
|
5038
|
+
*
|
|
5039
|
+
* Used by callers that want to scope per-invoice operations (e.g.
|
|
5040
|
+
* SwapModule.verifyPayout's L3 validation) to only the tokens that
|
|
5041
|
+
* cover this invoice — avoiding false negatives when the wallet
|
|
5042
|
+
* contains unrelated tokens of the same currency in unconfirmed or
|
|
5043
|
+
* spent state.
|
|
5044
|
+
*
|
|
5045
|
+
* Returns an empty set if no tokens are currently linked.
|
|
5046
|
+
*/
|
|
5047
|
+
getTokenIdsForInvoice(invoiceId: string): Set<string>;
|
|
4979
5048
|
/**
|
|
4980
5049
|
* Explicitly close an invoice. Only target parties may close (§8.3).
|
|
4981
5050
|
*
|
|
@@ -5323,6 +5392,35 @@ declare class AccountingModule {
|
|
|
5323
5392
|
* await and the null assignment, so we loop until the field is null.
|
|
5324
5393
|
*/
|
|
5325
5394
|
private _drainFlushPromise;
|
|
5395
|
+
/**
|
|
5396
|
+
* Synchronously persist any pending provisional ledger entry for `invoiceId`
|
|
5397
|
+
* before returning to the caller. Used by `payInvoice` and
|
|
5398
|
+
* `returnInvoicePayment` to make the in-memory provisional entry durable
|
|
5399
|
+
* inside the same per-invoice gate that wrote it, closing the
|
|
5400
|
+
* crash-mid-conclude race that produces over-coverage on receivers.
|
|
5401
|
+
*
|
|
5402
|
+
* Implementation:
|
|
5403
|
+
* 1. Schedule a flush via the existing `_flushPromise` chain (so
|
|
5404
|
+
* concurrent `_handleTokenChange` callers waiting on the chain
|
|
5405
|
+
* observe ours as part of the sequence).
|
|
5406
|
+
* 2. Await OUR flush directly — NOT `_drainFlushPromise()`, which would
|
|
5407
|
+
* spin while concurrent token changes keep extending the chain and
|
|
5408
|
+
* hold the per-invoice gate for an unbounded number of additional
|
|
5409
|
+
* flushes. We only need OUR provisional entry durable.
|
|
5410
|
+
* 3. `_flushDirtyLedgerEntries` swallows per-invoice `storage.set`
|
|
5411
|
+
* rejections internally (sets a local `step1Failed` flag), leaving
|
|
5412
|
+
* the dirty entry on the set without re-throwing. So we post-check
|
|
5413
|
+
* `dirtyLedgerEntries.has(invoiceId)` and throw a `STORAGE_ERROR`
|
|
5414
|
+
* `SphereError` if our entry is still dirty — propagating to the
|
|
5415
|
+
* caller so they learn about the durability failure rather than
|
|
5416
|
+
* receiving a silent "success" return that lies on disk.
|
|
5417
|
+
*
|
|
5418
|
+
* @param invoiceId The invoice whose provisional entry must be durable.
|
|
5419
|
+
* @param callContext Used in the error message so the caller is named
|
|
5420
|
+
* ('payInvoice' / 'returnInvoicePayment') without
|
|
5421
|
+
* forcing a stack-trace inspection.
|
|
5422
|
+
*/
|
|
5423
|
+
private _persistProvisionalAndVerify;
|
|
5326
5424
|
/**
|
|
5327
5425
|
* Handle an incoming transfer event from PaymentsModule (§6.2).
|
|
5328
5426
|
*
|
|
@@ -6393,6 +6491,23 @@ type LegacyFileType = 'dat' | 'txt' | 'json' | 'mnemonic' | 'unknown';
|
|
|
6393
6491
|
*/
|
|
6394
6492
|
type DecryptionProgressCallback = (iteration: number, total: number) => Promise<void> | void;
|
|
6395
6493
|
|
|
6494
|
+
/**
|
|
6495
|
+
* Compute the Unicity L3 DIRECT:// address that corresponds to a given
|
|
6496
|
+
* compressed secp256k1 public key.
|
|
6497
|
+
*
|
|
6498
|
+
* Deterministic — the underlying primitive `UnmaskedPredicateReference.create`
|
|
6499
|
+
* only uses the public key, so the private key is never needed. This lets
|
|
6500
|
+
* a backend trust only one thing from the client (the chain pubkey, whose
|
|
6501
|
+
* ownership the client proves via signature) and derive everything else
|
|
6502
|
+
* locally. Closes the entire class of "client claims an identifier the
|
|
6503
|
+
* server can't verify" bugs at the API level.
|
|
6504
|
+
*
|
|
6505
|
+
* @param chainPubkey 33-byte compressed secp256k1 pubkey, hex-encoded
|
|
6506
|
+
* (66 chars, leading 02 or 03).
|
|
6507
|
+
* @throws if chainPubkey doesn't match the compressed-secp256k1 format.
|
|
6508
|
+
*/
|
|
6509
|
+
declare function computeDirectAddressFromChainPubkey(chainPubkey: string): Promise<string>;
|
|
6510
|
+
|
|
6396
6511
|
declare function isValidNametag(nametag: string): boolean;
|
|
6397
6512
|
|
|
6398
6513
|
/** Steps reported by the onProgress callback during wallet init/create/load/import */
|
|
@@ -6634,6 +6749,7 @@ interface SphereInitResult {
|
|
|
6634
6749
|
/** Generated mnemonic (only if autoGenerate was used) */
|
|
6635
6750
|
generatedMnemonic?: string;
|
|
6636
6751
|
}
|
|
6752
|
+
|
|
6637
6753
|
/**
|
|
6638
6754
|
* Holds all per-address module instances.
|
|
6639
6755
|
* Each HD address gets its own set so modules can run independently in background.
|
|
@@ -7880,4 +7996,4 @@ interface CheckNetworkHealthOptions {
|
|
|
7880
7996
|
*/
|
|
7881
7997
|
declare function checkNetworkHealth(network?: NetworkType, options?: CheckNetworkHealthOptions): Promise<NetworkHealthResult>;
|
|
7882
7998
|
|
|
7883
|
-
export { type AddressInfo, type AddressModuleSet, CHARSET, type CheckNetworkHealthOptions, CurrencyUtils, DEFAULT_DERIVATION_PATH, DEFAULT_TOKEN_DECIMALS, type DerivedKey, type DiscoverAddressProgress, type DiscoverAddressesOptions, type DiscoverAddressesResult, type DiscoveredAddress, type EncryptedData, type EncryptionOptions, type InitProgress, type InitProgressCallback, type InitProgressStep, type KeyPair, type L1Config, type LogHandler, type LogLevel, type LoggerConfig, type MasterKey, SIGN_MESSAGE_PREFIX, type ScanAddressProgress, type ScanAddressesOptions, type ScanAddressesResult, type ScannedAddressResult, Sphere, type SphereCreateOptions, SphereError, type SphereErrorCode, type SphereImportOptions, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, base58Decode, base58Encode, bytesToHex, checkNetworkHealth, computeHash160, convertBits, createAddress, createBech32, createKeyPair, createSphere, decodeBech32, decrypt, decryptJson, decryptMnemonic, decryptSimple, decryptWithSalt, deriveAddressInfo, deriveChildKey, deriveKeyAtPath, deserializeEncrypted, discoverAddressesImpl, doubleSha256, ec, encodeBech32, encrypt, encryptMnemonic, encryptSimple, entropyToMnemonic, extractFromText, findPattern, formatAmount, generateAddressInfo, generateMasterKey, generateMnemonic, generateRandomKey, getAddressHrp, getPublicKey, getSphere, hash160, hash160ToBytes, hashSignMessage, hexToBytes, identityFromMnemonic, identityFromMnemonicSync, importSphere, initSphere, isEncryptedData, isSphereError, isValidBech32, isValidNametag, isValidPrivateKey, loadSphere, logger, mnemonicToEntropy, mnemonicToSeed, mnemonicToSeedSync, privateKeyToAddressInfo, publicKeyToAddress, randomBytes, randomHex, randomUUID, ripemd160, scanAddressesImpl, serializeEncrypted, sha256, signMessage, sleep, sphereExists, toHumanReadable, toSmallestUnit, validateMnemonic, verifySignedMessage };
|
|
7999
|
+
export { type AddressInfo, type AddressModuleSet, CHARSET, type CheckNetworkHealthOptions, CurrencyUtils, DEFAULT_DERIVATION_PATH, DEFAULT_TOKEN_DECIMALS, type DerivedKey, type DiscoverAddressProgress, type DiscoverAddressesOptions, type DiscoverAddressesResult, type DiscoveredAddress, type EncryptedData, type EncryptionOptions, type InitProgress, type InitProgressCallback, type InitProgressStep, type KeyPair, type L1Config, type LogHandler, type LogLevel, type LoggerConfig, type MasterKey, SIGN_MESSAGE_PREFIX, type ScanAddressProgress, type ScanAddressesOptions, type ScanAddressesResult, type ScannedAddressResult, Sphere, type SphereCreateOptions, SphereError, type SphereErrorCode, type SphereImportOptions, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, base58Decode, base58Encode, bytesToHex, checkNetworkHealth, computeDirectAddressFromChainPubkey, computeHash160, convertBits, createAddress, createBech32, createKeyPair, createSphere, decodeBech32, decrypt, decryptJson, decryptMnemonic, decryptSimple, decryptWithSalt, deriveAddressInfo, deriveChildKey, deriveKeyAtPath, deserializeEncrypted, discoverAddressesImpl, doubleSha256, ec, encodeBech32, encrypt, encryptMnemonic, encryptSimple, entropyToMnemonic, extractFromText, findPattern, formatAmount, generateAddressInfo, generateMasterKey, generateMnemonic, generateRandomKey, getAddressHrp, getPublicKey, getSphere, hash160, hash160ToBytes, hashSignMessage, hexToBytes, identityFromMnemonic, identityFromMnemonicSync, importSphere, initSphere, isEncryptedData, isSphereError, isValidBech32, isValidNametag, isValidPrivateKey, loadSphere, logger, mnemonicToEntropy, mnemonicToSeed, mnemonicToSeedSync, privateKeyToAddressInfo, publicKeyToAddress, randomBytes, randomHex, randomUUID, ripemd160, scanAddressesImpl, serializeEncrypted, sha256, signMessage, sleep, sphereExists, toHumanReadable, toSmallestUnit, validateMnemonic, verifySignedMessage };
|