@orbinum/sdk 0.20.1 → 0.21.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.mts +48 -10
- package/dist/index.d.ts +48 -10
- package/dist/index.js +19 -1
- package/dist/index.mjs +18 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -721,6 +721,13 @@ type ZkNote = {
|
|
|
721
721
|
spendingKey: bigint;
|
|
722
722
|
/** Circuit version this note was created under (see `CURRENT_CIRCUIT_VERSION`). Required. */
|
|
723
723
|
circuitVersion: number;
|
|
724
|
+
/**
|
|
725
|
+
* Global Merkle leaf index, when known. Optional so pre-forest vaults
|
|
726
|
+
* need no migration: notes without it predate the first tree seal and
|
|
727
|
+
* belong to tree 0. Populated on shield and on scan; used only to derive
|
|
728
|
+
* the forest tree for same-tree coin selection (`treeIdOf`).
|
|
729
|
+
*/
|
|
730
|
+
leafIndex?: number;
|
|
724
731
|
/** Whether the note has been spent/nullified on-chain. */
|
|
725
732
|
spent: boolean;
|
|
726
733
|
/** Local timestamp when this note was marked spent, or null if still active/unknown. */
|
|
@@ -1095,6 +1102,7 @@ type RpcV2MerkleProof = {
|
|
|
1095
1102
|
path: string[];
|
|
1096
1103
|
leafIndex: number;
|
|
1097
1104
|
treeDepth: number;
|
|
1105
|
+
treeId?: number | undefined;
|
|
1098
1106
|
};
|
|
1099
1107
|
type PrivacyMerkleProof = RpcV2MerkleProof & {
|
|
1100
1108
|
root: string;
|
|
@@ -2301,22 +2309,52 @@ declare function generateTransferProof(params: PrivateTransferProofInputs, optio
|
|
|
2301
2309
|
verbose?: boolean;
|
|
2302
2310
|
}): Promise<ProofResult>;
|
|
2303
2311
|
|
|
2312
|
+
/**
|
|
2313
|
+
* Forest tree a note belongs to.
|
|
2314
|
+
*
|
|
2315
|
+
* Falls back to tree 0 for a missing or malformed `leafIndex`. Both cases are
|
|
2316
|
+
* expected rather than defensive noise:
|
|
2317
|
+
*
|
|
2318
|
+
* - Notes persisted before the forest upgrade carry no index, and they all
|
|
2319
|
+
* predate the first seal, so tree 0 is the correct answer.
|
|
2320
|
+
* - The index originates in an indexer scan hint, which is untrusted. A
|
|
2321
|
+
* `NaN` reaching this function would make every same-tree comparison
|
|
2322
|
+
* false — no pair would ever be selectable and the whole balance would
|
|
2323
|
+
* look unspendable.
|
|
2324
|
+
*/
|
|
2325
|
+
declare function treeIdOf(note: Pick<ZkNote, 'leafIndex'>): number;
|
|
2326
|
+
/**
|
|
2327
|
+
* Outcome of {@link selectNotes}.
|
|
2328
|
+
*
|
|
2329
|
+
* - `[noteA, noteB | null]` — a spendable selection; a `null` second slot
|
|
2330
|
+
* means the transfer runs with a dummy input.
|
|
2331
|
+
* - `{ needsConsolidation: true }` — the balance covers the amount, but only
|
|
2332
|
+
* by pairing notes from different forest trees, which no single proof can
|
|
2333
|
+
* do. The caller should offer a consolidation, not an insufficient-funds
|
|
2334
|
+
* error.
|
|
2335
|
+
* - `null` — no combination covers the amount.
|
|
2336
|
+
*/
|
|
2337
|
+
type CoinSelection = [ZkNote, ZkNote | null] | {
|
|
2338
|
+
needsConsolidation: true;
|
|
2339
|
+
} | null;
|
|
2304
2340
|
/**
|
|
2305
2341
|
* Selects up to 2 unspent notes that together cover `needed` planck.
|
|
2306
2342
|
*
|
|
2307
|
-
*
|
|
2308
|
-
*
|
|
2309
|
-
*
|
|
2310
|
-
*
|
|
2343
|
+
* Both inputs of a transfer are proven together against ONE circuit VK and ONE
|
|
2344
|
+
* public `merkle_root`, so a pair must agree on two things: mixing circuit
|
|
2345
|
+
* versions produces an invalid proof, and notes in different forest trees
|
|
2346
|
+
* anchor to different roots that can never converge. A single note needs
|
|
2347
|
+
* neither check.
|
|
2311
2348
|
*
|
|
2312
|
-
*
|
|
2313
|
-
*
|
|
2314
|
-
*
|
|
2315
|
-
*
|
|
2349
|
+
* Resolution order:
|
|
2350
|
+
* 1. One note that alone covers `needed` → `[note, null]`.
|
|
2351
|
+
* 2. Smallest same-version, same-tree pair whose sum covers it → `[a, b]`.
|
|
2352
|
+
* 3. A cross-tree pair would cover it → `{ needsConsolidation: true }`.
|
|
2353
|
+
* 4. Nothing covers it → `null`.
|
|
2316
2354
|
*
|
|
2317
2355
|
* Only unspent notes with value > 0 are considered.
|
|
2318
2356
|
*/
|
|
2319
|
-
declare function selectNotes(notes: ZkNote[], needed: bigint):
|
|
2357
|
+
declare function selectNotes(notes: ZkNote[], needed: bigint): CoinSelection;
|
|
2320
2358
|
/**
|
|
2321
2359
|
* Builds a dummy `TransferInputNote` for use as the second input in a single-note transfer.
|
|
2322
2360
|
*
|
|
@@ -4453,4 +4491,4 @@ interface ExtrinsicFailedData {
|
|
|
4453
4491
|
dispatch_info: DispatchInfo;
|
|
4454
4492
|
}
|
|
4455
4493
|
|
|
4456
|
-
export { type AccountListing, type AccountMappedData, type AccountMappedEvent, type AccountMappingCall, type AccountMappingEvent, AccountMappingModule, AccountMappingPrecompile, type AccountMetadata, type AccountUnmappedEvent, type ActiveVersionSetEvent, type AddChainLinkArgs, type AddChainLinkParams, type AddSupportedChainArgs, type AliasFullIdentity, type AliasInfo, type AliasListedForSaleEvent, type AliasOnSaleData, type AliasRegisteredData, type AliasRegisteredEvent, type AliasReleasedEvent, type AliasSaleCancelledEvent, type AliasSoldData, type AliasSoldEvent, type AliasTransferredData, type AliasTransferredEvent, type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BatchRegisterVerificationKeysArgs, type BatchVerificationKeysRegisteredEvent, type BlockInfo, type BuyAliasArgs, type Bytes32, CURRENT_CIRCUIT_VERSION, type ChainInfo, type ChainLink, type ChainLinkAddedEvent, type ChainLinkRemovedEvent, CircuitId, CircuitId as CircuitIdType, CircuitVersionResolver, type ClaimShieldedFeesParams, type ClientProviderConfig, type CommitmentsInsertedEvent, type CommitmentsInsertedEventData, type ConnectionStatus, CryptoPrecompiles, type DecodedAddChainLinkArgs, type DecodedBatchArgs, type DecodedDispatchAsPrivateLinkArgs, type DecodedEthereumTransactArgs, type DecodedEvmCallArgs, type DecodedPrecompile, type DecodedPrivateTransferArgs, type DecodedPutAliasForSaleArgs, type DecodedRegisterAliasArgs, type DecodedRemarkArgs, type DecodedRevealPrivateLinkArgs, type DecodedSetAccountMetadataArgs, type DecodedShieldArgs, type DecodedShieldBatchArgs, type DecodedShieldBatchOperation, type DecodedSudoArgs, type DecodedTransferAllArgs, type DecodedTransferArgs, type DecodedTransferKeepAliveArgs, type DecodedUnshieldArgs, type DecryptedMemo, type DispatchAsLinkedAccountArgs, type DispatchAsLinkedParams, type DispatchAsPrivateLinkArgs, type DispatchError, type DispatchInfo, type DynamicBuilder, ENCRYPTED_MEMO_SIZE, EncryptedMemo, type EncryptedNoteRecord, type EndowedEventData, type EthereumExecutedData, type EventData, type EventPhase, type EventRecord, type EvmAddressInfo, type EvmBlock, EvmClient, type EvmExecutedData, type EvmExitReason, EvmExplorer, type EvmLog, type EvmSigner, type EvmTransaction, type EvmTxRequest, type EvmTxSummary, type ExtrinsicDecoder, type ExtrinsicFailedData, type ExtrinsicSuccessData, type FeeClaimProofInputs, type FormatOptions, KNOWN_PRECOMPILES, type KnownPrecompileInfo, type ListingInfo, MIN_SIGNATURE_BYTES, type MerkleRootUpdatedData, type MerkleRootUpdatedEvent, type MerkleTreeInfo, type MetadataUpdatedEvent, NoteBuilder, type NoteDisclosure, type NoteInput, type NoteStatusUpdate, type NullifiersSpentEvent, type NullifiersSpentEventData, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, PRECOMPILE_ADDR, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateChainLinkAddedEvent, type PrivateChainLinkRemovedEvent, type PrivateChainLinkRevealedEvent, type PrivateLink, type PrivateLinkDispatchExecutedEvent, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type ProofVerificationFailedEvent, type ProofVerifiedEvent, type ProxyCallExecutedEvent, type PutAliasOnSaleArgs, type PutOnSaleParams, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type RegisterAliasArgs, type RegisterAssetArgs, type RegisterPrivateLinkArgs, type RegisterVerificationKeyArgs, type RelayerInfo, RelayerStatusModule, type RemoveChainLinkArgs, type RemovePrivateLinkArgs, type RemoveSupportedChainArgs, type RemoveVerificationKeyArgs, type ReservedEventData, type ResolvedAlias, type ResolvedSpendVersion, type RevealPrivateLinkArgs, type RpcV2MerkleProof, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, SLIP0044_NAMESPACE, SPENDING_KEY_VERIFYING_CONTRACT, SPENDING_KEY_WARNING, type ScanCommitment, type SelfEphWindowEntry, type SetAccountMetadataArgs, type SetActiveVersionArgs, type SetMetadataParams, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedEvent, type ShieldedEventData, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, SignatureScheme, type SpendingKeyTypedData, type StatusChangeEvent, type StatusListener, SubstrateClient, type SupportedChain, type SupportedChainAddedEvent, type SupportedChainRemovedEvent, type SystemHealth, type TokenInfo, type TokenTransfer, type TransferAliasArgs, type TransferEventData, type TransferInputNote, type TransferOutputNote, type TryDecryptOptions, type TxResult, type UnsafeTxOptions, type UnshieldArgs, type UnshieldParams, type UnshieldProofInputs, type UnshieldedEvent, type UnshieldedEventData, type UnverifyAssetArgs, VaultLockedError, type VerificationKeyRegisteredEvent, type VerificationKeyRemovedEvent, type VerifyAssetArgs, type VerifyProofArgs, type VkEntry, type ZkNote, type ZkVerifierCall, type ZkVerifierCircuitVersionInfo, type ZkVerifierEvent, type ZkVerifierHistoricalVersion, ZkVerifierModule, type ZkVerifierVersionStats, type ZkVerifierVkHash, accountIdHexToSs58, addressToAccountIdHex, applyNoteStatus, bigintTo32Be, bigintTo32Le, bigintTo32LeArr, blindTag, buildDummyTransferInput, bytesToBigintLE, canonicalAccountId, computeNoteCommitment, computeNullifier, computePathIndices, createNoteDisclosureKey, decodeNoteDisclosureKey, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, deriveSelfEphSk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessageV2, deriveSpendingKeyTypedData, deriveStealthOwnerPk, deriveStealthSk, deriveVaultBlindKey, deriveVaultKey, deriveViewTag, deriveViewingPublicKey, deriveViewingSecretKey, encryptJson, encryptNote, ensureHexPrefix, evmAddressToAccountId, evmToImplicitSubstrate, evmToMappedAccountHex, evmToSubstrate, formatBalance, formatORB, fromBase64, fromHex, generateFeeClaimProof, generateTransferProof, generateUnshieldProof, getPrecompileLabel, hexToBigint, hexToNumber, implicitSubstrateToEvm, isEvmAddress, isImplicitEvmAccount, isSs58, isSubstrateAddress, isUnifiedAddress, leHexToBigint, mapExtrinsicArgs, mapZkEventData, normalizeEvmAddress, noteBlindTag, randomBlinding, recoverOwnerPkPoint, selectNotes, selfEphWindow, shortHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };
|
|
4494
|
+
export { type AccountListing, type AccountMappedData, type AccountMappedEvent, type AccountMappingCall, type AccountMappingEvent, AccountMappingModule, AccountMappingPrecompile, type AccountMetadata, type AccountUnmappedEvent, type ActiveVersionSetEvent, type AddChainLinkArgs, type AddChainLinkParams, type AddSupportedChainArgs, type AliasFullIdentity, type AliasInfo, type AliasListedForSaleEvent, type AliasOnSaleData, type AliasRegisteredData, type AliasRegisteredEvent, type AliasReleasedEvent, type AliasSaleCancelledEvent, type AliasSoldData, type AliasSoldEvent, type AliasTransferredData, type AliasTransferredEvent, type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BatchRegisterVerificationKeysArgs, type BatchVerificationKeysRegisteredEvent, type BlockInfo, type BuyAliasArgs, type Bytes32, CURRENT_CIRCUIT_VERSION, type ChainInfo, type ChainLink, type ChainLinkAddedEvent, type ChainLinkRemovedEvent, CircuitId, CircuitId as CircuitIdType, CircuitVersionResolver, type ClaimShieldedFeesParams, type ClientProviderConfig, type CommitmentsInsertedEvent, type CommitmentsInsertedEventData, type ConnectionStatus, CryptoPrecompiles, type DecodedAddChainLinkArgs, type DecodedBatchArgs, type DecodedDispatchAsPrivateLinkArgs, type DecodedEthereumTransactArgs, type DecodedEvmCallArgs, type DecodedPrecompile, type DecodedPrivateTransferArgs, type DecodedPutAliasForSaleArgs, type DecodedRegisterAliasArgs, type DecodedRemarkArgs, type DecodedRevealPrivateLinkArgs, type DecodedSetAccountMetadataArgs, type DecodedShieldArgs, type DecodedShieldBatchArgs, type DecodedShieldBatchOperation, type DecodedSudoArgs, type DecodedTransferAllArgs, type DecodedTransferArgs, type DecodedTransferKeepAliveArgs, type DecodedUnshieldArgs, type DecryptedMemo, type DispatchAsLinkedAccountArgs, type DispatchAsLinkedParams, type DispatchAsPrivateLinkArgs, type DispatchError, type DispatchInfo, type DynamicBuilder, ENCRYPTED_MEMO_SIZE, EncryptedMemo, type EncryptedNoteRecord, type EndowedEventData, type EthereumExecutedData, type EventData, type EventPhase, type EventRecord, type EvmAddressInfo, type EvmBlock, EvmClient, type EvmExecutedData, type EvmExitReason, EvmExplorer, type EvmLog, type EvmSigner, type EvmTransaction, type EvmTxRequest, type EvmTxSummary, type ExtrinsicDecoder, type ExtrinsicFailedData, type ExtrinsicSuccessData, type FeeClaimProofInputs, type FormatOptions, KNOWN_PRECOMPILES, type KnownPrecompileInfo, type ListingInfo, MIN_SIGNATURE_BYTES, type MerkleRootUpdatedData, type MerkleRootUpdatedEvent, type MerkleTreeInfo, type MetadataUpdatedEvent, NoteBuilder, type NoteDisclosure, type NoteInput, type NoteStatusUpdate, type NullifiersSpentEvent, type NullifiersSpentEventData, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, PRECOMPILE_ADDR, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateChainLinkAddedEvent, type PrivateChainLinkRemovedEvent, type PrivateChainLinkRevealedEvent, type PrivateLink, type PrivateLinkDispatchExecutedEvent, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type ProofVerificationFailedEvent, type ProofVerifiedEvent, type ProxyCallExecutedEvent, type PutAliasOnSaleArgs, type PutOnSaleParams, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type RegisterAliasArgs, type RegisterAssetArgs, type RegisterPrivateLinkArgs, type RegisterVerificationKeyArgs, type RelayerInfo, RelayerStatusModule, type RemoveChainLinkArgs, type RemovePrivateLinkArgs, type RemoveSupportedChainArgs, type RemoveVerificationKeyArgs, type ReservedEventData, type ResolvedAlias, type ResolvedSpendVersion, type RevealPrivateLinkArgs, type RpcV2MerkleProof, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, SLIP0044_NAMESPACE, SPENDING_KEY_VERIFYING_CONTRACT, SPENDING_KEY_WARNING, type ScanCommitment, type SelfEphWindowEntry, type SetAccountMetadataArgs, type SetActiveVersionArgs, type SetMetadataParams, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedEvent, type ShieldedEventData, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, SignatureScheme, type SpendingKeyTypedData, type StatusChangeEvent, type StatusListener, SubstrateClient, type SupportedChain, type SupportedChainAddedEvent, type SupportedChainRemovedEvent, type SystemHealth, type TokenInfo, type TokenTransfer, type TransferAliasArgs, type TransferEventData, type TransferInputNote, type TransferOutputNote, type TryDecryptOptions, type TxResult, type UnsafeTxOptions, type UnshieldArgs, type UnshieldParams, type UnshieldProofInputs, type UnshieldedEvent, type UnshieldedEventData, type UnverifyAssetArgs, VaultLockedError, type VerificationKeyRegisteredEvent, type VerificationKeyRemovedEvent, type VerifyAssetArgs, type VerifyProofArgs, type VkEntry, type ZkNote, type ZkVerifierCall, type ZkVerifierCircuitVersionInfo, type ZkVerifierEvent, type ZkVerifierHistoricalVersion, ZkVerifierModule, type ZkVerifierVersionStats, type ZkVerifierVkHash, accountIdHexToSs58, addressToAccountIdHex, applyNoteStatus, bigintTo32Be, bigintTo32Le, bigintTo32LeArr, blindTag, buildDummyTransferInput, bytesToBigintLE, canonicalAccountId, computeNoteCommitment, computeNullifier, computePathIndices, createNoteDisclosureKey, decodeNoteDisclosureKey, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, deriveSelfEphSk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessageV2, deriveSpendingKeyTypedData, deriveStealthOwnerPk, deriveStealthSk, deriveVaultBlindKey, deriveVaultKey, deriveViewTag, deriveViewingPublicKey, deriveViewingSecretKey, encryptJson, encryptNote, ensureHexPrefix, evmAddressToAccountId, evmToImplicitSubstrate, evmToMappedAccountHex, evmToSubstrate, formatBalance, formatORB, fromBase64, fromHex, generateFeeClaimProof, generateTransferProof, generateUnshieldProof, getPrecompileLabel, hexToBigint, hexToNumber, implicitSubstrateToEvm, isEvmAddress, isImplicitEvmAccount, isSs58, isSubstrateAddress, isUnifiedAddress, leHexToBigint, mapExtrinsicArgs, mapZkEventData, normalizeEvmAddress, noteBlindTag, randomBlinding, recoverOwnerPkPoint, selectNotes, selfEphWindow, shortHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, treeIdOf, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };
|
package/dist/index.d.ts
CHANGED
|
@@ -721,6 +721,13 @@ type ZkNote = {
|
|
|
721
721
|
spendingKey: bigint;
|
|
722
722
|
/** Circuit version this note was created under (see `CURRENT_CIRCUIT_VERSION`). Required. */
|
|
723
723
|
circuitVersion: number;
|
|
724
|
+
/**
|
|
725
|
+
* Global Merkle leaf index, when known. Optional so pre-forest vaults
|
|
726
|
+
* need no migration: notes without it predate the first tree seal and
|
|
727
|
+
* belong to tree 0. Populated on shield and on scan; used only to derive
|
|
728
|
+
* the forest tree for same-tree coin selection (`treeIdOf`).
|
|
729
|
+
*/
|
|
730
|
+
leafIndex?: number;
|
|
724
731
|
/** Whether the note has been spent/nullified on-chain. */
|
|
725
732
|
spent: boolean;
|
|
726
733
|
/** Local timestamp when this note was marked spent, or null if still active/unknown. */
|
|
@@ -1095,6 +1102,7 @@ type RpcV2MerkleProof = {
|
|
|
1095
1102
|
path: string[];
|
|
1096
1103
|
leafIndex: number;
|
|
1097
1104
|
treeDepth: number;
|
|
1105
|
+
treeId?: number | undefined;
|
|
1098
1106
|
};
|
|
1099
1107
|
type PrivacyMerkleProof = RpcV2MerkleProof & {
|
|
1100
1108
|
root: string;
|
|
@@ -2301,22 +2309,52 @@ declare function generateTransferProof(params: PrivateTransferProofInputs, optio
|
|
|
2301
2309
|
verbose?: boolean;
|
|
2302
2310
|
}): Promise<ProofResult>;
|
|
2303
2311
|
|
|
2312
|
+
/**
|
|
2313
|
+
* Forest tree a note belongs to.
|
|
2314
|
+
*
|
|
2315
|
+
* Falls back to tree 0 for a missing or malformed `leafIndex`. Both cases are
|
|
2316
|
+
* expected rather than defensive noise:
|
|
2317
|
+
*
|
|
2318
|
+
* - Notes persisted before the forest upgrade carry no index, and they all
|
|
2319
|
+
* predate the first seal, so tree 0 is the correct answer.
|
|
2320
|
+
* - The index originates in an indexer scan hint, which is untrusted. A
|
|
2321
|
+
* `NaN` reaching this function would make every same-tree comparison
|
|
2322
|
+
* false — no pair would ever be selectable and the whole balance would
|
|
2323
|
+
* look unspendable.
|
|
2324
|
+
*/
|
|
2325
|
+
declare function treeIdOf(note: Pick<ZkNote, 'leafIndex'>): number;
|
|
2326
|
+
/**
|
|
2327
|
+
* Outcome of {@link selectNotes}.
|
|
2328
|
+
*
|
|
2329
|
+
* - `[noteA, noteB | null]` — a spendable selection; a `null` second slot
|
|
2330
|
+
* means the transfer runs with a dummy input.
|
|
2331
|
+
* - `{ needsConsolidation: true }` — the balance covers the amount, but only
|
|
2332
|
+
* by pairing notes from different forest trees, which no single proof can
|
|
2333
|
+
* do. The caller should offer a consolidation, not an insufficient-funds
|
|
2334
|
+
* error.
|
|
2335
|
+
* - `null` — no combination covers the amount.
|
|
2336
|
+
*/
|
|
2337
|
+
type CoinSelection = [ZkNote, ZkNote | null] | {
|
|
2338
|
+
needsConsolidation: true;
|
|
2339
|
+
} | null;
|
|
2304
2340
|
/**
|
|
2305
2341
|
* Selects up to 2 unspent notes that together cover `needed` planck.
|
|
2306
2342
|
*
|
|
2307
|
-
*
|
|
2308
|
-
*
|
|
2309
|
-
*
|
|
2310
|
-
*
|
|
2343
|
+
* Both inputs of a transfer are proven together against ONE circuit VK and ONE
|
|
2344
|
+
* public `merkle_root`, so a pair must agree on two things: mixing circuit
|
|
2345
|
+
* versions produces an invalid proof, and notes in different forest trees
|
|
2346
|
+
* anchor to different roots that can never converge. A single note needs
|
|
2347
|
+
* neither check.
|
|
2311
2348
|
*
|
|
2312
|
-
*
|
|
2313
|
-
*
|
|
2314
|
-
*
|
|
2315
|
-
*
|
|
2349
|
+
* Resolution order:
|
|
2350
|
+
* 1. One note that alone covers `needed` → `[note, null]`.
|
|
2351
|
+
* 2. Smallest same-version, same-tree pair whose sum covers it → `[a, b]`.
|
|
2352
|
+
* 3. A cross-tree pair would cover it → `{ needsConsolidation: true }`.
|
|
2353
|
+
* 4. Nothing covers it → `null`.
|
|
2316
2354
|
*
|
|
2317
2355
|
* Only unspent notes with value > 0 are considered.
|
|
2318
2356
|
*/
|
|
2319
|
-
declare function selectNotes(notes: ZkNote[], needed: bigint):
|
|
2357
|
+
declare function selectNotes(notes: ZkNote[], needed: bigint): CoinSelection;
|
|
2320
2358
|
/**
|
|
2321
2359
|
* Builds a dummy `TransferInputNote` for use as the second input in a single-note transfer.
|
|
2322
2360
|
*
|
|
@@ -4453,4 +4491,4 @@ interface ExtrinsicFailedData {
|
|
|
4453
4491
|
dispatch_info: DispatchInfo;
|
|
4454
4492
|
}
|
|
4455
4493
|
|
|
4456
|
-
export { type AccountListing, type AccountMappedData, type AccountMappedEvent, type AccountMappingCall, type AccountMappingEvent, AccountMappingModule, AccountMappingPrecompile, type AccountMetadata, type AccountUnmappedEvent, type ActiveVersionSetEvent, type AddChainLinkArgs, type AddChainLinkParams, type AddSupportedChainArgs, type AliasFullIdentity, type AliasInfo, type AliasListedForSaleEvent, type AliasOnSaleData, type AliasRegisteredData, type AliasRegisteredEvent, type AliasReleasedEvent, type AliasSaleCancelledEvent, type AliasSoldData, type AliasSoldEvent, type AliasTransferredData, type AliasTransferredEvent, type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BatchRegisterVerificationKeysArgs, type BatchVerificationKeysRegisteredEvent, type BlockInfo, type BuyAliasArgs, type Bytes32, CURRENT_CIRCUIT_VERSION, type ChainInfo, type ChainLink, type ChainLinkAddedEvent, type ChainLinkRemovedEvent, CircuitId, CircuitId as CircuitIdType, CircuitVersionResolver, type ClaimShieldedFeesParams, type ClientProviderConfig, type CommitmentsInsertedEvent, type CommitmentsInsertedEventData, type ConnectionStatus, CryptoPrecompiles, type DecodedAddChainLinkArgs, type DecodedBatchArgs, type DecodedDispatchAsPrivateLinkArgs, type DecodedEthereumTransactArgs, type DecodedEvmCallArgs, type DecodedPrecompile, type DecodedPrivateTransferArgs, type DecodedPutAliasForSaleArgs, type DecodedRegisterAliasArgs, type DecodedRemarkArgs, type DecodedRevealPrivateLinkArgs, type DecodedSetAccountMetadataArgs, type DecodedShieldArgs, type DecodedShieldBatchArgs, type DecodedShieldBatchOperation, type DecodedSudoArgs, type DecodedTransferAllArgs, type DecodedTransferArgs, type DecodedTransferKeepAliveArgs, type DecodedUnshieldArgs, type DecryptedMemo, type DispatchAsLinkedAccountArgs, type DispatchAsLinkedParams, type DispatchAsPrivateLinkArgs, type DispatchError, type DispatchInfo, type DynamicBuilder, ENCRYPTED_MEMO_SIZE, EncryptedMemo, type EncryptedNoteRecord, type EndowedEventData, type EthereumExecutedData, type EventData, type EventPhase, type EventRecord, type EvmAddressInfo, type EvmBlock, EvmClient, type EvmExecutedData, type EvmExitReason, EvmExplorer, type EvmLog, type EvmSigner, type EvmTransaction, type EvmTxRequest, type EvmTxSummary, type ExtrinsicDecoder, type ExtrinsicFailedData, type ExtrinsicSuccessData, type FeeClaimProofInputs, type FormatOptions, KNOWN_PRECOMPILES, type KnownPrecompileInfo, type ListingInfo, MIN_SIGNATURE_BYTES, type MerkleRootUpdatedData, type MerkleRootUpdatedEvent, type MerkleTreeInfo, type MetadataUpdatedEvent, NoteBuilder, type NoteDisclosure, type NoteInput, type NoteStatusUpdate, type NullifiersSpentEvent, type NullifiersSpentEventData, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, PRECOMPILE_ADDR, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateChainLinkAddedEvent, type PrivateChainLinkRemovedEvent, type PrivateChainLinkRevealedEvent, type PrivateLink, type PrivateLinkDispatchExecutedEvent, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type ProofVerificationFailedEvent, type ProofVerifiedEvent, type ProxyCallExecutedEvent, type PutAliasOnSaleArgs, type PutOnSaleParams, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type RegisterAliasArgs, type RegisterAssetArgs, type RegisterPrivateLinkArgs, type RegisterVerificationKeyArgs, type RelayerInfo, RelayerStatusModule, type RemoveChainLinkArgs, type RemovePrivateLinkArgs, type RemoveSupportedChainArgs, type RemoveVerificationKeyArgs, type ReservedEventData, type ResolvedAlias, type ResolvedSpendVersion, type RevealPrivateLinkArgs, type RpcV2MerkleProof, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, SLIP0044_NAMESPACE, SPENDING_KEY_VERIFYING_CONTRACT, SPENDING_KEY_WARNING, type ScanCommitment, type SelfEphWindowEntry, type SetAccountMetadataArgs, type SetActiveVersionArgs, type SetMetadataParams, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedEvent, type ShieldedEventData, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, SignatureScheme, type SpendingKeyTypedData, type StatusChangeEvent, type StatusListener, SubstrateClient, type SupportedChain, type SupportedChainAddedEvent, type SupportedChainRemovedEvent, type SystemHealth, type TokenInfo, type TokenTransfer, type TransferAliasArgs, type TransferEventData, type TransferInputNote, type TransferOutputNote, type TryDecryptOptions, type TxResult, type UnsafeTxOptions, type UnshieldArgs, type UnshieldParams, type UnshieldProofInputs, type UnshieldedEvent, type UnshieldedEventData, type UnverifyAssetArgs, VaultLockedError, type VerificationKeyRegisteredEvent, type VerificationKeyRemovedEvent, type VerifyAssetArgs, type VerifyProofArgs, type VkEntry, type ZkNote, type ZkVerifierCall, type ZkVerifierCircuitVersionInfo, type ZkVerifierEvent, type ZkVerifierHistoricalVersion, ZkVerifierModule, type ZkVerifierVersionStats, type ZkVerifierVkHash, accountIdHexToSs58, addressToAccountIdHex, applyNoteStatus, bigintTo32Be, bigintTo32Le, bigintTo32LeArr, blindTag, buildDummyTransferInput, bytesToBigintLE, canonicalAccountId, computeNoteCommitment, computeNullifier, computePathIndices, createNoteDisclosureKey, decodeNoteDisclosureKey, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, deriveSelfEphSk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessageV2, deriveSpendingKeyTypedData, deriveStealthOwnerPk, deriveStealthSk, deriveVaultBlindKey, deriveVaultKey, deriveViewTag, deriveViewingPublicKey, deriveViewingSecretKey, encryptJson, encryptNote, ensureHexPrefix, evmAddressToAccountId, evmToImplicitSubstrate, evmToMappedAccountHex, evmToSubstrate, formatBalance, formatORB, fromBase64, fromHex, generateFeeClaimProof, generateTransferProof, generateUnshieldProof, getPrecompileLabel, hexToBigint, hexToNumber, implicitSubstrateToEvm, isEvmAddress, isImplicitEvmAccount, isSs58, isSubstrateAddress, isUnifiedAddress, leHexToBigint, mapExtrinsicArgs, mapZkEventData, normalizeEvmAddress, noteBlindTag, randomBlinding, recoverOwnerPkPoint, selectNotes, selfEphWindow, shortHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };
|
|
4494
|
+
export { type AccountListing, type AccountMappedData, type AccountMappedEvent, type AccountMappingCall, type AccountMappingEvent, AccountMappingModule, AccountMappingPrecompile, type AccountMetadata, type AccountUnmappedEvent, type ActiveVersionSetEvent, type AddChainLinkArgs, type AddChainLinkParams, type AddSupportedChainArgs, type AliasFullIdentity, type AliasInfo, type AliasListedForSaleEvent, type AliasOnSaleData, type AliasRegisteredData, type AliasRegisteredEvent, type AliasReleasedEvent, type AliasSaleCancelledEvent, type AliasSoldData, type AliasSoldEvent, type AliasTransferredData, type AliasTransferredEvent, type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BatchRegisterVerificationKeysArgs, type BatchVerificationKeysRegisteredEvent, type BlockInfo, type BuyAliasArgs, type Bytes32, CURRENT_CIRCUIT_VERSION, type ChainInfo, type ChainLink, type ChainLinkAddedEvent, type ChainLinkRemovedEvent, CircuitId, CircuitId as CircuitIdType, CircuitVersionResolver, type ClaimShieldedFeesParams, type ClientProviderConfig, type CommitmentsInsertedEvent, type CommitmentsInsertedEventData, type ConnectionStatus, CryptoPrecompiles, type DecodedAddChainLinkArgs, type DecodedBatchArgs, type DecodedDispatchAsPrivateLinkArgs, type DecodedEthereumTransactArgs, type DecodedEvmCallArgs, type DecodedPrecompile, type DecodedPrivateTransferArgs, type DecodedPutAliasForSaleArgs, type DecodedRegisterAliasArgs, type DecodedRemarkArgs, type DecodedRevealPrivateLinkArgs, type DecodedSetAccountMetadataArgs, type DecodedShieldArgs, type DecodedShieldBatchArgs, type DecodedShieldBatchOperation, type DecodedSudoArgs, type DecodedTransferAllArgs, type DecodedTransferArgs, type DecodedTransferKeepAliveArgs, type DecodedUnshieldArgs, type DecryptedMemo, type DispatchAsLinkedAccountArgs, type DispatchAsLinkedParams, type DispatchAsPrivateLinkArgs, type DispatchError, type DispatchInfo, type DynamicBuilder, ENCRYPTED_MEMO_SIZE, EncryptedMemo, type EncryptedNoteRecord, type EndowedEventData, type EthereumExecutedData, type EventData, type EventPhase, type EventRecord, type EvmAddressInfo, type EvmBlock, EvmClient, type EvmExecutedData, type EvmExitReason, EvmExplorer, type EvmLog, type EvmSigner, type EvmTransaction, type EvmTxRequest, type EvmTxSummary, type ExtrinsicDecoder, type ExtrinsicFailedData, type ExtrinsicSuccessData, type FeeClaimProofInputs, type FormatOptions, KNOWN_PRECOMPILES, type KnownPrecompileInfo, type ListingInfo, MIN_SIGNATURE_BYTES, type MerkleRootUpdatedData, type MerkleRootUpdatedEvent, type MerkleTreeInfo, type MetadataUpdatedEvent, NoteBuilder, type NoteDisclosure, type NoteInput, type NoteStatusUpdate, type NullifiersSpentEvent, type NullifiersSpentEventData, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, PRECOMPILE_ADDR, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateChainLinkAddedEvent, type PrivateChainLinkRemovedEvent, type PrivateChainLinkRevealedEvent, type PrivateLink, type PrivateLinkDispatchExecutedEvent, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type ProofVerificationFailedEvent, type ProofVerifiedEvent, type ProxyCallExecutedEvent, type PutAliasOnSaleArgs, type PutOnSaleParams, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type RegisterAliasArgs, type RegisterAssetArgs, type RegisterPrivateLinkArgs, type RegisterVerificationKeyArgs, type RelayerInfo, RelayerStatusModule, type RemoveChainLinkArgs, type RemovePrivateLinkArgs, type RemoveSupportedChainArgs, type RemoveVerificationKeyArgs, type ReservedEventData, type ResolvedAlias, type ResolvedSpendVersion, type RevealPrivateLinkArgs, type RpcV2MerkleProof, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, SLIP0044_NAMESPACE, SPENDING_KEY_VERIFYING_CONTRACT, SPENDING_KEY_WARNING, type ScanCommitment, type SelfEphWindowEntry, type SetAccountMetadataArgs, type SetActiveVersionArgs, type SetMetadataParams, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedEvent, type ShieldedEventData, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, SignatureScheme, type SpendingKeyTypedData, type StatusChangeEvent, type StatusListener, SubstrateClient, type SupportedChain, type SupportedChainAddedEvent, type SupportedChainRemovedEvent, type SystemHealth, type TokenInfo, type TokenTransfer, type TransferAliasArgs, type TransferEventData, type TransferInputNote, type TransferOutputNote, type TryDecryptOptions, type TxResult, type UnsafeTxOptions, type UnshieldArgs, type UnshieldParams, type UnshieldProofInputs, type UnshieldedEvent, type UnshieldedEventData, type UnverifyAssetArgs, VaultLockedError, type VerificationKeyRegisteredEvent, type VerificationKeyRemovedEvent, type VerifyAssetArgs, type VerifyProofArgs, type VkEntry, type ZkNote, type ZkVerifierCall, type ZkVerifierCircuitVersionInfo, type ZkVerifierEvent, type ZkVerifierHistoricalVersion, ZkVerifierModule, type ZkVerifierVersionStats, type ZkVerifierVkHash, accountIdHexToSs58, addressToAccountIdHex, applyNoteStatus, bigintTo32Be, bigintTo32Le, bigintTo32LeArr, blindTag, buildDummyTransferInput, bytesToBigintLE, canonicalAccountId, computeNoteCommitment, computeNullifier, computePathIndices, createNoteDisclosureKey, decodeNoteDisclosureKey, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, deriveSelfEphSk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessageV2, deriveSpendingKeyTypedData, deriveStealthOwnerPk, deriveStealthSk, deriveVaultBlindKey, deriveVaultKey, deriveViewTag, deriveViewingPublicKey, deriveViewingSecretKey, encryptJson, encryptNote, ensureHexPrefix, evmAddressToAccountId, evmToImplicitSubstrate, evmToMappedAccountHex, evmToSubstrate, formatBalance, formatORB, fromBase64, fromHex, generateFeeClaimProof, generateTransferProof, generateUnshieldProof, getPrecompileLabel, hexToBigint, hexToNumber, implicitSubstrateToEvm, isEvmAddress, isImplicitEvmAccount, isSs58, isSubstrateAddress, isUnifiedAddress, leHexToBigint, mapExtrinsicArgs, mapZkEventData, normalizeEvmAddress, noteBlindTag, randomBlinding, recoverOwnerPkPoint, selectNotes, selfEphWindow, shortHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, treeIdOf, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };
|
package/dist/index.js
CHANGED
|
@@ -131,6 +131,7 @@ __export(index_exports, {
|
|
|
131
131
|
toBase64: () => toBase64,
|
|
132
132
|
toHex: () => toHex,
|
|
133
133
|
toTxResult: () => toTxResult,
|
|
134
|
+
treeIdOf: () => treeIdOf,
|
|
134
135
|
truncateMiddle: () => truncateMiddle,
|
|
135
136
|
tryDecryptNote: () => tryDecryptNote,
|
|
136
137
|
tryDecryptNoteVerbose: () => tryDecryptNoteVerbose,
|
|
@@ -4100,6 +4101,7 @@ function tryDecryptNoteVerbose(commitment, viewingSecretKey, spendingKey, ownOwn
|
|
|
4100
4101
|
blinding: plaintext.blinding,
|
|
4101
4102
|
spendingKey: effectiveSpendingKey,
|
|
4102
4103
|
circuitVersion: plaintext.circuitVersion,
|
|
4104
|
+
...Number.isSafeInteger(commitment.leafIndex) && commitment.leafIndex >= 0 && commitment.leafIndex < 2 ** 32 ? { leafIndex: commitment.leafIndex } : {},
|
|
4103
4105
|
spent: false,
|
|
4104
4106
|
spentAt: null,
|
|
4105
4107
|
commitment: recomputed,
|
|
@@ -4164,6 +4166,12 @@ function decodeNoteDisclosureKey(key) {
|
|
|
4164
4166
|
|
|
4165
4167
|
// src/shielded-pool/protocol/coinSelection.ts
|
|
4166
4168
|
var TRANSFER_TREE_DEPTH = 20;
|
|
4169
|
+
var LEAVES_PER_TREE = 1 << TRANSFER_TREE_DEPTH;
|
|
4170
|
+
function treeIdOf(note) {
|
|
4171
|
+
const idx = note.leafIndex;
|
|
4172
|
+
if (idx === void 0 || !Number.isSafeInteger(idx) || idx < 0 || idx >= 2 ** 32) return 0;
|
|
4173
|
+
return Math.floor(idx / LEAVES_PER_TREE);
|
|
4174
|
+
}
|
|
4167
4175
|
function selectNotes(notes, needed) {
|
|
4168
4176
|
const unspent = notes.filter((n) => !n.spent && n.value > 0n);
|
|
4169
4177
|
const sorted = [...unspent].sort((a, b) => a.value < b.value ? -1 : 1);
|
|
@@ -4173,11 +4181,20 @@ function selectNotes(notes, needed) {
|
|
|
4173
4181
|
for (let j = i + 1; j < sorted.length; j++) {
|
|
4174
4182
|
const a = sorted[i];
|
|
4175
4183
|
const b = sorted[j];
|
|
4176
|
-
if (a !== void 0 && b !== void 0 && a.circuitVersion === b.circuitVersion && a.value + b.value >= needed) {
|
|
4184
|
+
if (a !== void 0 && b !== void 0 && a.circuitVersion === b.circuitVersion && treeIdOf(a) === treeIdOf(b) && a.value + b.value >= needed) {
|
|
4177
4185
|
return [a, b];
|
|
4178
4186
|
}
|
|
4179
4187
|
}
|
|
4180
4188
|
}
|
|
4189
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
4190
|
+
for (let j = i + 1; j < sorted.length; j++) {
|
|
4191
|
+
const a = sorted[i];
|
|
4192
|
+
const b = sorted[j];
|
|
4193
|
+
if (a !== void 0 && b !== void 0 && a.circuitVersion === b.circuitVersion && a.value + b.value >= needed) {
|
|
4194
|
+
return { needsConsolidation: true };
|
|
4195
|
+
}
|
|
4196
|
+
}
|
|
4197
|
+
}
|
|
4181
4198
|
return null;
|
|
4182
4199
|
}
|
|
4183
4200
|
function buildDummyTransferInput(assetId) {
|
|
@@ -5579,6 +5596,7 @@ var import_polkadot_api5 = require("polkadot-api");
|
|
|
5579
5596
|
toBase64,
|
|
5580
5597
|
toHex,
|
|
5581
5598
|
toTxResult,
|
|
5599
|
+
treeIdOf,
|
|
5582
5600
|
truncateMiddle,
|
|
5583
5601
|
tryDecryptNote,
|
|
5584
5602
|
tryDecryptNoteVerbose,
|
package/dist/index.mjs
CHANGED
|
@@ -3963,6 +3963,7 @@ function tryDecryptNoteVerbose(commitment, viewingSecretKey, spendingKey, ownOwn
|
|
|
3963
3963
|
blinding: plaintext.blinding,
|
|
3964
3964
|
spendingKey: effectiveSpendingKey,
|
|
3965
3965
|
circuitVersion: plaintext.circuitVersion,
|
|
3966
|
+
...Number.isSafeInteger(commitment.leafIndex) && commitment.leafIndex >= 0 && commitment.leafIndex < 2 ** 32 ? { leafIndex: commitment.leafIndex } : {},
|
|
3966
3967
|
spent: false,
|
|
3967
3968
|
spentAt: null,
|
|
3968
3969
|
commitment: recomputed,
|
|
@@ -4027,6 +4028,12 @@ function decodeNoteDisclosureKey(key) {
|
|
|
4027
4028
|
|
|
4028
4029
|
// src/shielded-pool/protocol/coinSelection.ts
|
|
4029
4030
|
var TRANSFER_TREE_DEPTH = 20;
|
|
4031
|
+
var LEAVES_PER_TREE = 1 << TRANSFER_TREE_DEPTH;
|
|
4032
|
+
function treeIdOf(note) {
|
|
4033
|
+
const idx = note.leafIndex;
|
|
4034
|
+
if (idx === void 0 || !Number.isSafeInteger(idx) || idx < 0 || idx >= 2 ** 32) return 0;
|
|
4035
|
+
return Math.floor(idx / LEAVES_PER_TREE);
|
|
4036
|
+
}
|
|
4030
4037
|
function selectNotes(notes, needed) {
|
|
4031
4038
|
const unspent = notes.filter((n) => !n.spent && n.value > 0n);
|
|
4032
4039
|
const sorted = [...unspent].sort((a, b) => a.value < b.value ? -1 : 1);
|
|
@@ -4036,11 +4043,20 @@ function selectNotes(notes, needed) {
|
|
|
4036
4043
|
for (let j = i + 1; j < sorted.length; j++) {
|
|
4037
4044
|
const a = sorted[i];
|
|
4038
4045
|
const b = sorted[j];
|
|
4039
|
-
if (a !== void 0 && b !== void 0 && a.circuitVersion === b.circuitVersion && a.value + b.value >= needed) {
|
|
4046
|
+
if (a !== void 0 && b !== void 0 && a.circuitVersion === b.circuitVersion && treeIdOf(a) === treeIdOf(b) && a.value + b.value >= needed) {
|
|
4040
4047
|
return [a, b];
|
|
4041
4048
|
}
|
|
4042
4049
|
}
|
|
4043
4050
|
}
|
|
4051
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
4052
|
+
for (let j = i + 1; j < sorted.length; j++) {
|
|
4053
|
+
const a = sorted[i];
|
|
4054
|
+
const b = sorted[j];
|
|
4055
|
+
if (a !== void 0 && b !== void 0 && a.circuitVersion === b.circuitVersion && a.value + b.value >= needed) {
|
|
4056
|
+
return { needsConsolidation: true };
|
|
4057
|
+
}
|
|
4058
|
+
}
|
|
4059
|
+
}
|
|
4044
4060
|
return null;
|
|
4045
4061
|
}
|
|
4046
4062
|
function buildDummyTransferInput(assetId) {
|
|
@@ -5464,6 +5480,7 @@ export {
|
|
|
5464
5480
|
toBase64,
|
|
5465
5481
|
toHex,
|
|
5466
5482
|
toTxResult,
|
|
5483
|
+
treeIdOf,
|
|
5467
5484
|
truncateMiddle,
|
|
5468
5485
|
tryDecryptNote,
|
|
5469
5486
|
tryDecryptNoteVerbose,
|