@chironbuilder/ootle-sdk 0.3.0 → 0.4.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 +29 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/indexerDecode.d.ts +7 -2
- package/dist/indexerDecode.d.ts.map +1 -1
- package/dist/indexerDecode.js +17 -7
- package/dist/ootleNetwork.d.ts +18 -1
- package/dist/ootleNetwork.d.ts.map +1 -1
- package/dist/ootleNetwork.js +66 -0
- package/dist/storage.d.ts +10 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +16 -0
- package/dist/verifyOwnershipProof.d.ts +45 -0
- package/dist/verifyOwnershipProof.d.ts.map +1 -0
- package/dist/verifyOwnershipProof.js +143 -0
- package/dist/wallet.d.ts +18 -2
- package/dist/wallet.d.ts.map +1 -1
- package/dist/wallet.js +110 -57
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,6 +62,25 @@ See `src/wallet.ts`'s doc comments for the full `OotleAccount` surface — `send
|
|
|
62
62
|
`shield`/`unshield`, `htlcFund`/`htlcClaim`/`htlcRefund`, `claimTestnetXtr`, `execute` (the general
|
|
63
63
|
instruction-builder escape hatch, with automatic missing-input discovery and lock-contention retry).
|
|
64
64
|
|
|
65
|
+
### Networks
|
|
66
|
+
|
|
67
|
+
`NetworkName` is `"mainnet" | "esmeralda" | "igor"`. Mainnet holds real value; `isTestnet(name)`
|
|
68
|
+
tells the two apart, and `claimTestnetXtr` refuses on mainnet. The same seed gives the same keys on
|
|
69
|
+
every network; only the address prefix differs (`otl_1…` on mainnet, `otl_esm_1…` on Esmeralda), and
|
|
70
|
+
every transaction carries its network byte, so one signed for a testnet can't be replayed on mainnet.
|
|
71
|
+
|
|
72
|
+
Indexers come from the SDK's own table (`indexerUrlFor`): mainnet is
|
|
73
|
+
`https://indexer-a.ootle.tari.com` (tari-ootle's default), Esmeralda keeps
|
|
74
|
+
`https://ootle-indexer-a.tari.com`, and Igor has none. Point a network elsewhere with
|
|
75
|
+
`setIndexerUrl(Network.MainNet, url)` before creating accounts.
|
|
76
|
+
|
|
77
|
+
Because the keys are the same, stored records are kept apart by network instead. An account's
|
|
78
|
+
shielded outputs, scan cursors and watermarks, pending shields, reservations and HTLC journal live
|
|
79
|
+
under `account.ledgerId`: `local:N` on a testnet (unchanged from earlier versions, so existing data
|
|
80
|
+
needs no migration) and `mainnet:local:N` on mainnet. Read them with `account.ledgerId`, never
|
|
81
|
+
`localAccountId(index)`. The substate version cache is split the same way, and
|
|
82
|
+
`recoverPendingShields(provider, network)` only reconciles that network's pending shields.
|
|
83
|
+
|
|
65
84
|
### Claiming a Minotari (L1) burn
|
|
66
85
|
|
|
67
86
|
A burn addressed to this account's public key (`getPublicKey()`) is claimed with `claimBurn`. Build
|
|
@@ -124,12 +143,21 @@ await account.refundFromJournal(fund.journalId);
|
|
|
124
143
|
`isHtlcClaimableByEpoch`.
|
|
125
144
|
- Claimed and refunded outputs are recorded in the shielded ledger, so they're spendable at once.
|
|
126
145
|
|
|
146
|
+
## Verifying ownership proofs
|
|
147
|
+
|
|
148
|
+
A site that receives `{ walletAddress, publicNonce, signature }` from
|
|
149
|
+
`tari_signWalletOwnershipChallenge` checks it with `verifyWalletOwnershipProof` (and a per-output
|
|
150
|
+
proof with `verifyOwnershipProof`), taking the key from the address it already had in mind. The
|
|
151
|
+
byte spec is in [docs/ownership-proof.md](docs/ownership-proof.md);
|
|
152
|
+
`src/fixtures/ownershipProof.vectors.json` holds fixed vectors produced with Tari's real signer
|
|
153
|
+
(test-only keys).
|
|
154
|
+
|
|
127
155
|
## What's in here, and what isn't
|
|
128
156
|
|
|
129
157
|
- **Account core** (`wallet.ts`): `OotleAccount`, balance/plan-resolution helpers, the transaction
|
|
130
158
|
auto-resolve retry loop.
|
|
131
159
|
- **Crypto/derivation**: `derivation.ts`, `domainHash.ts`, `componentAddress.ts`, `vault.ts`,
|
|
132
|
-
`ownershipProof.ts`, `confidential.ts`.
|
|
160
|
+
`ownershipProof.ts`, `verifyOwnershipProof.ts`, `confidential.ts`.
|
|
133
161
|
- **HTLC**: `htlc.ts` (condition trees), `htlcSafety.ts` (epoch rules, pre-claim verification,
|
|
134
162
|
per-output masks, outcome classification) + the journaled `OotleAccount` HTLC methods.
|
|
135
163
|
- **L1 burn claims**: `burnClaim.ts` (proof assembly) + `OotleAccount.claimBurn`.
|
package/dist/index.d.ts
CHANGED
|
@@ -12,13 +12,15 @@ export { accessRuleRequiringPublicKey, htlcConditions } from "./htlc.js";
|
|
|
12
12
|
export type { HtlcExpectations, HtlcFacts } from "./htlcSafety.js";
|
|
13
13
|
export { HtlcUnknownOutcomeError, HtlcVerificationError, conditionRootOf, describeHtlcConditions, epochsUntilRefund, findScriptRoot, isDefinitiveRejection, isHtlcClaimableByEpoch, isHtlcRefundable, verifyHtlcTerms, } from "./htlcSafety.js";
|
|
14
14
|
export type { NetworkName } from "./ootleNetwork.js";
|
|
15
|
-
export { toOotleNetwork } from "./ootleNetwork.js";
|
|
15
|
+
export { NETWORK_NAMES, indexerUrlFor, isNetworkName, isTestnet, networkNameFromByte, setIndexerUrl, toOotleNetwork } from "./ootleNetwork.js";
|
|
16
16
|
export { OWNERSHIP_PROOF_CHALLENGE_MAX_LENGTH, buildOwnershipProofMessage, buildWalletOwnershipMessage } from "./ownershipProof.js";
|
|
17
|
+
export type { OutputOwnershipProof, ProofNetwork, ProofVerdict, WalletOwnershipProof } from "./verifyOwnershipProof.js";
|
|
18
|
+
export { verifyOwnershipProof, verifySchnorrSignature, verifyWalletOwnershipProof } from "./verifyOwnershipProof.js";
|
|
17
19
|
export type { EncryptedVault } from "./vault.js";
|
|
18
20
|
export { decryptVault, encryptVault, fromHex, toHex } from "./vault.js";
|
|
19
21
|
export { withTimeout } from "./timeout.js";
|
|
20
22
|
export type { CommitmentReservation, HtlcJournalEntry, HtlcJournalStatus, KeyValueStore, PendingShield, PrivatePaymentScanResume, ShieldedOutputRecord } from "./storage.js";
|
|
21
|
-
export { addPendingShield, addShieldedOutput, clearUtxoScanPageCursor, configureOotleStorage, getKnownVersions, getPrivatePaymentScanCursor, getPrivatePaymentScanResume, getUtxoScanPageCursor, getUtxoScanWatermarks, listPendingShields, listShieldedOutputs, localAccountId, markShieldedOutputSpent, reviveShieldedOutput, removePendingShield, serialized, setKnownVersions, setPrivatePaymentScanCursor, setPrivatePaymentScanResume, setUtxoScanPageCursor, setUtxoScanWatermarks, wipeOotleState, CommitmentReservedError, RESERVATION_TTL_MS, listHtlcJournal, } from "./storage.js";
|
|
23
|
+
export { addPendingShield, addShieldedOutput, clearUtxoScanPageCursor, configureOotleStorage, getKnownVersions, getPrivatePaymentScanCursor, getPrivatePaymentScanResume, getUtxoScanPageCursor, getUtxoScanWatermarks, listPendingShields, listShieldedOutputs, isMainnetLedgerId, ledgerAccountId, localAccountId, markShieldedOutputSpent, reviveShieldedOutput, removePendingShield, serialized, setKnownVersions, setPrivatePaymentScanCursor, setPrivatePaymentScanResume, setUtxoScanPageCursor, setUtxoScanWatermarks, wipeOotleState, CommitmentReservedError, RESERVATION_TTL_MS, listHtlcJournal, } from "./storage.js";
|
|
22
24
|
export type { UtxosDeltaResult, UtxosPageResult, UtxoScanWatermark } from "./utxoScan.js";
|
|
23
25
|
export { scanUtxosDelta, scanUtxosPage } from "./utxoScan.js";
|
|
24
26
|
export { chromeStorageAdapter, inMemoryAdapter, localStorageAdapter } from "./adapters.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,YAAY,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEhF,OAAO,EACL,wBAAwB,EACxB,iCAAiC,EACjC,6BAA6B,EAC7B,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EAAE,sBA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,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,EACpB,4BAA4B,EAC5B,4BAA4B,EAC5B,cAAc,EACd,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,11 +7,12 @@ export { deriveAccountKeys } from "./derivation.js";
|
|
|
7
7
|
export { DomainSeparatedHasher, KEY_MANAGER_DOMAIN, KEY_MANAGER_DOMAIN_VERSION, keyManagerDomainHasher } from "./domainHash.js";
|
|
8
8
|
export { accessRuleRequiringPublicKey, htlcConditions } from "./htlc.js";
|
|
9
9
|
export { HtlcUnknownOutcomeError, HtlcVerificationError, conditionRootOf, describeHtlcConditions, epochsUntilRefund, findScriptRoot, isDefinitiveRejection, isHtlcClaimableByEpoch, isHtlcRefundable, verifyHtlcTerms, } from "./htlcSafety.js";
|
|
10
|
-
export { toOotleNetwork } from "./ootleNetwork.js";
|
|
10
|
+
export { NETWORK_NAMES, indexerUrlFor, isNetworkName, isTestnet, networkNameFromByte, setIndexerUrl, toOotleNetwork } from "./ootleNetwork.js";
|
|
11
11
|
export { OWNERSHIP_PROOF_CHALLENGE_MAX_LENGTH, buildOwnershipProofMessage, buildWalletOwnershipMessage } from "./ownershipProof.js";
|
|
12
|
+
export { verifyOwnershipProof, verifySchnorrSignature, verifyWalletOwnershipProof } from "./verifyOwnershipProof.js";
|
|
12
13
|
export { decryptVault, encryptVault, fromHex, toHex } from "./vault.js";
|
|
13
14
|
export { withTimeout } from "./timeout.js";
|
|
14
|
-
export { addPendingShield, addShieldedOutput, clearUtxoScanPageCursor, configureOotleStorage, getKnownVersions, getPrivatePaymentScanCursor, getPrivatePaymentScanResume, getUtxoScanPageCursor, getUtxoScanWatermarks, listPendingShields, listShieldedOutputs, localAccountId, markShieldedOutputSpent, reviveShieldedOutput, removePendingShield, serialized, setKnownVersions, setPrivatePaymentScanCursor, setPrivatePaymentScanResume, setUtxoScanPageCursor, setUtxoScanWatermarks, wipeOotleState, CommitmentReservedError, RESERVATION_TTL_MS, listHtlcJournal, } from "./storage.js";
|
|
15
|
+
export { addPendingShield, addShieldedOutput, clearUtxoScanPageCursor, configureOotleStorage, getKnownVersions, getPrivatePaymentScanCursor, getPrivatePaymentScanResume, getUtxoScanPageCursor, getUtxoScanWatermarks, listPendingShields, listShieldedOutputs, isMainnetLedgerId, ledgerAccountId, localAccountId, markShieldedOutputSpent, reviveShieldedOutput, removePendingShield, serialized, setKnownVersions, setPrivatePaymentScanCursor, setPrivatePaymentScanResume, setUtxoScanPageCursor, setUtxoScanWatermarks, wipeOotleState, CommitmentReservedError, RESERVATION_TTL_MS, listHtlcJournal, } from "./storage.js";
|
|
15
16
|
export { scanUtxosDelta, scanUtxosPage } from "./utxoScan.js";
|
|
16
17
|
export { chromeStorageAdapter, inMemoryAdapter, localStorageAdapter } from "./adapters.js";
|
|
17
18
|
export { OotleAccount, assertValidMinimumValuePromise, buildHtlcSpendStatement, extractMissingSubstateAddress, extractStaleLockVersion, forgetKnownVersions, pollTransactionResult, recoverPendingShields, FeeCommittedError, FeeBookkeepingError, resetKnownVersions, resolveInputsWithRetry, resolveSendPrivatelyPlan, resolveUnshieldPlan, selectPrivateFeeUtxo, selectShieldedUtxosForAmount, selectUnspentShieldedOutputs, substateExists, summarizePrivateHoldings, synthesizeShieldedOnlyBalances, } from "./wallet.js";
|
package/dist/indexerDecode.d.ts
CHANGED
|
@@ -8,13 +8,18 @@ export declare function utxoValueOf<T = any>(value: unknown): T;
|
|
|
8
8
|
/** `getSubstate` response with `state.up.substate` decoded. */
|
|
9
9
|
export declare function decodeSubstateResponse<T = any>(response: any): T;
|
|
10
10
|
export declare function getSubstateDecoded(provider: IndexerProvider, substateId: string, version?: number | null): Promise<any>;
|
|
11
|
-
/**
|
|
11
|
+
/** The most substates the indexer serves in one request. It refuses a larger one outright. */
|
|
12
|
+
export declare const MAX_SUBSTATES_PER_REQUEST = 20;
|
|
13
|
+
/**
|
|
14
|
+
* `fetchSubstates` with each entry given the pre-0.48 `{ version, substate }` shape. Asks in batches, because an account
|
|
15
|
+
* holding more than a batch's worth of tokens is ordinary: every campaign it claims from adds a receipt vault.
|
|
16
|
+
*/
|
|
12
17
|
export declare function fetchSubstatesDecoded(provider: IndexerProvider, ids: string[]): Promise<{
|
|
13
18
|
substates: Record<string, {
|
|
14
19
|
version: number;
|
|
15
20
|
substate: any;
|
|
16
21
|
} | undefined>;
|
|
17
|
-
}
|
|
22
|
+
} & Record<string, any>>;
|
|
18
23
|
/** Decodes `Finalized.execution_result` (and nested event blobs) in a transaction-result response. */
|
|
19
24
|
export declare function decodeTransactionResultResponse<T = any>(response: any): T;
|
|
20
25
|
/** An `ExecuteResult` with any CBOR-string events also decoded. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexerDecode.d.ts","sourceRoot":"","sources":["../src/indexerDecode.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,yFAAyF;AACzF,wBAAgB,eAAe,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,CAE1D;AAED,gGAAgG;AAChG,wBAAgB,eAAe,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,CAE1D;AAED,wBAAgB,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,CAElD;AAED,wBAAgB,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,CAEtD;AAED,+DAA+D;AAC/D,wBAAgB,sBAAsB,CAAC,CAAC,GAAG,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC,CAKhE;AAED,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,eAAe,EAAE,UAAU,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,sGAAsG;AACtG,wBAAgB,+BAA+B,CAAC,CAAC,GAAG,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC,CAUzE;AAED,mEAAmE;AACnE,wBAAgB,uBAAuB,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,CAOlE;AAED,wBAAsB,2BAA2B,CAAC,QAAQ,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAEhH"}
|
package/dist/indexerDecode.js
CHANGED
|
@@ -31,16 +31,26 @@ export function decodeSubstateResponse(response) {
|
|
|
31
31
|
export async function getSubstateDecoded(provider, substateId, version) {
|
|
32
32
|
return decodeSubstateResponse(await provider.getSubstate(substateId, version));
|
|
33
33
|
}
|
|
34
|
-
/**
|
|
34
|
+
/** The most substates the indexer serves in one request. It refuses a larger one outright. */
|
|
35
|
+
export const MAX_SUBSTATES_PER_REQUEST = 20;
|
|
36
|
+
/**
|
|
37
|
+
* `fetchSubstates` with each entry given the pre-0.48 `{ version, substate }` shape. Asks in batches, because an account
|
|
38
|
+
* holding more than a batch's worth of tokens is ordinary: every campaign it claims from adds a receipt vault.
|
|
39
|
+
*/
|
|
35
40
|
export async function fetchSubstatesDecoded(provider, ids) {
|
|
36
|
-
const
|
|
41
|
+
const batches = [];
|
|
42
|
+
for (let i = 0; i < ids.length; i += MAX_SUBSTATES_PER_REQUEST)
|
|
43
|
+
batches.push(ids.slice(i, i + MAX_SUBSTATES_PER_REQUEST));
|
|
44
|
+
const responses = (await Promise.all((batches.length ? batches : [[]]).map((batch) => provider.fetchSubstates(batch))));
|
|
37
45
|
const substates = {};
|
|
38
|
-
for (const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
for (const response of responses) {
|
|
47
|
+
for (const [id, entry] of Object.entries(response.substates ?? {})) {
|
|
48
|
+
if (!entry)
|
|
49
|
+
continue;
|
|
50
|
+
substates[id] = { ...entry, substate: substateValueOf(entry.value ?? entry.substate) };
|
|
51
|
+
}
|
|
42
52
|
}
|
|
43
|
-
return { ...
|
|
53
|
+
return { ...Object.assign({}, ...responses), substates };
|
|
44
54
|
}
|
|
45
55
|
/** Decodes `Finalized.execution_result` (and nested event blobs) in a transaction-result response. */
|
|
46
56
|
export function decodeTransactionResultResponse(response) {
|
package/dist/ootleNetwork.d.ts
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
import { Network } from "@tari-project/ootle";
|
|
2
|
-
|
|
2
|
+
/** The networks this SDK creates accounts on. `"mainnet"` holds real value; the other two are testnets. */
|
|
3
|
+
export type NetworkName = "mainnet" | "esmeralda" | "igor";
|
|
4
|
+
/** Every `NetworkName`, mainnet first. */
|
|
5
|
+
export declare const NETWORK_NAMES: readonly NetworkName[];
|
|
6
|
+
/** True for a network whose funds have no value (anything but mainnet). */
|
|
7
|
+
export declare function isTestnet(name: NetworkName): boolean;
|
|
3
8
|
export declare function toOotleNetwork(name: NetworkName): Network;
|
|
9
|
+
/** The `NetworkName` for an Ootle network byte (as carried by an `otl_` address), or `undefined`. */
|
|
10
|
+
export declare function networkNameFromByte(byte: number): NetworkName | undefined;
|
|
11
|
+
/** Accepts a `NetworkName` string and narrows it; anything else (an older stored value, a dApp's
|
|
12
|
+
* parameter) is refused rather than guessed at. */
|
|
13
|
+
export declare function isNetworkName(value: unknown): value is NetworkName;
|
|
14
|
+
/** The indexer this SDK uses for `network`: an override from `setIndexerUrl`, else the default.
|
|
15
|
+
* Throws for a network with neither. Never has a trailing slash. */
|
|
16
|
+
export declare function indexerUrlFor(network: Network): string;
|
|
17
|
+
/** Point `network` at another indexer (a self-hosted one, or a new public endpoint), or pass
|
|
18
|
+
* `null` to go back to the default. Accounts created afterwards use it; an account that has
|
|
19
|
+
* already connected keeps its connection. */
|
|
20
|
+
export declare function setIndexerUrl(network: Network, url: string | null): void;
|
|
4
21
|
//# sourceMappingURL=ootleNetwork.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ootleNetwork.d.ts","sourceRoot":"","sources":["../src/ootleNetwork.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"ootleNetwork.d.ts","sourceRoot":"","sources":["../src/ootleNetwork.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,2GAA2G;AAC3G,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,WAAW,GAAG,MAAM,CAAC;AAE3D,0CAA0C;AAC1C,eAAO,MAAM,aAAa,EAAE,SAAS,WAAW,EAAqC,CAAC;AAEtF,2EAA2E;AAC3E,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAEpD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAWzD;AAED,qGAAqG;AACrG,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAWzE;AAED;mDACmD;AACnD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE;AAiBD;oEACoE;AACpE,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAItD;AAED;;6CAE6C;AAC7C,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAaxE"}
|
package/dist/ootleNetwork.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { Network } from "@tari-project/ootle";
|
|
2
|
+
/** Every `NetworkName`, mainnet first. */
|
|
3
|
+
export const NETWORK_NAMES = ["mainnet", "esmeralda", "igor"];
|
|
4
|
+
/** True for a network whose funds have no value (anything but mainnet). */
|
|
5
|
+
export function isTestnet(name) {
|
|
6
|
+
return name !== "mainnet";
|
|
7
|
+
}
|
|
2
8
|
export function toOotleNetwork(name) {
|
|
3
9
|
switch (name) {
|
|
10
|
+
case "mainnet":
|
|
11
|
+
return Network.MainNet;
|
|
4
12
|
case "esmeralda":
|
|
5
13
|
return Network.Esmeralda;
|
|
6
14
|
case "igor":
|
|
@@ -9,3 +17,61 @@ export function toOotleNetwork(name) {
|
|
|
9
17
|
throw new Error(`Unknown network: ${name}`);
|
|
10
18
|
}
|
|
11
19
|
}
|
|
20
|
+
/** The `NetworkName` for an Ootle network byte (as carried by an `otl_` address), or `undefined`. */
|
|
21
|
+
export function networkNameFromByte(byte) {
|
|
22
|
+
switch (byte) {
|
|
23
|
+
case Network.MainNet:
|
|
24
|
+
return "mainnet";
|
|
25
|
+
case Network.Esmeralda:
|
|
26
|
+
return "esmeralda";
|
|
27
|
+
case Network.Igor:
|
|
28
|
+
return "igor";
|
|
29
|
+
default:
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** Accepts a `NetworkName` string and narrows it; anything else (an older stored value, a dApp's
|
|
34
|
+
* parameter) is refused rather than guessed at. */
|
|
35
|
+
export function isNetworkName(value) {
|
|
36
|
+
return typeof value === "string" && NETWORK_NAMES.includes(value);
|
|
37
|
+
}
|
|
38
|
+
// Indexer endpoints. `@tari-project/ootle`'s `defaultIndexerUrl` knows only LocalNet and Esmeralda
|
|
39
|
+
// and throws for mainnet, so the SDK keeps its own table.
|
|
40
|
+
// - MainNet: tari-ootle's own default (`crates/wallet/ootle-rs/src/helpers.rs`, v0.50.1); the wallet
|
|
41
|
+
// daemon preset lists indexer-b as its second.
|
|
42
|
+
// - Esmeralda: the URL `defaultIndexerUrl` has always returned, unchanged, so existing testnet
|
|
43
|
+
// accounts keep talking to the same indexer.
|
|
44
|
+
// - Igor: no public indexer; set one with `setIndexerUrl`.
|
|
45
|
+
const DEFAULT_INDEXER_URLS = {
|
|
46
|
+
[Network.MainNet]: "https://indexer-a.ootle.tari.com",
|
|
47
|
+
[Network.Esmeralda]: "https://ootle-indexer-a.tari.com",
|
|
48
|
+
[Network.LocalNet]: "http://localhost:12500",
|
|
49
|
+
};
|
|
50
|
+
const indexerOverrides = new Map();
|
|
51
|
+
/** The indexer this SDK uses for `network`: an override from `setIndexerUrl`, else the default.
|
|
52
|
+
* Throws for a network with neither. Never has a trailing slash. */
|
|
53
|
+
export function indexerUrlFor(network) {
|
|
54
|
+
const url = indexerOverrides.get(network) ?? DEFAULT_INDEXER_URLS[network];
|
|
55
|
+
if (!url)
|
|
56
|
+
throw new Error(`No indexer is configured for network ${Network[network] ?? network}. Set one with setIndexerUrl().`);
|
|
57
|
+
return url;
|
|
58
|
+
}
|
|
59
|
+
/** Point `network` at another indexer (a self-hosted one, or a new public endpoint), or pass
|
|
60
|
+
* `null` to go back to the default. Accounts created afterwards use it; an account that has
|
|
61
|
+
* already connected keeps its connection. */
|
|
62
|
+
export function setIndexerUrl(network, url) {
|
|
63
|
+
if (url === null) {
|
|
64
|
+
indexerOverrides.delete(network);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
let parsed;
|
|
68
|
+
try {
|
|
69
|
+
parsed = new URL(url);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
throw new Error(`Not a valid indexer URL: ${url}`);
|
|
73
|
+
}
|
|
74
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:")
|
|
75
|
+
throw new Error(`An indexer URL must be http(s): ${url}`);
|
|
76
|
+
indexerOverrides.set(network, url.replace(/\/+$/, ""));
|
|
77
|
+
}
|
package/dist/storage.d.ts
CHANGED
|
@@ -128,6 +128,16 @@ export interface PrivatePaymentScanResume {
|
|
|
128
128
|
pending: boolean;
|
|
129
129
|
}
|
|
130
130
|
export declare function localAccountId(index: number): string;
|
|
131
|
+
/**
|
|
132
|
+
* The id an account's records are kept under in this store: its shielded outputs, scan cursors and
|
|
133
|
+
* watermarks, pending shields, reservations and HTLC journal. One seed gives the same keys and the
|
|
134
|
+
* same `local:N` on every network, so without the network in the id a mainnet account would read
|
|
135
|
+
* and spend its testnet twin's records. Mainnet ids are prefixed; testnet ids stay `local:N`, as
|
|
136
|
+
* every earlier build wrote them, so existing testnet data needs no migration.
|
|
137
|
+
*/
|
|
138
|
+
export declare function ledgerAccountId(index: number, mainnet: boolean): string;
|
|
139
|
+
/** Whether a ledger id (see `ledgerAccountId`) belongs to a mainnet account. */
|
|
140
|
+
export declare function isMainnetLedgerId(accountId: string): boolean;
|
|
131
141
|
/** Runs a whole read-modify-write cycle to completion before the next one starts, so two
|
|
132
142
|
* concurrent callers (two tabs, a page request racing a popup request) can't interleave their
|
|
133
143
|
* read-modify-write on this key and silently clobber each other's write.
|
package/dist/storage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAC5C,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAID;0EAC0E;AAC1E,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAEhE;AAcD,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,6EAA6E;IAC7E,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,K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AAE,MAAM,EAAE;gBAArB,WAAW,EAAE,MAAM,EAAE;CAQlD;AAQD;4FAC4F;AAC5F,wBAAsB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAE1I;AAED,wBAAsB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAK5J;AAED;oDACoD;AACpD,wBAAsB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAE9G;AAED,wBAAsB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAKrH;AAED,wBAAsB,uBAAuB,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMvG;AAED;;mFAEmF;AACnF,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAIpD"}
|
package/dist/storage.js
CHANGED
|
@@ -37,6 +37,22 @@ const DEFAULTS = {
|
|
|
37
37
|
export function localAccountId(index) {
|
|
38
38
|
return `local:${index}`;
|
|
39
39
|
}
|
|
40
|
+
const MAINNET_LEDGER_PREFIX = "mainnet:";
|
|
41
|
+
/**
|
|
42
|
+
* The id an account's records are kept under in this store: its shielded outputs, scan cursors and
|
|
43
|
+
* watermarks, pending shields, reservations and HTLC journal. One seed gives the same keys and the
|
|
44
|
+
* same `local:N` on every network, so without the network in the id a mainnet account would read
|
|
45
|
+
* and spend its testnet twin's records. Mainnet ids are prefixed; testnet ids stay `local:N`, as
|
|
46
|
+
* every earlier build wrote them, so existing testnet data needs no migration.
|
|
47
|
+
*/
|
|
48
|
+
export function ledgerAccountId(index, mainnet) {
|
|
49
|
+
const id = localAccountId(index);
|
|
50
|
+
return mainnet ? `${MAINNET_LEDGER_PREFIX}${id}` : id;
|
|
51
|
+
}
|
|
52
|
+
/** Whether a ledger id (see `ledgerAccountId`) belongs to a mainnet account. */
|
|
53
|
+
export function isMainnetLedgerId(accountId) {
|
|
54
|
+
return accountId.startsWith(MAINNET_LEDGER_PREFIX);
|
|
55
|
+
}
|
|
40
56
|
async function read() {
|
|
41
57
|
const raw = await store().get(STORAGE_KEY);
|
|
42
58
|
return { ...DEFAULTS, ...raw };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** The network an address or output says it is on. Wider than `NetworkName` on purpose: a verifier
|
|
2
|
+
* checks proofs from any network an address can name, whether or not this SDK creates accounts
|
|
3
|
+
* there. */
|
|
4
|
+
export type ProofNetwork = "mainnet" | "esmeralda" | "igor";
|
|
5
|
+
/**
|
|
6
|
+
* Tari Ristretto Schnorr verification over an already-built message. Never throws: a malformed
|
|
7
|
+
* point, a non-canonical scalar or a wrong length is simply `false`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function verifySchnorrSignature(publicKey: Uint8Array, message: Uint8Array, publicNonce: Uint8Array, signature: Uint8Array): boolean;
|
|
10
|
+
export interface WalletOwnershipProof {
|
|
11
|
+
/** The `otl_…` address the proof is about: the verifier's own copy, never the prover's claim. */
|
|
12
|
+
walletAddress: string;
|
|
13
|
+
/** The exact challenge text the verifier issued. */
|
|
14
|
+
challenge: string;
|
|
15
|
+
/** Hex or raw bytes, as `tari_signWalletOwnershipChallenge` returned them. */
|
|
16
|
+
publicNonce: Uint8Array | string;
|
|
17
|
+
signature: Uint8Array | string;
|
|
18
|
+
}
|
|
19
|
+
export type ProofVerdict = {
|
|
20
|
+
valid: true;
|
|
21
|
+
network: ProofNetwork;
|
|
22
|
+
} | {
|
|
23
|
+
valid: false;
|
|
24
|
+
reason: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Checks a `tari_signWalletOwnershipChallenge` result: that `signature` is the account's owner key
|
|
28
|
+
* (decoded from `walletAddress`) signing `buildWalletOwnershipMessage(network, walletAddress,
|
|
29
|
+
* challenge)`, where `network` is the byte carried by the address itself.
|
|
30
|
+
*/
|
|
31
|
+
export declare function verifyWalletOwnershipProof({ walletAddress, challenge, publicNonce, signature }: WalletOwnershipProof): ProofVerdict;
|
|
32
|
+
export interface OutputOwnershipProof {
|
|
33
|
+
/** The one-time public key of the output being proved, as the verifier derived or read it. */
|
|
34
|
+
publicKey: Uint8Array | string;
|
|
35
|
+
/** The network byte the output lives on (`ParsedOotleAddress.network`, or `Network.*`). */
|
|
36
|
+
networkByte: number;
|
|
37
|
+
resourceAddress: string;
|
|
38
|
+
substateId: string;
|
|
39
|
+
challenge: string;
|
|
40
|
+
publicNonce: Uint8Array | string;
|
|
41
|
+
signature: Uint8Array | string;
|
|
42
|
+
}
|
|
43
|
+
/** Checks a `tari_signOwnershipChallenge` result against the output's one-time public key. */
|
|
44
|
+
export declare function verifyOwnershipProof({ publicKey, networkByte, resourceAddress, substateId, challenge, publicNonce, signature }: OutputOwnershipProof): ProofVerdict;
|
|
45
|
+
//# sourceMappingURL=verifyOwnershipProof.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verifyOwnershipProof.d.ts","sourceRoot":"","sources":["../src/verifyOwnershipProof.ts"],"names":[],"mappings":"AAyBA;;YAEY;AACZ,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,WAAW,GAAG,MAAM,CAAC;AA+B5D;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,GAAG,OAAO,CAqB1I;AAED,MAAM,WAAW,oBAAoB;IACnC,iGAAiG;IACjG,aAAa,EAAE,MAAM,CAAC;IACtB,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB,8EAA8E;IAC9E,WAAW,EAAE,UAAU,GAAG,MAAM,CAAC;IACjC,SAAS,EAAE,UAAU,GAAG,MAAM,CAAC;CAChC;AAED,MAAM,MAAM,YAAY,GAAG;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAErG;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,oBAAoB,GAAG,YAAY,CAwBnI;AAED,MAAM,WAAW,oBAAoB;IACnC,8FAA8F;IAC9F,SAAS,EAAE,UAAU,GAAG,MAAM,CAAC;IAC/B,2FAA2F;IAC3F,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,UAAU,GAAG,MAAM,CAAC;IACjC,SAAS,EAAE,UAAU,GAAG,MAAM,CAAC;CAChC;AAED,8FAA8F;AAC9F,wBAAgB,oBAAoB,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,oBAAoB,GAAG,YAAY,CAkBnK"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// Verifiers for the two ownership proofs (ownershipProof.ts), so a site that receives
|
|
2
|
+
// `{ walletAddress, publicNonce, signature }` from `tari_signWalletOwnershipChallenge` can check it
|
|
3
|
+
// without rebuilding the bytes by hand. Until now every integrator re-derived the message
|
|
4
|
+
// construction from the source; the byte spec is in docs/ownership-proof.md and the fixed vectors
|
|
5
|
+
// in fixtures/ownershipProof.vectors.json pin it.
|
|
6
|
+
//
|
|
7
|
+
// What a verifier must never do: trust a public key the prover reports about themselves. The wallet
|
|
8
|
+
// proof takes its key FROM the address (`parseOotleAddress`), the address being the thing the
|
|
9
|
+
// verifier already had in mind; the per-output proof takes the one-time public key the verifier
|
|
10
|
+
// derived or read from the chain. Both are passed in by the verifier, never by the prover.
|
|
11
|
+
//
|
|
12
|
+
// The Schnorr check mirrors tari-crypto's `SchnorrSignature::verify` (schnorr.rs):
|
|
13
|
+
// e = H("com.tari.schnorr_signature.v1.challenge", R, P, message) mod l
|
|
14
|
+
// valid iff s·G == R + e·P
|
|
15
|
+
// with H the length-prefixed domain-separated BLAKE2b-512 (domainHash.ts) and l the ristretto255
|
|
16
|
+
// group order. `s` must be canonical (0 < s < l): a non-canonical scalar is a malleable signature,
|
|
17
|
+
// which tari-crypto also refuses.
|
|
18
|
+
import { ristretto255 } from "@noble/curves/ed25519.js";
|
|
19
|
+
import { Network } from "@tari-project/ootle";
|
|
20
|
+
import { parseOotleAddress } from "@tari-project/ootle-wasm";
|
|
21
|
+
import { DomainSeparatedHasher } from "./domainHash.js";
|
|
22
|
+
import { OWNERSHIP_PROOF_CHALLENGE_MAX_LENGTH, buildOwnershipProofMessage, buildWalletOwnershipMessage } from "./ownershipProof.js";
|
|
23
|
+
const { Point } = ristretto255;
|
|
24
|
+
function proofNetworkFromByte(byte) {
|
|
25
|
+
switch (byte) {
|
|
26
|
+
case Network.MainNet:
|
|
27
|
+
return "mainnet";
|
|
28
|
+
case Network.Esmeralda:
|
|
29
|
+
return "esmeralda";
|
|
30
|
+
case Network.Igor:
|
|
31
|
+
return "igor";
|
|
32
|
+
default:
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const GROUP_ORDER = (1n << 252n) + 27742317777372353535851937790883648493n;
|
|
37
|
+
function scalarFromBytesLE(bytes) {
|
|
38
|
+
let n = 0n;
|
|
39
|
+
for (let i = bytes.length - 1; i >= 0; i--)
|
|
40
|
+
n = (n << 8n) | BigInt(bytes[i]);
|
|
41
|
+
return n;
|
|
42
|
+
}
|
|
43
|
+
function bytesOf(value) {
|
|
44
|
+
if (value instanceof Uint8Array)
|
|
45
|
+
return value;
|
|
46
|
+
if (typeof value !== "string" || value.length === 0 || value.length % 2 !== 0 || !/^[0-9a-fA-F]+$/.test(value))
|
|
47
|
+
return null;
|
|
48
|
+
const out = new Uint8Array(value.length / 2);
|
|
49
|
+
for (let i = 0; i < out.length; i++)
|
|
50
|
+
out[i] = parseInt(value.slice(2 * i, 2 * i + 2), 16);
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Tari Ristretto Schnorr verification over an already-built message. Never throws: a malformed
|
|
55
|
+
* point, a non-canonical scalar or a wrong length is simply `false`.
|
|
56
|
+
*/
|
|
57
|
+
export function verifySchnorrSignature(publicKey, message, publicNonce, signature) {
|
|
58
|
+
try {
|
|
59
|
+
if (publicKey.length !== 32 || publicNonce.length !== 32 || signature.length !== 32)
|
|
60
|
+
return false;
|
|
61
|
+
const s = scalarFromBytesLE(signature);
|
|
62
|
+
if (s === 0n || s >= GROUP_ORDER)
|
|
63
|
+
return false;
|
|
64
|
+
const P = Point.fromBytes(publicKey);
|
|
65
|
+
const R = Point.fromBytes(publicNonce);
|
|
66
|
+
if (P.equals(Point.ZERO))
|
|
67
|
+
return false;
|
|
68
|
+
const challenge = new DomainSeparatedHasher("com.tari.schnorr_signature", 1, "challenge", 64)
|
|
69
|
+
.chain(publicNonce)
|
|
70
|
+
.chain(publicKey)
|
|
71
|
+
.chain(message)
|
|
72
|
+
.finalize();
|
|
73
|
+
const e = scalarFromBytesLE(challenge) % GROUP_ORDER;
|
|
74
|
+
// noble's multiply() throws on a zero scalar. e = 0 is a 2^-252 event, but the right answer
|
|
75
|
+
// there is s·G == R, not the catch-all false below.
|
|
76
|
+
const eP = e === 0n ? Point.ZERO : P.multiply(e);
|
|
77
|
+
return Point.BASE.multiply(s).equals(R.add(eP));
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Checks a `tari_signWalletOwnershipChallenge` result: that `signature` is the account's owner key
|
|
85
|
+
* (decoded from `walletAddress`) signing `buildWalletOwnershipMessage(network, walletAddress,
|
|
86
|
+
* challenge)`, where `network` is the byte carried by the address itself.
|
|
87
|
+
*/
|
|
88
|
+
export function verifyWalletOwnershipProof({ walletAddress, challenge, publicNonce, signature }) {
|
|
89
|
+
if (typeof walletAddress !== "string" || walletAddress.length === 0)
|
|
90
|
+
return { valid: false, reason: "walletAddress must be a non-empty string." };
|
|
91
|
+
if (typeof challenge !== "string" || challenge.length === 0)
|
|
92
|
+
return { valid: false, reason: "challenge must be a non-empty string." };
|
|
93
|
+
// UTF-16 code units, the same count the signer applies (ownershipProof.ts), so verifier and signer
|
|
94
|
+
// agree on what is too long.
|
|
95
|
+
if (challenge.length > OWNERSHIP_PROOF_CHALLENGE_MAX_LENGTH) {
|
|
96
|
+
return { valid: false, reason: `challenge is longer than ${OWNERSHIP_PROOF_CHALLENGE_MAX_LENGTH} characters, which the wallet refuses to sign.` };
|
|
97
|
+
}
|
|
98
|
+
const address = walletAddress.trim();
|
|
99
|
+
let parsed;
|
|
100
|
+
try {
|
|
101
|
+
parsed = parseOotleAddress(address);
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return { valid: false, reason: "walletAddress is not a valid otl_ address." };
|
|
105
|
+
}
|
|
106
|
+
const network = proofNetworkFromByte(parsed.network);
|
|
107
|
+
if (!network)
|
|
108
|
+
return { valid: false, reason: `walletAddress is on an unsupported network (byte ${parsed.network}).` };
|
|
109
|
+
const R = bytesOf(publicNonce);
|
|
110
|
+
const s = bytesOf(signature);
|
|
111
|
+
if (!R || !s)
|
|
112
|
+
return { valid: false, reason: "publicNonce and signature must be 32-byte hex strings or byte arrays." };
|
|
113
|
+
const message = buildWalletOwnershipMessage(parsed.network, address, challenge);
|
|
114
|
+
return verifySchnorrSignature(parsed.owner_key, message, R, s)
|
|
115
|
+
? { valid: true, network }
|
|
116
|
+
: { valid: false, reason: "The signature does not match this wallet address and challenge." };
|
|
117
|
+
}
|
|
118
|
+
/** Checks a `tari_signOwnershipChallenge` result against the output's one-time public key. */
|
|
119
|
+
export function verifyOwnershipProof({ publicKey, networkByte, resourceAddress, substateId, challenge, publicNonce, signature }) {
|
|
120
|
+
if (typeof challenge !== "string" || challenge.length === 0)
|
|
121
|
+
return { valid: false, reason: "challenge must be a non-empty string." };
|
|
122
|
+
if (challenge.length > OWNERSHIP_PROOF_CHALLENGE_MAX_LENGTH) {
|
|
123
|
+
return { valid: false, reason: `challenge is longer than ${OWNERSHIP_PROOF_CHALLENGE_MAX_LENGTH} characters, which the wallet refuses to sign.` };
|
|
124
|
+
}
|
|
125
|
+
if (typeof resourceAddress !== "string" || resourceAddress.length === 0)
|
|
126
|
+
return { valid: false, reason: "resourceAddress must be a non-empty string." };
|
|
127
|
+
if (typeof substateId !== "string" || substateId.length === 0)
|
|
128
|
+
return { valid: false, reason: "substateId must be a non-empty string." };
|
|
129
|
+
if (!Number.isInteger(networkByte))
|
|
130
|
+
return { valid: false, reason: "networkByte must be an integer." };
|
|
131
|
+
const network = proofNetworkFromByte(networkByte);
|
|
132
|
+
if (!network)
|
|
133
|
+
return { valid: false, reason: `unsupported network byte ${networkByte}.` };
|
|
134
|
+
const P = bytesOf(publicKey);
|
|
135
|
+
const R = bytesOf(publicNonce);
|
|
136
|
+
const s = bytesOf(signature);
|
|
137
|
+
if (!P || !R || !s)
|
|
138
|
+
return { valid: false, reason: "publicKey, publicNonce and signature must be 32-byte hex strings or byte arrays." };
|
|
139
|
+
const message = buildOwnershipProofMessage(networkByte, resourceAddress, substateId, challenge);
|
|
140
|
+
return verifySchnorrSignature(P, message, R, s)
|
|
141
|
+
? { valid: true, network }
|
|
142
|
+
: { valid: false, reason: "The signature does not match this output's key and challenge." };
|
|
143
|
+
}
|
package/dist/wallet.d.ts
CHANGED
|
@@ -171,6 +171,14 @@ export declare class OotleAccount implements WalletAccountApi {
|
|
|
171
171
|
private provider;
|
|
172
172
|
private readonly ownerSecret;
|
|
173
173
|
private constructor();
|
|
174
|
+
/**
|
|
175
|
+
* The id this account's records live under in the SDK store (see `ledgerAccountId`): `local:N`
|
|
176
|
+
* on a testnet, `mainnet:local:N` on mainnet, so the same seed's accounts never share shielded
|
|
177
|
+
* outputs, scan state or journals across networks. Read at call time, so a host that re-points
|
|
178
|
+
* `index` at its own ledger slot (an imported seed) is honoured. Use this, not `localAccountId`,
|
|
179
|
+
* whenever reading this account's records directly.
|
|
180
|
+
*/
|
|
181
|
+
get ledgerId(): string;
|
|
174
182
|
/** `entropy` is the 16-byte CipherSeed entropy (see cipherSeed.ts), not a raw 32-byte seed. */
|
|
175
183
|
static fromSeed(entropy: Uint8Array, index: number, networkName: NetworkName): OotleAccount;
|
|
176
184
|
getProvider(): Promise<IndexerProvider>;
|
|
@@ -181,6 +189,14 @@ export declare class OotleAccount implements WalletAccountApi {
|
|
|
181
189
|
* address", it is NOT the on-chain account component address. See `getComponentAddress()`.
|
|
182
190
|
*/
|
|
183
191
|
getWalletAddress(): Promise<string>;
|
|
192
|
+
/**
|
|
193
|
+
* Refuses an `otl_` address that names a different network from this account's. The component
|
|
194
|
+
* address is derived from the key alone, so a testnet address used on mainnet would still pay its
|
|
195
|
+
* owner's mainnet account -- but a mismatch nearly always means the sender has the wrong network
|
|
196
|
+
* or the wrong address in hand, and on mainnet that costs real money. Throws on an address that
|
|
197
|
+
* doesn't parse, too.
|
|
198
|
+
*/
|
|
199
|
+
private assertSameNetwork;
|
|
184
200
|
/**
|
|
185
201
|
* This account's owner public key, synchronously. Named as the receiver of every revealed
|
|
186
202
|
* stealth output this account's `StealthTransfer`s create (tari-ootle#2645): the engine only
|
|
@@ -1207,7 +1223,7 @@ export declare function resolveSendPrivatelyPlan(records: ShieldedOutputRecord[]
|
|
|
1207
1223
|
* every pending shield, whichever local account they belong to — this is a read-only connection,
|
|
1208
1224
|
* not account/signing-specific.
|
|
1209
1225
|
*/
|
|
1210
|
-
export declare function recoverPendingShields(provider: IndexerProvider): Promise<void>;
|
|
1226
|
+
export declare function recoverPendingShields(provider: IndexerProvider, network?: Network): Promise<void>;
|
|
1211
1227
|
/**
|
|
1212
1228
|
* The fee named by an `InsufficientFeesPaid` rejection, if any. The engine words it three ways:
|
|
1213
1229
|
* "Required fees N but M paid", "Committing requires N but M paid" and
|
|
@@ -1240,7 +1256,7 @@ export declare function dedupeInputs<T extends SubstateRequirement>(inputs: read
|
|
|
1240
1256
|
* remembered one is unusable. Keeping it would make `applyKnownVersions` reassert it over every
|
|
1241
1257
|
* future resolve, turning one bad write into a permanently stuck wallet.
|
|
1242
1258
|
*/
|
|
1243
|
-
export declare function forgetKnownVersions(substateIds: string[]): Promise<void>;
|
|
1259
|
+
export declare function forgetKnownVersions(substateIds: string[], network?: Network): Promise<void>;
|
|
1244
1260
|
/** Drops the in-memory known-versions cache. Call this on wallet reset so a freshly-created wallet
|
|
1245
1261
|
* can't inherit the previous wallet's cached version numbers — the persisted side of that wipe is
|
|
1246
1262
|
* the caller's own responsibility (a serialized clear of whatever `KeyValueStore` backs `storage.ts`). */
|
package/dist/wallet.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,OAAO,EAUP,iBAAiB,EAMjB,gBAAgB,IAAI,wBAAwB,EAc7C,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EACV,aAAa,EACb,mCAAmC,EACnC,WAAW,EAIX,mBAAmB,EACnB,aAAa,EACd,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE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,IAAI,IAAI,CAEzC;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,eAAe,EACzB,aAAa,EAAE,MAAM,EACrB,SAAS,SAAS,GACjB,OAAO,CAAC,mCAAmC,CAAC,CAkD9C;AAmBD,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,eAAe,EACzB,YAAY,EAAE,mBAAmB,EAAE,EACnC,OAAO,SAAI,EACX,YAAY,SAAM,GACjB,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAUhC;AAED;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAAC,QAAQ,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQpG;AAmBD,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM5E;AAOD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAGvG;AAoDD;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,iBAAiB,EACzB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,OAAO,EACjB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC,CAoB/D"}
|
package/dist/wallet.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Mask, OotleWallet, StealthInput, StealthInputsStatement, StealthOutputsStatement, StealthTransfer, StealthTransferStatement, TARI_RESOURCE_ADDRESS, TransactionBuilder, WalletStealthAuthorizer, WasmStealthCrypto, XTR_FAUCET_CLAIM_RESOURCE_ADDRESS, XTR_FAUCET_COMPONENT_ADDRESS, XTR_FAUCET_VAULT_ADDRESS, amountLiteral, createOutput, decryptOwnedUtxo as upstreamDecryptOwnedUtxo, decryptInputData as upstreamDecryptInputData,
|
|
1
|
+
import { Mask, Network, OotleWallet, StealthInput, StealthInputsStatement, StealthOutputsStatement, StealthTransfer, StealthTransferStatement, TARI_RESOURCE_ADDRESS, TransactionBuilder, WalletStealthAuthorizer, WasmStealthCrypto, XTR_FAUCET_CLAIM_RESOURCE_ADDRESS, XTR_FAUCET_COMPONENT_ADDRESS, XTR_FAUCET_VAULT_ADDRESS, amountLiteral, createOutput, decryptOwnedUtxo as upstreamDecryptOwnedUtxo, decryptInputData as upstreamDecryptInputData, getVaultIdsForAccount, resolveMaxEpoch, resolveTransaction, resourceAddressLiteral, generateSealKeypair, sealTransaction, sendTransaction, serializeUnsignedTx, signTransaction, stealthUtxoSubstateId, submitTransaction, } from "@tari-project/ootle";
|
|
2
2
|
import { IndexerProvider } from "@tari-project/ootle-indexer";
|
|
3
3
|
import { SecretKeyWallet } from "@tari-project/ootle-secret-key-wallet";
|
|
4
4
|
import { buildScriptPathWitness, buildStealthTransferStatement, createStealthOutputWitness, parseOotleAddress, publicKeyFromSecretKey, stealthDhSecret, validateStealthTransfer, } from "@tari-project/ootle-wasm";
|
|
@@ -18,8 +18,8 @@ import { deriveAccountKeys } from "./derivation.js";
|
|
|
18
18
|
import { htlcConditions } from "./htlc.js";
|
|
19
19
|
import { HtlcUnknownOutcomeError, HtlcVerificationError, decryptOwnStatementOutput, describeHtlcConditions, findScriptRoot, isDefinitiveRejection, isHtlcRefundable, newOperationId, sha256Hex, statementInputCommitment, statementOutputCommitment, subtractScalars, verifyHtlcTerms, } from "./htlcSafety.js";
|
|
20
20
|
import { buildOwnershipProofMessage, buildWalletOwnershipMessage } from "./ownershipProof.js";
|
|
21
|
-
import { toOotleNetwork } from "./ootleNetwork.js";
|
|
22
|
-
import { addPendingShield, addShieldedOutput, clearUtxoScanPageCursor, getHtlcJournalEntry, getKnownVersions, getPrivatePaymentScanCursor, getPrivatePaymentScanResume, getUtxoScanPageCursor, getUtxoScanWatermarks, listHtlcJournal, listPendingShields, listReservedCommitments, listShieldedOutputs,
|
|
21
|
+
import { indexerUrlFor, networkNameFromByte, toOotleNetwork } from "./ootleNetwork.js";
|
|
22
|
+
import { addPendingShield, addShieldedOutput, clearUtxoScanPageCursor, getHtlcJournalEntry, getKnownVersions, getPrivatePaymentScanCursor, getPrivatePaymentScanResume, getUtxoScanPageCursor, getUtxoScanWatermarks, listHtlcJournal, listPendingShields, listReservedCommitments, listShieldedOutputs, isMainnetLedgerId, ledgerAccountId, markShieldedOutputSpent, reviveShieldedOutput, putHtlcJournalEntry, releaseReservations, removePendingShield, reserveCommitments, setKnownVersions, setPrivatePaymentScanCursor, setPrivatePaymentScanResume, setUtxoScanPageCursor, setUtxoScanWatermarks, updateHtlcJournalEntry, CommitmentReservedError, } from "./storage.js";
|
|
23
23
|
import { withTimeout } from "./timeout.js";
|
|
24
24
|
import { scanUtxosDelta, scanUtxosPage } from "./utxoScan.js";
|
|
25
25
|
import { fromHex, toHex } from "./vault.js";
|
|
@@ -187,6 +187,16 @@ export class OotleAccount {
|
|
|
187
187
|
this.signer = signer;
|
|
188
188
|
this.ownerSecret = ownerSecret;
|
|
189
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* The id this account's records live under in the SDK store (see `ledgerAccountId`): `local:N`
|
|
192
|
+
* on a testnet, `mainnet:local:N` on mainnet, so the same seed's accounts never share shielded
|
|
193
|
+
* outputs, scan state or journals across networks. Read at call time, so a host that re-points
|
|
194
|
+
* `index` at its own ledger slot (an imported seed) is honoured. Use this, not `localAccountId`,
|
|
195
|
+
* whenever reading this account's records directly.
|
|
196
|
+
*/
|
|
197
|
+
get ledgerId() {
|
|
198
|
+
return ledgerAccountId(this.index, this.network === Network.MainNet);
|
|
199
|
+
}
|
|
190
200
|
/** `entropy` is the 16-byte CipherSeed entropy (see cipherSeed.ts), not a raw 32-byte seed. */
|
|
191
201
|
static fromSeed(entropy, index, networkName) {
|
|
192
202
|
const network = toOotleNetwork(networkName);
|
|
@@ -200,7 +210,7 @@ export class OotleAccount {
|
|
|
200
210
|
// problem (unlike execute()'s later errors, which are meaningful on-chain rejections this
|
|
201
211
|
// class deliberately leaves unwrapped) — mirrors the same "unreachable" framing
|
|
202
212
|
// DaemonAccount.connectClient() uses for the equivalent first-contact step.
|
|
203
|
-
const url =
|
|
213
|
+
const url = indexerUrlFor(this.network);
|
|
204
214
|
try {
|
|
205
215
|
this.provider = await withTimeout(IndexerProvider.connect({ url, network: this.network }), 15_000, "connecting to the Tari indexer");
|
|
206
216
|
}
|
|
@@ -220,6 +230,27 @@ export class OotleAccount {
|
|
|
220
230
|
async getWalletAddress() {
|
|
221
231
|
return this.signer.getAddress();
|
|
222
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Refuses an `otl_` address that names a different network from this account's. The component
|
|
235
|
+
* address is derived from the key alone, so a testnet address used on mainnet would still pay its
|
|
236
|
+
* owner's mainnet account -- but a mismatch nearly always means the sender has the wrong network
|
|
237
|
+
* or the wrong address in hand, and on mainnet that costs real money. Throws on an address that
|
|
238
|
+
* doesn't parse, too.
|
|
239
|
+
*/
|
|
240
|
+
assertSameNetwork(address, role) {
|
|
241
|
+
let byte;
|
|
242
|
+
try {
|
|
243
|
+
byte = parseOotleAddress(address.trim()).network;
|
|
244
|
+
}
|
|
245
|
+
catch {
|
|
246
|
+
throw new Error(`${role} address is not a valid otl_ address.`);
|
|
247
|
+
}
|
|
248
|
+
if (byte !== this.network) {
|
|
249
|
+
const theirs = networkNameFromByte(byte) ?? `network ${byte}`;
|
|
250
|
+
const ours = networkNameFromByte(this.network) ?? `network ${this.network}`;
|
|
251
|
+
throw new Error(`${role} address is for ${theirs}, but this account is on ${ours}. Check you have the right address and network.`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
223
254
|
/**
|
|
224
255
|
* This account's owner public key, synchronously. Named as the receiver of every revealed
|
|
225
256
|
* stealth output this account's `StealthTransfer`s create (tari-ootle#2645): the engine only
|
|
@@ -291,7 +322,7 @@ export class OotleAccount {
|
|
|
291
322
|
// live, the next balance read counts it again. The vault lookup above already proved the
|
|
292
323
|
// indexer is reachable in this same call, which is what makes a per-id failure here meaningful
|
|
293
324
|
// rather than just noise.
|
|
294
|
-
const unspentRecords = (await listShieldedOutputs(
|
|
325
|
+
const unspentRecords = (await listShieldedOutputs(this.ledgerId)).filter((r) => !r.spent);
|
|
295
326
|
const liveness = await Promise.all(unspentRecords.map(async (record) => {
|
|
296
327
|
try {
|
|
297
328
|
await withTimeout(getSubstateDecoded(provider, stealthUtxoSubstateId(record.resourceAddress, fromHex(record.commitment))), 15_000, "checking a shielded output");
|
|
@@ -408,11 +439,11 @@ export class OotleAccount {
|
|
|
408
439
|
// tokens) — hit exactly this exhausting 20 on a real 2-hop swap.
|
|
409
440
|
const maxRetries = opts.maxRetries ?? 30;
|
|
410
441
|
const seenAddresses = new Set();
|
|
411
|
-
let inputs = await applyKnownVersions(opts.inputs ? [...opts.inputs] : []);
|
|
442
|
+
let inputs = await applyKnownVersions(opts.inputs ? [...opts.inputs] : [], this.network);
|
|
412
443
|
// Built once, outside the retry loop, like `maxEpoch` above: the fee stealth proof doesn't
|
|
413
444
|
// depend on which main-instruction substates a given attempt discovers, so redoing the
|
|
414
445
|
// indexer round trip + proof generation on every retry would buy nothing.
|
|
415
|
-
const accountId =
|
|
446
|
+
const accountId = this.ledgerId;
|
|
416
447
|
const privateFee = await this.resolvePrivateFee(feeType, maxFee);
|
|
417
448
|
for (let attempt = 0;; attempt++) {
|
|
418
449
|
const builder = TransactionBuilder.new(this.network, maxEpoch).withInstructions(instructions);
|
|
@@ -433,7 +464,7 @@ export class OotleAccount {
|
|
|
433
464
|
if (opts.dryRun)
|
|
434
465
|
return await withTimeout(this.submitDryRun(provider, unsignedTx, extraSigners), 30_000, "submitting the transaction");
|
|
435
466
|
const result = await withTimeout(this.submitReal(provider, unsignedTx, extraSigners), 60_000, "submitting the transaction");
|
|
436
|
-
await recordKnownVersions(result);
|
|
467
|
+
await recordKnownVersions(result, this.network);
|
|
437
468
|
if (privateFee && feeType.kind === "private") {
|
|
438
469
|
await this.recordPrivateFeeSpend(accountId, feeType.feeResourceAddress, privateFee, String(result.transaction_id));
|
|
439
470
|
}
|
|
@@ -475,7 +506,7 @@ export class OotleAccount {
|
|
|
475
506
|
// `forgetKnownVersions`'s doc comment) -- the local N+1 computed below is correct for
|
|
476
507
|
// *this* attempt, but leaving the stale entry in place would win out again on some
|
|
477
508
|
// later, unrelated transaction that resolves this same substate from scratch.
|
|
478
|
-
await forgetKnownVersions([staleVersion.substateId]);
|
|
509
|
+
await forgetKnownVersions([staleVersion.substateId], this.network);
|
|
479
510
|
inputs = inputs.map((input) => input.substate_id === staleVersion.substateId ? { ...input, version: staleVersion.version + 1 } : input);
|
|
480
511
|
continue;
|
|
481
512
|
}
|
|
@@ -485,7 +516,7 @@ export class OotleAccount {
|
|
|
485
516
|
// overwrites the freshly resolved (correct) version with the stale one and the next
|
|
486
517
|
// attempt fails identically. Persisted, so one bad write wedges every later transaction
|
|
487
518
|
// across reloads. Forget those entries and trust the chain.
|
|
488
|
-
await forgetKnownVersions(inputs.map((i) => i.substate_id));
|
|
519
|
+
await forgetKnownVersions(inputs.map((i) => i.substate_id), this.network);
|
|
489
520
|
inputs = resolved;
|
|
490
521
|
continue;
|
|
491
522
|
}
|
|
@@ -511,7 +542,7 @@ export class OotleAccount {
|
|
|
511
542
|
`time it receives funds, so a brand-new account cannot be paid until it has been ` +
|
|
512
543
|
`funded once. (${resolveError instanceof Error ? resolveError.message.slice(0, 120) : String(resolveError)})`);
|
|
513
544
|
}
|
|
514
|
-
inputs = await applyKnownVersions([...inputs, resolved]);
|
|
545
|
+
inputs = await applyKnownVersions([...inputs, resolved], this.network);
|
|
515
546
|
}
|
|
516
547
|
}
|
|
517
548
|
}
|
|
@@ -538,7 +569,7 @@ export class OotleAccount {
|
|
|
538
569
|
resolved.inputs = dedupeInputs(resolved.inputs);
|
|
539
570
|
const signed = await signTransaction([this.signer, ...extraSigners], resolved);
|
|
540
571
|
const envelope = sealTransaction(signed);
|
|
541
|
-
const res = await fetch(`${
|
|
572
|
+
const res = await fetch(`${indexerUrlFor(this.network)}/transactions/dry-run`, {
|
|
542
573
|
method: "POST",
|
|
543
574
|
headers: { "Content-Type": "application/json" },
|
|
544
575
|
// `TransactionEnvelope` (ootle-ts-bindings) is just `string` — the request body is the
|
|
@@ -648,6 +679,8 @@ export class OotleAccount {
|
|
|
648
679
|
throw new Error(`send: amount must be greater than zero, got ${amount}`);
|
|
649
680
|
const account = await this.getComponentAddress();
|
|
650
681
|
const isWalletAddress = recipientAddress.startsWith("otl");
|
|
682
|
+
if (isWalletAddress)
|
|
683
|
+
this.assertSameNetwork(recipientAddress, "The recipient");
|
|
651
684
|
const recipient = isWalletAddress ? componentAddressFromWalletAddress(recipientAddress) : recipientAddress;
|
|
652
685
|
const instructions = [];
|
|
653
686
|
if (isWalletAddress) {
|
|
@@ -763,6 +796,8 @@ export class OotleAccount {
|
|
|
763
796
|
* of burning the whole retry budget re-observing the same stale state.
|
|
764
797
|
*/
|
|
765
798
|
async claimTestnetXtr(maxFee = 5000n, retries = 10, retryDelayMs = 300) {
|
|
799
|
+
if (this.network === Network.MainNet)
|
|
800
|
+
throw new Error("There is no faucet on mainnet.");
|
|
766
801
|
const provider = await this.getProvider();
|
|
767
802
|
const publicKeyHex = bytesToHex(await this.getPublicKey());
|
|
768
803
|
const account = await this.getComponentAddress();
|
|
@@ -786,7 +821,7 @@ export class OotleAccount {
|
|
|
786
821
|
// This is typically the first transaction for a brand-new account — recording its
|
|
787
822
|
// resulting versions (the newly-created fee vault included) closes the exact gap that
|
|
788
823
|
// otherwise bites the *next* transaction (see `applyKnownVersions`'s doc comment).
|
|
789
|
-
await recordKnownVersions(result);
|
|
824
|
+
await recordKnownVersions(result, this.network);
|
|
790
825
|
return result;
|
|
791
826
|
}
|
|
792
827
|
catch (e) {
|
|
@@ -850,7 +885,7 @@ export class OotleAccount {
|
|
|
850
885
|
*/
|
|
851
886
|
async shield(resourceAddress, amount, maxFee = 50000n, memo, minimumValuePromise = 0n, feeType = { kind: "transparent" }) {
|
|
852
887
|
assertValidMinimumValuePromise(minimumValuePromise, amount);
|
|
853
|
-
const accountId =
|
|
888
|
+
const accountId = this.ledgerId;
|
|
854
889
|
const provider = await this.getProvider();
|
|
855
890
|
const account = await this.getComponentAddress();
|
|
856
891
|
// Output.destination decodes as a bech32m wallet address (owner_key + view_key), NOT the
|
|
@@ -881,7 +916,7 @@ export class OotleAccount {
|
|
|
881
916
|
let keepPending = false;
|
|
882
917
|
try {
|
|
883
918
|
const response = await this.pollRecordingFee(accountId, feeType, privateFee, transactionId, () => withTimeout(pollTransactionResult(provider, transactionId), 60_000, "submitting the shield transaction"));
|
|
884
|
-
await recordKnownVersions(response);
|
|
919
|
+
await recordKnownVersions(response, this.network);
|
|
885
920
|
await recordKnownShieldedOutput(accountId, resourceAddress, ownCommitment, amount, transactionId, memo);
|
|
886
921
|
if (privateFee && feeType.kind === "private") {
|
|
887
922
|
await this.recordPrivateFeeSpend(accountId, feeType.feeResourceAddress, privateFee, transactionId);
|
|
@@ -996,7 +1031,7 @@ export class OotleAccount {
|
|
|
996
1031
|
* writes.
|
|
997
1032
|
*/
|
|
998
1033
|
async unshield(resourceAddress, revealedOutAmount, maxFee = 100000n, memo, feeType = { kind: "transparent" }) {
|
|
999
|
-
const accountId =
|
|
1034
|
+
const accountId = this.ledgerId;
|
|
1000
1035
|
const opId = newOperationId("unshield");
|
|
1001
1036
|
const unavailable = await this.unavailableCommitments(accountId, opId);
|
|
1002
1037
|
const records = await this.filterReadableShieldedOutputs((await listShieldedOutputs(accountId)).filter((r) => !unavailable.has(r.commitment)), resourceAddress, revealedOutAmount);
|
|
@@ -1052,7 +1087,7 @@ export class OotleAccount {
|
|
|
1052
1087
|
let keepPending = false;
|
|
1053
1088
|
try {
|
|
1054
1089
|
const response = await this.pollRecordingFee(accountId, feeType, privateFee, transactionId, () => withTimeout(pollTransactionResult(provider, transactionId), 60_000, "submitting the unshield transaction"));
|
|
1055
|
-
await recordKnownVersions(response);
|
|
1090
|
+
await recordKnownVersions(response, this.network);
|
|
1056
1091
|
await recordKnownShieldedOutput(accountId, resourceAddress, ownCommitment, remainder, transactionId, memo);
|
|
1057
1092
|
for (const commitment of commitments) {
|
|
1058
1093
|
await markShieldedOutputSpent(accountId, commitment);
|
|
@@ -1108,10 +1143,10 @@ export class OotleAccount {
|
|
|
1108
1143
|
const builder = await this.buildWithdrawStealthAndExecute(provider, account, resourceAddress, amount, workspaceVarName, followUpInstructions, relatedComponents);
|
|
1109
1144
|
const viewSecret = await this.signer.getViewSecret();
|
|
1110
1145
|
const { transactionId, privateFee } = await this.prepareSignSubmit(builder, provider, account, maxFee, feeType, { viewSecret });
|
|
1111
|
-
const response = await this.pollRecordingFee(
|
|
1112
|
-
await recordKnownVersions(response);
|
|
1146
|
+
const response = await this.pollRecordingFee(this.ledgerId, feeType, privateFee, transactionId, () => withTimeout(pollTransactionResult(provider, transactionId), 60_000, "submitting the transaction"));
|
|
1147
|
+
await recordKnownVersions(response, this.network);
|
|
1113
1148
|
if (privateFee && feeType.kind === "private") {
|
|
1114
|
-
await this.recordPrivateFeeSpend(
|
|
1149
|
+
await this.recordPrivateFeeSpend(this.ledgerId, feeType.feeResourceAddress, privateFee, transactionId);
|
|
1115
1150
|
}
|
|
1116
1151
|
return { transactionId };
|
|
1117
1152
|
}
|
|
@@ -1277,10 +1312,10 @@ export class OotleAccount {
|
|
|
1277
1312
|
const authorized = await WalletStealthAuthorizer.fromSpec(wallet, spec, { viewSecret, crypto: new WasmStealthCrypto(this.network) }).prepare(provider);
|
|
1278
1313
|
const envelope = privateFee ? await this.sealWithPrivateFee(authorized, privateFee.feeSigner) : await authorized.seal();
|
|
1279
1314
|
const transactionId = await submitTransaction(provider, envelope);
|
|
1280
|
-
const response = await this.pollRecordingFee(
|
|
1281
|
-
await recordKnownVersions(response);
|
|
1315
|
+
const response = await this.pollRecordingFee(this.ledgerId, feeType, privateFee, transactionId, () => withTimeout(pollTransactionResult(provider, transactionId), 60_000, "submitting the redemption transaction"));
|
|
1316
|
+
await recordKnownVersions(response, this.network);
|
|
1282
1317
|
if (privateFee && feeType.kind === "private") {
|
|
1283
|
-
await this.recordPrivateFeeSpend(
|
|
1318
|
+
await this.recordPrivateFeeSpend(this.ledgerId, feeType.feeResourceAddress, privateFee, transactionId);
|
|
1284
1319
|
}
|
|
1285
1320
|
return { transactionId };
|
|
1286
1321
|
}
|
|
@@ -1484,7 +1519,7 @@ export class OotleAccount {
|
|
|
1484
1519
|
reservationHolder) {
|
|
1485
1520
|
if (feeType.kind !== "private")
|
|
1486
1521
|
return null;
|
|
1487
|
-
const accountId =
|
|
1522
|
+
const accountId = this.ledgerId;
|
|
1488
1523
|
const records = await listShieldedOutputs(accountId);
|
|
1489
1524
|
for (const unavailable of await this.unavailableCommitments(accountId, reservationHolder))
|
|
1490
1525
|
exclude = [...exclude, unavailable];
|
|
@@ -1581,7 +1616,7 @@ export class OotleAccount {
|
|
|
1581
1616
|
* stealth funds is never refunded.
|
|
1582
1617
|
*/
|
|
1583
1618
|
async sendPrivatelyPayingFeeFromTransfer(records, resourceAddress, recipientWalletAddress, amount, maxFee, memo, minimumValuePromise, opId) {
|
|
1584
|
-
const accountId =
|
|
1619
|
+
const accountId = this.ledgerId;
|
|
1585
1620
|
records = await this.filterReadableShieldedOutputs(records, resourceAddress, amount + maxFee);
|
|
1586
1621
|
// Enough inputs for the amount plus the fee limit when the balance allows; otherwise all of
|
|
1587
1622
|
// them -- the measured fee is usually far below the limit, and `build` checks the real one.
|
|
@@ -1694,7 +1729,7 @@ export class OotleAccount {
|
|
|
1694
1729
|
});
|
|
1695
1730
|
try {
|
|
1696
1731
|
const response = await withTimeout(pollTransactionResult(provider, transactionId), 60_000, "submitting the private send");
|
|
1697
|
-
await recordKnownVersions(response);
|
|
1732
|
+
await recordKnownVersions(response, this.network);
|
|
1698
1733
|
if (attempt.changeCommitment) {
|
|
1699
1734
|
await recordKnownShieldedOutput(accountId, resourceAddress, attempt.changeCommitment, attempt.change, transactionId);
|
|
1700
1735
|
}
|
|
@@ -1736,7 +1771,7 @@ export class OotleAccount {
|
|
|
1736
1771
|
* record the indexer can't answer for right now is left as it is.
|
|
1737
1772
|
*/
|
|
1738
1773
|
async pruneSpentShieldedOutputs() {
|
|
1739
|
-
const accountId =
|
|
1774
|
+
const accountId = this.ledgerId;
|
|
1740
1775
|
const before = (await listShieldedOutputs(accountId)).filter((r) => !r.spent).length;
|
|
1741
1776
|
await this.checkShieldedOutputs(await listShieldedOutputs(accountId));
|
|
1742
1777
|
const after = (await listShieldedOutputs(accountId)).filter((r) => !r.spent).length;
|
|
@@ -1744,7 +1779,7 @@ export class OotleAccount {
|
|
|
1744
1779
|
}
|
|
1745
1780
|
/** Reads each unspent record's UTXO; returns the unusable commitments, marking the definitively spent ones. */
|
|
1746
1781
|
async checkShieldedOutputs(records) {
|
|
1747
|
-
const accountId =
|
|
1782
|
+
const accountId = this.ledgerId;
|
|
1748
1783
|
const provider = await this.getProvider();
|
|
1749
1784
|
const crypto = new WasmStealthCrypto(this.network);
|
|
1750
1785
|
const viewSecret = await this.signer.getViewSecret();
|
|
@@ -1862,7 +1897,7 @@ export class OotleAccount {
|
|
|
1862
1897
|
* submissions use — if it would be rejected. Nothing reaches consensus; nothing is spent.
|
|
1863
1898
|
*/
|
|
1864
1899
|
async dryRunEnvelope(envelope) {
|
|
1865
|
-
const res = await fetch(`${
|
|
1900
|
+
const res = await fetch(`${indexerUrlFor(this.network)}/transactions/dry-run`, {
|
|
1866
1901
|
method: "POST",
|
|
1867
1902
|
headers: { "Content-Type": "application/json" },
|
|
1868
1903
|
body: JSON.stringify({ transaction: envelope }),
|
|
@@ -1966,7 +2001,7 @@ export class OotleAccount {
|
|
|
1966
2001
|
const envelope = sealTransaction(signed);
|
|
1967
2002
|
const transactionId = await submitTransaction(provider, envelope);
|
|
1968
2003
|
const response = await withTimeout(pollTransactionResult(provider, transactionId), 60_000, "submitting the private-fee redemption transaction");
|
|
1969
|
-
await recordKnownVersions(response);
|
|
2004
|
+
await recordKnownVersions(response, this.network);
|
|
1970
2005
|
return { transactionId, feeChangeCommitment };
|
|
1971
2006
|
}
|
|
1972
2007
|
/**
|
|
@@ -2008,8 +2043,9 @@ export class OotleAccount {
|
|
|
2008
2043
|
async htlcFund(resourceAddress, amount, claimantWalletAddress, hashLockHex, refundEpoch, maxFee = 50000n, feeType = { kind: "transparent" }, options = {}) {
|
|
2009
2044
|
if (amount <= 0n)
|
|
2010
2045
|
throw new Error("htlcFund: amount must be greater than zero.");
|
|
2046
|
+
this.assertSameNetwork(claimantWalletAddress, "The claimant");
|
|
2011
2047
|
const opId = newOperationId("htlc-fund");
|
|
2012
|
-
const accountId =
|
|
2048
|
+
const accountId = this.ledgerId;
|
|
2013
2049
|
const provider = await this.getProvider();
|
|
2014
2050
|
const account = await this.getComponentAddress();
|
|
2015
2051
|
const walletAddress = await this.getWalletAddress();
|
|
@@ -2303,7 +2339,7 @@ export class OotleAccount {
|
|
|
2303
2339
|
/** Refunds an HTLC this account funded, using the conditions/mask/amount `htlcFund` journaled. */
|
|
2304
2340
|
async refundFromJournal(journalId, maxFee = 50000n, feeType = { kind: "transparent" }) {
|
|
2305
2341
|
const entry = await getHtlcJournalEntry(journalId);
|
|
2306
|
-
if (!entry || entry.kind !== "fund" || entry.accountId !==
|
|
2342
|
+
if (!entry || entry.kind !== "fund" || entry.accountId !== this.ledgerId) {
|
|
2307
2343
|
throw new Error(`refundFromJournal: ${journalId} is not an HTLC this account funded.`);
|
|
2308
2344
|
}
|
|
2309
2345
|
if (!entry.htlcCommitment || !entry.outputMask)
|
|
@@ -2313,7 +2349,7 @@ export class OotleAccount {
|
|
|
2313
2349
|
/** Shared claim/refund path: private-fee reservation, dry run, journal, submit, bookkeeping. */
|
|
2314
2350
|
async spendHtlc(p) {
|
|
2315
2351
|
const opId = newOperationId(`htlc-${p.kind}`);
|
|
2316
|
-
const accountId =
|
|
2352
|
+
const accountId = this.ledgerId;
|
|
2317
2353
|
const provider = await this.getProvider();
|
|
2318
2354
|
const account = await this.getComponentAddress();
|
|
2319
2355
|
const substateId = stealthUtxoSubstateId(p.resourceAddress, fromHex(p.commitmentHex));
|
|
@@ -2392,7 +2428,7 @@ export class OotleAccount {
|
|
|
2392
2428
|
/** Applies a confirmed HTLC operation's local bookkeeping. Idempotent (see `addShieldedOutput`). */
|
|
2393
2429
|
async finalizeHtlcEntry(entry, response) {
|
|
2394
2430
|
const txId = entry.transactionId;
|
|
2395
|
-
await recordKnownVersions(response);
|
|
2431
|
+
await recordKnownVersions(response, this.network);
|
|
2396
2432
|
if (entry.ownCommitment && entry.ownAmount) {
|
|
2397
2433
|
await recordKnownShieldedOutput(entry.accountId, entry.resourceAddress, entry.ownCommitment, BigInt(entry.ownAmount), txId);
|
|
2398
2434
|
}
|
|
@@ -2408,7 +2444,7 @@ export class OotleAccount {
|
|
|
2408
2444
|
/** This account's HTLC journal (every fund/claim/refund and its state), newest first. The
|
|
2409
2445
|
* entries' `envelope` of a claim contains the preimage — don't display or export it. */
|
|
2410
2446
|
async listHtlcs() {
|
|
2411
|
-
return (await listHtlcJournal(
|
|
2447
|
+
return (await listHtlcJournal(this.ledgerId)).sort((a, b) => b.createdAt - a.createdAt);
|
|
2412
2448
|
}
|
|
2413
2449
|
/**
|
|
2414
2450
|
* Resolves every HTLC operation whose outcome isn't final (`prepared`, `claim_armed`,
|
|
@@ -2420,7 +2456,7 @@ export class OotleAccount {
|
|
|
2420
2456
|
*/
|
|
2421
2457
|
async reconcileHtlcs() {
|
|
2422
2458
|
const provider = await this.getProvider();
|
|
2423
|
-
const open = (await listHtlcJournal(
|
|
2459
|
+
const open = (await listHtlcJournal(this.ledgerId)).filter((e) => ["prepared", "claim_armed", "submitted", "unknown"].includes(e.status));
|
|
2424
2460
|
const out = [];
|
|
2425
2461
|
for (const entry of open) {
|
|
2426
2462
|
let current = entry;
|
|
@@ -2520,7 +2556,8 @@ export class OotleAccount {
|
|
|
2520
2556
|
*/
|
|
2521
2557
|
async sendPrivately(resourceAddress, recipientWalletAddress, amount, maxFee = 100000n, memo, minimumValuePromise = 0n, feeType = { kind: "transparent" }) {
|
|
2522
2558
|
assertValidMinimumValuePromise(minimumValuePromise, amount);
|
|
2523
|
-
|
|
2559
|
+
this.assertSameNetwork(recipientWalletAddress, "The recipient");
|
|
2560
|
+
const accountId = this.ledgerId;
|
|
2524
2561
|
const opId = newOperationId("send-private");
|
|
2525
2562
|
const unavailable = await this.unavailableCommitments(accountId, opId);
|
|
2526
2563
|
const records = await this.filterReadableShieldedOutputs((await listShieldedOutputs(accountId)).filter((r) => !unavailable.has(r.commitment)), resourceAddress, amount);
|
|
@@ -2596,7 +2633,7 @@ export class OotleAccount {
|
|
|
2596
2633
|
let keepPending = false;
|
|
2597
2634
|
try {
|
|
2598
2635
|
const response = await this.pollRecordingFee(accountId, feeType, privateFee, transactionId, () => withTimeout(pollTransactionResult(provider, transactionId), 60_000, "submitting the private send"));
|
|
2599
|
-
await recordKnownVersions(response);
|
|
2636
|
+
await recordKnownVersions(response, this.network);
|
|
2600
2637
|
if (ownCommitment)
|
|
2601
2638
|
await recordKnownShieldedOutput(accountId, resourceAddress, ownCommitment, changeAmount, transactionId);
|
|
2602
2639
|
for (const commitment of commitments) {
|
|
@@ -2636,7 +2673,7 @@ export class OotleAccount {
|
|
|
2636
2673
|
* shielded-outputs picker.
|
|
2637
2674
|
*/
|
|
2638
2675
|
async claimPrivatePayment(resourceAddress, commitmentHex) {
|
|
2639
|
-
const accountId =
|
|
2676
|
+
const accountId = this.ledgerId;
|
|
2640
2677
|
const existing = await listShieldedOutputs(accountId);
|
|
2641
2678
|
if (existing.some((r) => r.resourceAddress === resourceAddress && r.commitment === commitmentHex)) {
|
|
2642
2679
|
throw new Error("You've already claimed this payment.");
|
|
@@ -2695,8 +2732,8 @@ export class OotleAccount {
|
|
|
2695
2732
|
transactionId = await submitTransaction(provider, attempt.envelope);
|
|
2696
2733
|
response = await withTimeout(pollTransactionResult(provider, transactionId), 90_000, "claiming the burn");
|
|
2697
2734
|
}
|
|
2698
|
-
await recordKnownVersions(response);
|
|
2699
|
-
await recordKnownShieldedOutput(
|
|
2735
|
+
await recordKnownVersions(response, this.network);
|
|
2736
|
+
await recordKnownShieldedOutput(this.ledgerId, TARI_RESOURCE_ADDRESS, attempt.ownCommitment, attempt.claimedAmount, transactionId, memo);
|
|
2700
2737
|
return { transactionId, claimedAmount: attempt.claimedAmount, commitment: attempt.ownCommitment, fee };
|
|
2701
2738
|
}
|
|
2702
2739
|
/**
|
|
@@ -2808,7 +2845,7 @@ export class OotleAccount {
|
|
|
2808
2845
|
});
|
|
2809
2846
|
try {
|
|
2810
2847
|
const response = await withTimeout(pollTransactionResult(provider, transactionId), 60_000, "submitting the unshield transaction");
|
|
2811
|
-
await recordKnownVersions(response);
|
|
2848
|
+
await recordKnownVersions(response, this.network);
|
|
2812
2849
|
await recordKnownShieldedOutput(accountId, resourceAddress, changeCommitment, remainder, transactionId, memo);
|
|
2813
2850
|
for (const commitment of commitments)
|
|
2814
2851
|
await markShieldedOutputSpent(accountId, commitment);
|
|
@@ -2834,7 +2871,7 @@ export class OotleAccount {
|
|
|
2834
2871
|
if (resourceAddress !== TARI_RESOURCE_ADDRESS) {
|
|
2835
2872
|
throw new Error("This account doesn't exist on-chain yet. Unshield some TARI first to create it, then unshield other resources.");
|
|
2836
2873
|
}
|
|
2837
|
-
const accountId =
|
|
2874
|
+
const accountId = this.ledgerId;
|
|
2838
2875
|
const crypto = new WasmStealthCrypto(this.network);
|
|
2839
2876
|
const viewSecret = await this.signer.getViewSecret();
|
|
2840
2877
|
const walletAddress = await this.getWalletAddress();
|
|
@@ -2949,7 +2986,7 @@ export class OotleAccount {
|
|
|
2949
2986
|
transactionId = await submitTransaction(provider, attempt.envelope);
|
|
2950
2987
|
response = await withTimeout(pollTransactionResult(provider, transactionId), 90_000, "unshielding into a new account");
|
|
2951
2988
|
}
|
|
2952
|
-
await recordKnownVersions(response);
|
|
2989
|
+
await recordKnownVersions(response, this.network);
|
|
2953
2990
|
for (const input of inputs)
|
|
2954
2991
|
await markShieldedOutputSpent(accountId, input.commitmentHex);
|
|
2955
2992
|
if (attempt.changeCommitment) {
|
|
@@ -3022,7 +3059,7 @@ export class OotleAccount {
|
|
|
3022
3059
|
}
|
|
3023
3060
|
/** Dry-runs a sealed claim and returns the fee it needs: what it was charged plus the allowance. */
|
|
3024
3061
|
async estimateClaimFee(dryRun, what = "claim") {
|
|
3025
|
-
const res = await fetch(`${
|
|
3062
|
+
const res = await fetch(`${indexerUrlFor(this.network)}/transactions/dry-run`, {
|
|
3026
3063
|
method: "POST",
|
|
3027
3064
|
headers: { "Content-Type": "application/json" },
|
|
3028
3065
|
body: JSON.stringify({ transaction: dryRun.envelope }),
|
|
@@ -3068,7 +3105,7 @@ export class OotleAccount {
|
|
|
3068
3105
|
* Anything not in here is, as far as this wallet is concerned, not spendable.
|
|
3069
3106
|
*/
|
|
3070
3107
|
async listUnspentShieldedOutputs(resourceAddress) {
|
|
3071
|
-
return selectUnspentShieldedOutputs(await listShieldedOutputs(
|
|
3108
|
+
return selectUnspentShieldedOutputs(await listShieldedOutputs(this.ledgerId), resourceAddress);
|
|
3072
3109
|
}
|
|
3073
3110
|
/**
|
|
3074
3111
|
* Per-resource totals over `listUnspentShieldedOutputs()`, with each resource's real on-chain
|
|
@@ -3123,7 +3160,7 @@ export class OotleAccount {
|
|
|
3123
3160
|
* that is gone from the listing and cannot be recovered by this scan.
|
|
3124
3161
|
*/
|
|
3125
3162
|
async scanForPrivatePayments(maxPages, pageSize = 50) {
|
|
3126
|
-
const accountId =
|
|
3163
|
+
const accountId = this.ledgerId;
|
|
3127
3164
|
const provider = await this.getProvider();
|
|
3128
3165
|
const viewSecret = await this.signer.getViewSecret();
|
|
3129
3166
|
const crypto = new WasmStealthCrypto(this.network);
|
|
@@ -3240,7 +3277,7 @@ export class OotleAccount {
|
|
|
3240
3277
|
* whose mint is known to be recent, not a background sweep of the whole chain.
|
|
3241
3278
|
*/
|
|
3242
3279
|
async scanForResourceUtxos(resourceAddress, opts = {}) {
|
|
3243
|
-
const accountId =
|
|
3280
|
+
const accountId = this.ledgerId;
|
|
3244
3281
|
const provider = await this.getProvider();
|
|
3245
3282
|
const viewSecret = await this.signer.getViewSecret();
|
|
3246
3283
|
const crypto = new WasmStealthCrypto(this.network);
|
|
@@ -3358,7 +3395,7 @@ export class OotleAccount {
|
|
|
3358
3395
|
*/
|
|
3359
3396
|
async scanForOwnedUtxos(resourceAddress, indexerBaseUrl, opts = {}) {
|
|
3360
3397
|
const { mode = "full", perShardLimit = 200, pageSize = 100, maxPages = 20 } = opts;
|
|
3361
|
-
const accountId =
|
|
3398
|
+
const accountId = this.ledgerId;
|
|
3362
3399
|
const viewSecret = await this.signer.getViewSecret();
|
|
3363
3400
|
const crypto = new WasmStealthCrypto(this.network);
|
|
3364
3401
|
const known = new Set((await listShieldedOutputs(accountId)).map((r) => r.commitment));
|
|
@@ -3748,9 +3785,16 @@ export function resolveSendPrivatelyPlan(records, resourceAddress, amount) {
|
|
|
3748
3785
|
* every pending shield, whichever local account they belong to — this is a read-only connection,
|
|
3749
3786
|
* not account/signing-specific.
|
|
3750
3787
|
*/
|
|
3751
|
-
export async function recoverPendingShields(provider) {
|
|
3788
|
+
export async function recoverPendingShields(provider, network) {
|
|
3752
3789
|
const pending = await listPendingShields();
|
|
3753
3790
|
for (const p of pending) {
|
|
3791
|
+
// A pending shield belongs to the network its ledger id names (see `ledgerAccountId`). Only
|
|
3792
|
+
// that network's indexer can answer for it; asking another one just fails every time. With
|
|
3793
|
+
// no `network` given, every entry is tried, as before.
|
|
3794
|
+
const mainnetEntry = isMainnetLedgerId(p.accountId);
|
|
3795
|
+
if (network !== undefined && mainnetEntry !== (network === Network.MainNet))
|
|
3796
|
+
continue;
|
|
3797
|
+
const entryNetwork = mainnetEntry ? Network.MainNet : Network.Esmeralda;
|
|
3754
3798
|
try {
|
|
3755
3799
|
const response = await getTransactionResultDecoded(provider, p.transactionId);
|
|
3756
3800
|
const result = response.result;
|
|
@@ -3771,7 +3815,7 @@ export async function recoverPendingShields(provider) {
|
|
|
3771
3815
|
await markShieldedOutputSpent(p.accountId, p.privateFee.spentCommitment);
|
|
3772
3816
|
}
|
|
3773
3817
|
if (succeeded) {
|
|
3774
|
-
await recordKnownVersions(response);
|
|
3818
|
+
await recordKnownVersions(response, entryNetwork);
|
|
3775
3819
|
if (p.ownCommitment) {
|
|
3776
3820
|
await recordKnownShieldedOutput(p.accountId, p.resourceAddress, p.ownCommitment, BigInt(p.amount), p.transactionId, p.memo);
|
|
3777
3821
|
}
|
|
@@ -3864,12 +3908,21 @@ async function loadKnownVersions() {
|
|
|
3864
3908
|
}
|
|
3865
3909
|
return knownVersionsPromise;
|
|
3866
3910
|
}
|
|
3911
|
+
/**
|
|
3912
|
+
* The cache key for a substate on `network`. A component address is derived from the key alone, so
|
|
3913
|
+
* the same address exists on every network with unrelated versions; mainnet entries are prefixed
|
|
3914
|
+
* so they never meet testnet ones. Testnet keys stay bare, exactly as every earlier build wrote
|
|
3915
|
+
* them, so existing caches keep working.
|
|
3916
|
+
*/
|
|
3917
|
+
function versionKey(substateId, network) {
|
|
3918
|
+
return network === Network.MainNet ? `mainnet:${substateId}` : substateId;
|
|
3919
|
+
}
|
|
3867
3920
|
/** Prefers our own record of a substate's version over whatever the indexer just reported, when
|
|
3868
3921
|
* we have a newer one — see the block comment above for why. */
|
|
3869
|
-
async function applyKnownVersions(inputs) {
|
|
3922
|
+
async function applyKnownVersions(inputs, network) {
|
|
3870
3923
|
const known = await loadKnownVersions();
|
|
3871
3924
|
return inputs.map((input) => {
|
|
3872
|
-
const version = known.get(input.substate_id);
|
|
3925
|
+
const version = known.get(versionKey(input.substate_id, network));
|
|
3873
3926
|
return version !== undefined && (input.version === null || version > input.version) ? { ...input, version } : input;
|
|
3874
3927
|
});
|
|
3875
3928
|
}
|
|
@@ -3902,7 +3955,7 @@ export function dedupeInputs(inputs) {
|
|
|
3902
3955
|
/** Remembers the post-transaction version of every substate a *confirmed* (never a dry-run —
|
|
3903
3956
|
* those don't reflect real state) transaction touched, so the next transaction that references
|
|
3904
3957
|
* one of them doesn't have to trust the indexer's possibly-stale view of it. */
|
|
3905
|
-
async function recordKnownVersions(response) {
|
|
3958
|
+
async function recordKnownVersions(response, network) {
|
|
3906
3959
|
const result = response.result;
|
|
3907
3960
|
if (result === "Pending" || "Rejected" in result)
|
|
3908
3961
|
return;
|
|
@@ -3916,7 +3969,7 @@ async function recordKnownVersions(response) {
|
|
|
3916
3969
|
return;
|
|
3917
3970
|
const updates = new Map();
|
|
3918
3971
|
for (const [id, substate] of upSubstates)
|
|
3919
|
-
updates.set(id, substate.version);
|
|
3972
|
+
updates.set(versionKey(id, network), substate.version);
|
|
3920
3973
|
// No extra `serialized()` wrap needed here (and one would deadlock: `setKnownVersions` below
|
|
3921
3974
|
// already serializes its own write against storage.ts's shared queue, and queuing this whole
|
|
3922
3975
|
// function behind that same queue would make it wait on a write that is itself waiting for this
|
|
@@ -3952,13 +4005,13 @@ function withTransactionId(response) {
|
|
|
3952
4005
|
* remembered one is unusable. Keeping it would make `applyKnownVersions` reassert it over every
|
|
3953
4006
|
* future resolve, turning one bad write into a permanently stuck wallet.
|
|
3954
4007
|
*/
|
|
3955
|
-
export async function forgetKnownVersions(substateIds) {
|
|
4008
|
+
export async function forgetKnownVersions(substateIds, network) {
|
|
3956
4009
|
if (substateIds.length === 0)
|
|
3957
4010
|
return;
|
|
3958
4011
|
const known = await loadKnownVersions();
|
|
3959
4012
|
let changed = false;
|
|
3960
4013
|
for (const id of substateIds)
|
|
3961
|
-
if (known.delete(id))
|
|
4014
|
+
if (known.delete(versionKey(id, network)))
|
|
3962
4015
|
changed = true;
|
|
3963
4016
|
if (changed)
|
|
3964
4017
|
await setKnownVersions(Object.fromEntries(known));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chironbuilder/ootle-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Shared TypeScript client for Tari Ootle (L2): account derivation, balances, transactions, HTLCs, and stealth/confidential transfers — the account core behind Sapient and the Tari L1 web wallet's Ootle support.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|