@chironbuilder/ootle-sdk 0.2.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -62,6 +62,18 @@ 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
+
65
77
  ### Claiming a Minotari (L1) burn
66
78
 
67
79
  A burn addressed to this account's public key (`getPublicKey()`) is claimed with `claimBurn`. Build
@@ -124,12 +136,21 @@ await account.refundFromJournal(fund.journalId);
124
136
  `isHtlcClaimableByEpoch`.
125
137
  - Claimed and refunded outputs are recorded in the shielded ledger, so they're spendable at once.
126
138
 
139
+ ## Verifying ownership proofs
140
+
141
+ A site that receives `{ walletAddress, publicNonce, signature }` from
142
+ `tari_signWalletOwnershipChallenge` checks it with `verifyWalletOwnershipProof` (and a per-output
143
+ proof with `verifyOwnershipProof`), taking the key from the address it already had in mind. The
144
+ byte spec is in [docs/ownership-proof.md](docs/ownership-proof.md);
145
+ `src/fixtures/ownershipProof.vectors.json` holds fixed vectors produced with Tari's real signer
146
+ (test-only keys).
147
+
127
148
  ## What's in here, and what isn't
128
149
 
129
150
  - **Account core** (`wallet.ts`): `OotleAccount`, balance/plan-resolution helpers, the transaction
130
151
  auto-resolve retry loop.
131
152
  - **Crypto/derivation**: `derivation.ts`, `domainHash.ts`, `componentAddress.ts`, `vault.ts`,
132
- `ownershipProof.ts`, `confidential.ts`.
153
+ `ownershipProof.ts`, `verifyOwnershipProof.ts`, `confidential.ts`.
133
154
  - **HTLC**: `htlc.ts` (condition trees), `htlcSafety.ts` (epoch rules, pre-claim verification,
134
155
  per-output masks, outcome classification) + the journaled `OotleAccount` HTLC methods.
135
156
  - **L1 burn claims**: `burnClaim.ts` (proof assembly) + `OotleAccount.claimBurn`.
package/dist/index.d.ts CHANGED
@@ -12,8 +12,10 @@ 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";
@@ -1 +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C;AAEtB,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9D,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAE3F,YAAY,EAAE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC7I,OAAO,EACL,YAAY,EACZ,8BAA8B,EAC9B,uBAAuB,EACvB,6BAA6B,EAC7B,uBAAuB,EACvB,mBAAmB,EACnB,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,8 +7,9 @@ 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
15
  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";
@@ -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
- /** `fetchSubstates` with each entry given the pre-0.48 `{ version, substate }` shape. */
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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AC,CAYlM;AAED,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"}
@@ -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
- /** `fetchSubstates` with each entry given the pre-0.48 `{ version, substate }` shape. */
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 response = (await provider.fetchSubstates(ids));
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 [id, entry] of Object.entries(response.substates ?? {})) {
39
- if (!entry)
40
- continue;
41
- substates[id] = { ...entry, substate: substateValueOf(entry.value ?? entry.substate) };
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 { ...response, substates };
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) {
@@ -1,4 +1,21 @@
1
1
  import { Network } from "@tari-project/ootle";
2
- export type NetworkName = "esmeralda" | "igor";
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;AAE/C,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CASzD"}
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"}
@@ -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
+ }
@@ -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
@@ -181,6 +181,14 @@ export declare class OotleAccount implements WalletAccountApi {
181
181
  * address", it is NOT the on-chain account component address. See `getComponentAddress()`.
182
182
  */
183
183
  getWalletAddress(): Promise<string>;
184
+ /**
185
+ * Refuses an `otl_` address that names a different network from this account's. The component
186
+ * address is derived from the key alone, so a testnet address used on mainnet would still pay its
187
+ * owner's mainnet account -- but a mismatch nearly always means the sender has the wrong network
188
+ * or the wrong address in hand, and on mainnet that costs real money. Throws on an address that
189
+ * doesn't parse, too.
190
+ */
191
+ private assertSameNetwork;
184
192
  /**
185
193
  * This account's owner public key, synchronously. Named as the receiver of every revealed
186
194
  * stealth output this account's `StealthTransfer`s create (tari-ootle#2645): the engine only
@@ -1208,6 +1216,21 @@ export declare function resolveSendPrivatelyPlan(records: ShieldedOutputRecord[]
1208
1216
  * not account/signing-specific.
1209
1217
  */
1210
1218
  export declare function recoverPendingShields(provider: IndexerProvider): Promise<void>;
1219
+ /**
1220
+ * The fee named by an `InsufficientFeesPaid` rejection, if any. The engine words it three ways:
1221
+ * "Required fees N but M paid", "Committing requires N but M paid" and
1222
+ * "Insufficient fees paid: M, required fees: N".
1223
+ */
1224
+ export declare function requiredFeeFromRejection(e: unknown): bigint | null;
1225
+ /**
1226
+ * The fees to dry-run a new-account unshield at. `first` leaves change whenever the private
1227
+ * remainder can, so the dry run has the change output the real transaction will have; if the fee it
1228
+ * measures would use up that remainder, `withoutChange` measures the cheaper change-free shape.
1229
+ */
1230
+ export declare function unshieldFeeProbes(remainder: bigint, amount: bigint, maxFee: bigint): {
1231
+ first: bigint;
1232
+ withoutChange: bigint | null;
1233
+ };
1211
1234
  /**
1212
1235
  * Collapses a transaction's inputs to one entry per `substate_id`. Ootle 0.47's transaction
1213
1236
  * deserializer rejects duplicate inputs outright — the whole transaction fails to parse inside the
@@ -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,eAAe,EAAE,MAAM,uCAAuC,CAAC;AA2BxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,E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,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, defaultIndexerUrl, getVaultIdsForAccount, resolveMaxEpoch, resolveTransaction, resourceAddressLiteral, generateSealKeypair, sealTransaction, sendTransaction, serializeUnsignedTx, signTransaction, stealthUtxoSubstateId, submitTransaction, } from "@tari-project/ootle";
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,7 +18,7 @@ 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";
21
+ import { indexerUrlFor, networkNameFromByte, toOotleNetwork } from "./ootleNetwork.js";
22
22
  import { addPendingShield, addShieldedOutput, clearUtxoScanPageCursor, getHtlcJournalEntry, getKnownVersions, getPrivatePaymentScanCursor, getPrivatePaymentScanResume, getUtxoScanPageCursor, getUtxoScanWatermarks, listHtlcJournal, listPendingShields, listReservedCommitments, listShieldedOutputs, localAccountId, 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";
@@ -200,7 +200,7 @@ export class OotleAccount {
200
200
  // problem (unlike execute()'s later errors, which are meaningful on-chain rejections this
201
201
  // class deliberately leaves unwrapped) — mirrors the same "unreachable" framing
202
202
  // DaemonAccount.connectClient() uses for the equivalent first-contact step.
203
- const url = defaultIndexerUrl(this.network);
203
+ const url = indexerUrlFor(this.network);
204
204
  try {
205
205
  this.provider = await withTimeout(IndexerProvider.connect({ url, network: this.network }), 15_000, "connecting to the Tari indexer");
206
206
  }
@@ -220,6 +220,27 @@ export class OotleAccount {
220
220
  async getWalletAddress() {
221
221
  return this.signer.getAddress();
222
222
  }
223
+ /**
224
+ * Refuses an `otl_` address that names a different network from this account's. The component
225
+ * address is derived from the key alone, so a testnet address used on mainnet would still pay its
226
+ * owner's mainnet account -- but a mismatch nearly always means the sender has the wrong network
227
+ * or the wrong address in hand, and on mainnet that costs real money. Throws on an address that
228
+ * doesn't parse, too.
229
+ */
230
+ assertSameNetwork(address, role) {
231
+ let byte;
232
+ try {
233
+ byte = parseOotleAddress(address.trim()).network;
234
+ }
235
+ catch {
236
+ throw new Error(`${role} address is not a valid otl_ address.`);
237
+ }
238
+ if (byte !== this.network) {
239
+ const theirs = networkNameFromByte(byte) ?? `network ${byte}`;
240
+ const ours = networkNameFromByte(this.network) ?? `network ${this.network}`;
241
+ throw new Error(`${role} address is for ${theirs}, but this account is on ${ours}. Check you have the right address and network.`);
242
+ }
243
+ }
223
244
  /**
224
245
  * This account's owner public key, synchronously. Named as the receiver of every revealed
225
246
  * stealth output this account's `StealthTransfer`s create (tari-ootle#2645): the engine only
@@ -538,7 +559,7 @@ export class OotleAccount {
538
559
  resolved.inputs = dedupeInputs(resolved.inputs);
539
560
  const signed = await signTransaction([this.signer, ...extraSigners], resolved);
540
561
  const envelope = sealTransaction(signed);
541
- const res = await fetch(`${defaultIndexerUrl(this.network)}/transactions/dry-run`, {
562
+ const res = await fetch(`${indexerUrlFor(this.network)}/transactions/dry-run`, {
542
563
  method: "POST",
543
564
  headers: { "Content-Type": "application/json" },
544
565
  // `TransactionEnvelope` (ootle-ts-bindings) is just `string` — the request body is the
@@ -648,6 +669,8 @@ export class OotleAccount {
648
669
  throw new Error(`send: amount must be greater than zero, got ${amount}`);
649
670
  const account = await this.getComponentAddress();
650
671
  const isWalletAddress = recipientAddress.startsWith("otl");
672
+ if (isWalletAddress)
673
+ this.assertSameNetwork(recipientAddress, "The recipient");
651
674
  const recipient = isWalletAddress ? componentAddressFromWalletAddress(recipientAddress) : recipientAddress;
652
675
  const instructions = [];
653
676
  if (isWalletAddress) {
@@ -763,6 +786,8 @@ export class OotleAccount {
763
786
  * of burning the whole retry budget re-observing the same stale state.
764
787
  */
765
788
  async claimTestnetXtr(maxFee = 5000n, retries = 10, retryDelayMs = 300) {
789
+ if (this.network === Network.MainNet)
790
+ throw new Error("There is no faucet on mainnet.");
766
791
  const provider = await this.getProvider();
767
792
  const publicKeyHex = bytesToHex(await this.getPublicKey());
768
793
  const account = await this.getComponentAddress();
@@ -1862,7 +1887,7 @@ export class OotleAccount {
1862
1887
  * submissions use — if it would be rejected. Nothing reaches consensus; nothing is spent.
1863
1888
  */
1864
1889
  async dryRunEnvelope(envelope) {
1865
- const res = await fetch(`${defaultIndexerUrl(this.network)}/transactions/dry-run`, {
1890
+ const res = await fetch(`${indexerUrlFor(this.network)}/transactions/dry-run`, {
1866
1891
  method: "POST",
1867
1892
  headers: { "Content-Type": "application/json" },
1868
1893
  body: JSON.stringify({ transaction: envelope }),
@@ -2008,6 +2033,7 @@ export class OotleAccount {
2008
2033
  async htlcFund(resourceAddress, amount, claimantWalletAddress, hashLockHex, refundEpoch, maxFee = 50000n, feeType = { kind: "transparent" }, options = {}) {
2009
2034
  if (amount <= 0n)
2010
2035
  throw new Error("htlcFund: amount must be greater than zero.");
2036
+ this.assertSameNetwork(claimantWalletAddress, "The claimant");
2011
2037
  const opId = newOperationId("htlc-fund");
2012
2038
  const accountId = localAccountId(this.index);
2013
2039
  const provider = await this.getProvider();
@@ -2520,6 +2546,7 @@ export class OotleAccount {
2520
2546
  */
2521
2547
  async sendPrivately(resourceAddress, recipientWalletAddress, amount, maxFee = 100000n, memo, minimumValuePromise = 0n, feeType = { kind: "transparent" }) {
2522
2548
  assertValidMinimumValuePromise(minimumValuePromise, amount);
2549
+ this.assertSameNetwork(recipientWalletAddress, "The recipient");
2523
2550
  const accountId = localAccountId(this.index);
2524
2551
  const opId = newOperationId("send-private");
2525
2552
  const unavailable = await this.unavailableCommitments(accountId, opId);
@@ -2921,15 +2948,34 @@ export class OotleAccount {
2921
2948
  const signed = await signTransaction(signers, unsignedTx, sealKeypair);
2922
2949
  return { envelope: sealTransaction(signed), change, changeCommitment };
2923
2950
  };
2924
- // Any fee the balance can pay works as the dry run's probe; it only feeds the metered cost.
2925
- const payable = remainder + amount - 1n;
2926
- const probe = maxFee < payable ? maxFee : payable;
2927
- const fee = await this.estimateClaimFee(await build(probe, true), "unshield");
2951
+ // The dry run must have the real transaction's shape, change output included, or it meters a
2952
+ // cheaper transaction than the one sent. The probe only feeds the metered cost.
2953
+ const probes = unshieldFeeProbes(remainder, amount, maxFee);
2954
+ let fee = await this.estimateClaimFee(await build(probes.first, true), "unshield");
2955
+ if (probes.withoutChange !== null && fee >= remainder) {
2956
+ // A fee this large leaves no change, so the transaction sent has no change output to pay for.
2957
+ const withoutChange = await this.estimateClaimFee(await build(probes.withoutChange, true), "unshield");
2958
+ if (withoutChange >= remainder)
2959
+ fee = withoutChange;
2960
+ }
2928
2961
  if (fee > maxFee)
2929
2962
  throw new Error(`unshield: creating the account costs ${fee}, above the ${maxFee} limit`);
2930
- const attempt = await build(fee, false);
2931
- const transactionId = await submitTransaction(provider, attempt.envelope);
2932
- const response = await withTimeout(pollTransactionResult(provider, transactionId), 90_000, "unshielding into a new account");
2963
+ let attempt = await build(fee, false);
2964
+ let transactionId = await submitTransaction(provider, attempt.envelope);
2965
+ let response;
2966
+ try {
2967
+ response = await withTimeout(pollTransactionResult(provider, transactionId), 90_000, "unshielding into a new account");
2968
+ }
2969
+ catch (e) {
2970
+ // As in claimBurn: a shortfall aborts without spending anything, and names the fee it wanted.
2971
+ const required = requiredFeeFromRejection(e);
2972
+ if (required === null || required <= fee || required > maxFee)
2973
+ throw e;
2974
+ fee = required;
2975
+ attempt = await build(fee, false);
2976
+ transactionId = await submitTransaction(provider, attempt.envelope);
2977
+ response = await withTimeout(pollTransactionResult(provider, transactionId), 90_000, "unshielding into a new account");
2978
+ }
2933
2979
  await recordKnownVersions(response);
2934
2980
  for (const input of inputs)
2935
2981
  await markShieldedOutputSpent(accountId, input.commitmentHex);
@@ -3003,7 +3049,7 @@ export class OotleAccount {
3003
3049
  }
3004
3050
  /** Dry-runs a sealed claim and returns the fee it needs: what it was charged plus the allowance. */
3005
3051
  async estimateClaimFee(dryRun, what = "claim") {
3006
- const res = await fetch(`${defaultIndexerUrl(this.network)}/transactions/dry-run`, {
3052
+ const res = await fetch(`${indexerUrlFor(this.network)}/transactions/dry-run`, {
3007
3053
  method: "POST",
3008
3054
  headers: { "Content-Type": "application/json" },
3009
3055
  body: JSON.stringify({ transaction: dryRun.envelope }),
@@ -3030,6 +3076,11 @@ export class OotleAccount {
3030
3076
  for (const amount of Object.values(breakdown))
3031
3077
  if (amount !== undefined)
3032
3078
  charged += BigInt(amount);
3079
+ // Since 0.50 a receipt can be charged less than committing the whole transaction costs. Mirrors
3080
+ // the engine's FinalizeResult::required_fees; the field is absent from an older indexer's result.
3081
+ const whole = finalize.total_fees_required;
3082
+ if (whole !== undefined && BigInt(whole) > charged)
3083
+ charged = BigInt(whole);
3033
3084
  if (charged === 0n)
3034
3085
  throw new Error(`Could not estimate the ${what} fee: the dry run reported no cost`);
3035
3086
  return charged + FEE_ESTIMATE_ALLOWANCE;
@@ -3781,11 +3832,30 @@ function claimFeeProbe(burnValue) {
3781
3832
  const probe = 1000000n;
3782
3833
  return burnValue > probe ? probe : burnValue - 1n;
3783
3834
  }
3784
- /** The fee named by an `InsufficientFeesPaid` rejection ("Required fees N but M paid"), if any. */
3785
- function requiredFeeFromRejection(e) {
3786
- const match = /Required fees (\d+) but \d+ paid/.exec(e instanceof Error ? e.message : String(e));
3835
+ /**
3836
+ * The fee named by an `InsufficientFeesPaid` rejection, if any. The engine words it three ways:
3837
+ * "Required fees N but M paid", "Committing requires N but M paid" and
3838
+ * "Insufficient fees paid: M, required fees: N".
3839
+ */
3840
+ export function requiredFeeFromRejection(e) {
3841
+ const message = e instanceof Error ? e.message : String(e);
3842
+ const match = /(?:Required fees|Committing requires) (\d+) but \d+ paid/.exec(message) ??
3843
+ /Insufficient fees paid: \d+, required fees: (\d+)/.exec(message);
3787
3844
  return match ? BigInt(match[1]) : null;
3788
3845
  }
3846
+ /**
3847
+ * The fees to dry-run a new-account unshield at. `first` leaves change whenever the private
3848
+ * remainder can, so the dry run has the change output the real transaction will have; if the fee it
3849
+ * measures would use up that remainder, `withoutChange` measures the cheaper change-free shape.
3850
+ */
3851
+ export function unshieldFeeProbes(remainder, amount, maxFee) {
3852
+ const payable = remainder + amount - 1n;
3853
+ const withoutChange = maxFee < payable ? maxFee : payable;
3854
+ const roomForChange = remainder - 1n;
3855
+ if (roomForChange <= 0n)
3856
+ return { first: withoutChange, withoutChange: null };
3857
+ return { first: maxFee < roomForChange ? maxFee : roomForChange, withoutChange };
3858
+ }
3789
3859
  /**
3790
3860
  * Persists a `ShieldedOutputRecord` for a commitment already known locally (see
3791
3861
  * `extractOutputCommitment`'s doc comment for why this is preferred over scanning the finalized
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chironbuilder/ootle-sdk",
3
- "version": "0.2.2",
3
+ "version": "0.4.0",
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",
@@ -39,15 +39,15 @@
39
39
  "prepublishOnly": "npm run build"
40
40
  },
41
41
  "dependencies": {
42
+ "@chironbuilder/ootle-wasm-legacy": "file:./vendor/ootle-wasm-patched",
42
43
  "@noble/curves": "^1.9.0",
43
44
  "@noble/hashes": "^2.2.0",
44
- "@tari-project/ootle": "^0.12.0",
45
- "@tari-project/ootle-indexer": "^0.12.0",
46
- "@tari-project/ootle-secret-key-wallet": "^0.12.0",
47
- "@tari-project/ootle-ts-bindings": "^1.62.0",
48
- "@tari-project/ootle-wasm": "^0.49.2",
49
- "@tari-project/ootle-wasm-bor": "^0.49.2",
50
- "@chironbuilder/ootle-wasm-legacy": "file:./vendor/ootle-wasm-patched"
45
+ "@tari-project/ootle": "^0.14.0",
46
+ "@tari-project/ootle-indexer": "^0.14.0",
47
+ "@tari-project/ootle-secret-key-wallet": "^0.14.0",
48
+ "@tari-project/ootle-ts-bindings": "^1.63.0",
49
+ "@tari-project/ootle-wasm": "^0.50.1",
50
+ "@tari-project/ootle-wasm-bor": "^0.50.1"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/chrome": "^0.0.280",
@@ -1,97 +1,97 @@
1
- # ootle-wasm
2
-
3
- Rust → WASM library providing client-side crypto operations for Tari Ootle L2.
4
-
5
- ## Architecture
6
-
7
- - `core/` — Pure Rust library. All crypto/encoding logic lives here. Testable natively with `cargo test`.
8
- - `wasm/` — Thin `wasm-bindgen` shell. Accepts JSON strings, calls core, returns results.
9
-
10
- ## Prerequisites
11
-
12
- ```bash
13
- # Install wasm-pack
14
- cargo install wasm-pack
15
-
16
- # (Optional) Install wasm-opt for size optimisation
17
- # macOS:
18
- brew install binaryen
19
- # or via cargo:
20
- cargo install wasm-opt
21
- ```
22
-
23
- ## Build
24
-
25
- ### Native (tests only)
26
-
27
- ```bash
28
- cargo test -p ootle-wasm-core
29
- ```
30
-
31
- ### WASM
32
-
33
- ```bash
34
- # Build for bundler (webpack, vite, rollup, esbuild)
35
- wasm-pack build crates/ootle_wasm/wasm --target bundler --release --out-dir ../../../pkg
36
-
37
- # Build for Node.js
38
- wasm-pack build crates/ootle_wasm/wasm --target nodejs --release --out-dir ../../../pkg
39
-
40
- # Build for web (no bundler)
41
- wasm-pack build crates/ootle_wasm/wasm --target web --release --out-dir ../../../pkg
42
- ```
43
-
44
- The output goes to `pkg/` at the repo root containing:
45
-
46
- - `ootle_wasm_bg.wasm` — the WASM binary
47
- - `ootle_wasm.js` — JS glue code
48
- - `ootle_wasm.d.ts` — TypeScript type definitions
49
-
50
- ### Size optimisation (optional)
51
-
52
- ```bash
53
- wasm-opt -Oz --strip-debug --strip-producers pkg/ootle_wasm_bg.wasm -o pkg/ootle_wasm_bg.wasm
54
- ```
55
-
56
- ### Debug build (with panic hook)
57
-
58
- ```bash
59
- wasm-pack build crates/ootle_wasm/wasm --target bundler --dev --out-dir ../../../pkg -- --features debug
60
- ```
61
-
62
- ## WASM Exports
63
-
64
- | Function | Signature | Description |
65
- |---------------------------|-----------------------------------------------------------------------------|-----------------------------------------------------|
66
- | `borEncodeTransaction` | `(transactionJson: string) → string` | BOR-encode a Transaction JSON → base64 envelope |
67
- | `hashUnsignedTransaction` | `(unsignedTxJson: string, sealSignerPubKeyHex: string) → Uint8Array` | Hash an unsigned transaction for signing (64 bytes) |
68
- | `schnorrSign` | `(secretKeyHex: string, message: Uint8Array) → { public_nonce, signature }` | Schnorr-sign a message |
69
- | `generateKeypair` | `() → { secret_key, public_key }` | Generate a random Ristretto keypair |
70
- | `publicKeyFromSecretKey` | `(secretKeyHex: string) → string` | Derive public key from secret key |
71
-
72
- All keys and signatures are lowercase hex-encoded strings.
73
-
74
- ## Usage from JS/TS
75
-
76
- ```typescript
77
- import init, {
78
- generateKeypair,
79
- schnorrSign,
80
- hashUnsignedTransaction,
81
- borEncodeTransaction,
82
- publicKeyFromSecretKey,
83
- } from './pkg/ootle_wasm.js';
84
-
85
- // Initialise the WASM module
86
- await init();
87
-
88
- // Generate a keypair
89
- const { secret_key, public_key } = generateKeypair();
90
-
91
- // Hash an unsigned transaction for signing
92
- const unsignedTxJson = JSON.stringify(unsignedTransaction);
93
- const hash = hashUnsignedTransaction(unsignedTxJson, sealSignerPublicKeyHex);
94
-
95
- // Sign the hash
96
- const { public_nonce, signature } = schnorrSign(secret_key, hash);
97
- ```
1
+ # ootle-wasm
2
+
3
+ Rust → WASM library providing client-side crypto operations for Tari Ootle L2.
4
+
5
+ ## Architecture
6
+
7
+ - `core/` — Pure Rust library. All crypto/encoding logic lives here. Testable natively with `cargo test`.
8
+ - `wasm/` — Thin `wasm-bindgen` shell. Accepts JSON strings, calls core, returns results.
9
+
10
+ ## Prerequisites
11
+
12
+ ```bash
13
+ # Install wasm-pack
14
+ cargo install wasm-pack
15
+
16
+ # (Optional) Install wasm-opt for size optimisation
17
+ # macOS:
18
+ brew install binaryen
19
+ # or via cargo:
20
+ cargo install wasm-opt
21
+ ```
22
+
23
+ ## Build
24
+
25
+ ### Native (tests only)
26
+
27
+ ```bash
28
+ cargo test -p ootle-wasm-core
29
+ ```
30
+
31
+ ### WASM
32
+
33
+ ```bash
34
+ # Build for bundler (webpack, vite, rollup, esbuild)
35
+ wasm-pack build crates/ootle_wasm/wasm --target bundler --release --out-dir ../../../pkg
36
+
37
+ # Build for Node.js
38
+ wasm-pack build crates/ootle_wasm/wasm --target nodejs --release --out-dir ../../../pkg
39
+
40
+ # Build for web (no bundler)
41
+ wasm-pack build crates/ootle_wasm/wasm --target web --release --out-dir ../../../pkg
42
+ ```
43
+
44
+ The output goes to `pkg/` at the repo root containing:
45
+
46
+ - `ootle_wasm_bg.wasm` — the WASM binary
47
+ - `ootle_wasm.js` — JS glue code
48
+ - `ootle_wasm.d.ts` — TypeScript type definitions
49
+
50
+ ### Size optimisation (optional)
51
+
52
+ ```bash
53
+ wasm-opt -Oz --strip-debug --strip-producers pkg/ootle_wasm_bg.wasm -o pkg/ootle_wasm_bg.wasm
54
+ ```
55
+
56
+ ### Debug build (with panic hook)
57
+
58
+ ```bash
59
+ wasm-pack build crates/ootle_wasm/wasm --target bundler --dev --out-dir ../../../pkg -- --features debug
60
+ ```
61
+
62
+ ## WASM Exports
63
+
64
+ | Function | Signature | Description |
65
+ |---------------------------|-----------------------------------------------------------------------------|-----------------------------------------------------|
66
+ | `borEncodeTransaction` | `(transactionJson: string) → string` | BOR-encode a Transaction JSON → base64 envelope |
67
+ | `hashUnsignedTransaction` | `(unsignedTxJson: string, sealSignerPubKeyHex: string) → Uint8Array` | Hash an unsigned transaction for signing (64 bytes) |
68
+ | `schnorrSign` | `(secretKeyHex: string, message: Uint8Array) → { public_nonce, signature }` | Schnorr-sign a message |
69
+ | `generateKeypair` | `() → { secret_key, public_key }` | Generate a random Ristretto keypair |
70
+ | `publicKeyFromSecretKey` | `(secretKeyHex: string) → string` | Derive public key from secret key |
71
+
72
+ All keys and signatures are lowercase hex-encoded strings.
73
+
74
+ ## Usage from JS/TS
75
+
76
+ ```typescript
77
+ import init, {
78
+ generateKeypair,
79
+ schnorrSign,
80
+ hashUnsignedTransaction,
81
+ borEncodeTransaction,
82
+ publicKeyFromSecretKey,
83
+ } from './pkg/ootle_wasm.js';
84
+
85
+ // Initialise the WASM module
86
+ await init();
87
+
88
+ // Generate a keypair
89
+ const { secret_key, public_key } = generateKeypair();
90
+
91
+ // Hash an unsigned transaction for signing
92
+ const unsignedTxJson = JSON.stringify(unsignedTransaction);
93
+ const hash = hashUnsignedTransaction(unsignedTxJson, sealSignerPublicKeyHex);
94
+
95
+ // Sign the hash
96
+ const { public_nonce, signature } = schnorrSign(secret_key, hash);
97
+ ```
@@ -4,8 +4,8 @@
4
4
  "collaborators": [
5
5
  "The Tari Development Community"
6
6
  ],
7
- "description": "WASM bindings for Tari Ootle client-side crypto. LOCAL VENDOR PATCH: built from tari-ootle v0.49.2 plus chiron-0.49.2.patch (core/src/chiron.rs): createConfidentialWithdrawProofLiteral, burnClaimStealthSecret, validateBurnClaimOwnershipProof.",
8
- "version": "0.49.2-chiron.1",
7
+ "description": "WASM bindings for Tari Ootle client-side crypto. LOCAL VENDOR PATCH: built from tari-ootle v0.50.1 plus chiron-0.50.1.patch (core/src/chiron.rs): createConfidentialWithdrawProofLiteral, burnClaimStealthSecret, validateBurnClaimOwnershipProof.",
8
+ "version": "0.50.1-chiron.1",
9
9
  "license": "BSD-3-Clause",
10
10
  "repository": {
11
11
  "type": "git",