@chironbuilder/ootle-sdk 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/wallet.d.ts +31 -0
- package/dist/wallet.d.ts.map +1 -1
- package/dist/wallet.js +106 -1
- package/package.json +1 -1
package/dist/wallet.d.ts
CHANGED
|
@@ -387,6 +387,37 @@ export declare class OotleAccount implements WalletAccountApi {
|
|
|
387
387
|
withdrawStealthAndExecute(resourceAddress: string, amount: bigint, workspaceVarName: string, followUpInstructions: Instruction[], relatedComponents?: string[], maxFee?: bigint): Promise<{
|
|
388
388
|
transactionId: string;
|
|
389
389
|
}>;
|
|
390
|
+
/**
|
|
391
|
+
* Redeems one *specific, externally-known* stealth (freestanding) UTXO — a commitment this
|
|
392
|
+
* account was told about out of band (e.g. a ticket/ballot/voucher token some other party
|
|
393
|
+
* minted straight to this wallet's address), as opposed to `withdrawStealthAndExecute`'s
|
|
394
|
+
* *amount* drawn from this account's own tracked vault balance. Reveals the output's full
|
|
395
|
+
* value as a `Bucket` on the workspace under id `0`, then runs `followUpInstructions` (which
|
|
396
|
+
* must reference that bucket via `{Workspace: {id: 0, offset: null}}`) in the same signed
|
|
397
|
+
* transaction — e.g. handing it straight to a voting/redemption contract's own method.
|
|
398
|
+
*
|
|
399
|
+
* `revealedAmount` must be the output's *actual* value — there is no client-side way to
|
|
400
|
+
* discover it other than decrypting the UTXO (which this method's `WalletStealthAuthorizer`
|
|
401
|
+
* step does internally, using this account's own view secret, as part of resolving the
|
|
402
|
+
* spend); the caller is expected to already know it from whatever protocol minted the token
|
|
403
|
+
* (e.g. a fixed "amount-1 ballot" convention). A wrong value fails the balance proof inside
|
|
404
|
+
* `prepare()`, not silently.
|
|
405
|
+
*
|
|
406
|
+
* Bypasses the `StealthTransfer` fluent builder (its `spendStealthInput` targets *this
|
|
407
|
+
* account's own* previously-shielded outputs, tracked in local storage — see `unshield`'s doc
|
|
408
|
+
* comment on why no scan-by-commitment API exists for outputs this account never shielded
|
|
409
|
+
* itself) and instead hand-builds the same wire statement `unshield`/`shield`/
|
|
410
|
+
* `withdrawStealthAndExecute` produce via the builder, the same way the reference voter
|
|
411
|
+
* client for this pattern does (a zero-stealth-input-count, `KeyPath`-witnessed, fully-revealed
|
|
412
|
+
* transfer) — `WalletStealthAuthorizer.prepare()` fetches and unblinds the named commitment the
|
|
413
|
+
* same way regardless of which path built the statement.
|
|
414
|
+
*
|
|
415
|
+
* @param relatedComponents Every *other* component `followUpInstructions` touches — same
|
|
416
|
+
* reasoning as `withdrawStealthAndExecute`'s own parameter of the same name.
|
|
417
|
+
*/
|
|
418
|
+
redeemStealthOutputAndExecute(resourceAddress: string, commitmentHex: string, revealedAmount: bigint, followUpInstructions: Instruction[], relatedComponents?: string[], maxFee?: bigint): Promise<{
|
|
419
|
+
transactionId: string;
|
|
420
|
+
}>;
|
|
390
421
|
/**
|
|
391
422
|
* Funds an HTLC (hashed timelock contract): creates a stealth output for `amount` of
|
|
392
423
|
* `resourceAddress`, gated not by a normal one-time stealth key but by a two-leaf TIP-0006
|
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,
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,OAAO,EA0BR,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;AAYxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGxD,OAAO,K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AULT_ADDRESS, amountLiteral, createOutput, decryptOwnedUtxo, defaultIndexerUrl, getVaultIdsForAccount, resolveMaxEpoch, resolveTransaction, resourceAddressLiteral, sealTransaction, sendTransaction, signTransaction, stealthUtxoSubstateId, submitTransaction, } from "@tari-project/ootle";
|
|
1
|
+
import { Mask, OotleWallet, StealthInput, StealthInputsStatement, StealthOutputsStatement, StealthTransfer, StealthTransferStatement, TransactionBuilder, WalletStealthAuthorizer, WasmStealthCrypto, XTR_FAUCET_CLAIM_RESOURCE_ADDRESS, XTR_FAUCET_COMPONENT_ADDRESS, XTR_FAUCET_VAULT_ADDRESS, amountLiteral, createOutput, decryptOwnedUtxo, defaultIndexerUrl, getVaultIdsForAccount, resolveMaxEpoch, resolveTransaction, resourceAddressLiteral, sealTransaction, sendTransaction, 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, createConfidentialWithdrawProofLiteral, createStealthOutputWitness, parseOotleAddress, publicKeyFromSecretKey, schnorrSign, stealthDhSecret, validateStealthTransfer, } from "@tari-project/ootle-wasm";
|
|
@@ -993,6 +993,111 @@ export class OotleAccount {
|
|
|
993
993
|
await recordKnownVersions(response);
|
|
994
994
|
return { transactionId };
|
|
995
995
|
}
|
|
996
|
+
/**
|
|
997
|
+
* Redeems one *specific, externally-known* stealth (freestanding) UTXO — a commitment this
|
|
998
|
+
* account was told about out of band (e.g. a ticket/ballot/voucher token some other party
|
|
999
|
+
* minted straight to this wallet's address), as opposed to `withdrawStealthAndExecute`'s
|
|
1000
|
+
* *amount* drawn from this account's own tracked vault balance. Reveals the output's full
|
|
1001
|
+
* value as a `Bucket` on the workspace under id `0`, then runs `followUpInstructions` (which
|
|
1002
|
+
* must reference that bucket via `{Workspace: {id: 0, offset: null}}`) in the same signed
|
|
1003
|
+
* transaction — e.g. handing it straight to a voting/redemption contract's own method.
|
|
1004
|
+
*
|
|
1005
|
+
* `revealedAmount` must be the output's *actual* value — there is no client-side way to
|
|
1006
|
+
* discover it other than decrypting the UTXO (which this method's `WalletStealthAuthorizer`
|
|
1007
|
+
* step does internally, using this account's own view secret, as part of resolving the
|
|
1008
|
+
* spend); the caller is expected to already know it from whatever protocol minted the token
|
|
1009
|
+
* (e.g. a fixed "amount-1 ballot" convention). A wrong value fails the balance proof inside
|
|
1010
|
+
* `prepare()`, not silently.
|
|
1011
|
+
*
|
|
1012
|
+
* Bypasses the `StealthTransfer` fluent builder (its `spendStealthInput` targets *this
|
|
1013
|
+
* account's own* previously-shielded outputs, tracked in local storage — see `unshield`'s doc
|
|
1014
|
+
* comment on why no scan-by-commitment API exists for outputs this account never shielded
|
|
1015
|
+
* itself) and instead hand-builds the same wire statement `unshield`/`shield`/
|
|
1016
|
+
* `withdrawStealthAndExecute` produce via the builder, the same way the reference voter
|
|
1017
|
+
* client for this pattern does (a zero-stealth-input-count, `KeyPath`-witnessed, fully-revealed
|
|
1018
|
+
* transfer) — `WalletStealthAuthorizer.prepare()` fetches and unblinds the named commitment the
|
|
1019
|
+
* same way regardless of which path built the statement.
|
|
1020
|
+
*
|
|
1021
|
+
* @param relatedComponents Every *other* component `followUpInstructions` touches — same
|
|
1022
|
+
* reasoning as `withdrawStealthAndExecute`'s own parameter of the same name.
|
|
1023
|
+
*/
|
|
1024
|
+
async redeemStealthOutputAndExecute(resourceAddress, commitmentHex, revealedAmount, followUpInstructions, relatedComponents = [], maxFee = 100000n) {
|
|
1025
|
+
if (revealedAmount <= 0n) {
|
|
1026
|
+
throw new Error(`redeemStealthOutputAndExecute: revealedAmount must be > 0, got ${revealedAmount}`);
|
|
1027
|
+
}
|
|
1028
|
+
if (!/^[0-9a-f]{64}$/i.test(commitmentHex)) {
|
|
1029
|
+
throw new Error(`redeemStealthOutputAndExecute: commitmentHex must be exactly 64 hex characters (32 bytes)`);
|
|
1030
|
+
}
|
|
1031
|
+
const provider = await this.getProvider();
|
|
1032
|
+
const account = await this.getComponentAddress();
|
|
1033
|
+
const commitment = fromHex(commitmentHex);
|
|
1034
|
+
// An "incomplete" statement: the input side only names the commitment being spent (its mask
|
|
1035
|
+
// and value are recovered later, by the authorizer, from the on-chain UTXO) and declares a
|
|
1036
|
+
// `KeyPath` witness — ordinary one-time-key ownership, the same proof shield/unshield/
|
|
1037
|
+
// withdrawStealthAndExecute use, as opposed to htlcClaim/htlcRefund's script-path leaf. The
|
|
1038
|
+
// output side is empty (no new stealth output at all): the full value is revealed instead.
|
|
1039
|
+
const inputsJson = JSON.stringify({
|
|
1040
|
+
inputs: [{ commitment: commitmentHex, witness: "KeyPath" }],
|
|
1041
|
+
revealed_amount: "0",
|
|
1042
|
+
});
|
|
1043
|
+
const outputsJson = JSON.stringify({
|
|
1044
|
+
outputs: [],
|
|
1045
|
+
revealed_output_amount: revealedAmount.toString(),
|
|
1046
|
+
agg_range_proof: "",
|
|
1047
|
+
});
|
|
1048
|
+
const statement = new StealthTransferStatement(new StealthInputsStatement([], 0n, inputsJson), new StealthOutputsStatement(outputsJson));
|
|
1049
|
+
const maxEpoch = await resolveMaxEpoch(provider);
|
|
1050
|
+
const builder = TransactionBuilder.new(this.network, maxEpoch)
|
|
1051
|
+
.addInstruction({
|
|
1052
|
+
StealthTransfer: {
|
|
1053
|
+
resource_address_ref: { Address: resourceAddress },
|
|
1054
|
+
statement: { __ootleRawJson: statement.toCompactJson() },
|
|
1055
|
+
revealed_input_bucket: null,
|
|
1056
|
+
},
|
|
1057
|
+
})
|
|
1058
|
+
// Claims workspace id 0 for the revealed bucket above — followUpInstructions must reference
|
|
1059
|
+
// it as a plain numeric `{Workspace: {id: 0, offset: null}}`, not a named `{Workspace: ".."}`
|
|
1060
|
+
// (name resolution only applies to instructions built through *this* same chain; raw
|
|
1061
|
+
// pre-built instructions bypass it, same constraint `withdrawStealthAndExecute` documents).
|
|
1062
|
+
.saveVar("redeemed")
|
|
1063
|
+
.withInstructions(followUpInstructions)
|
|
1064
|
+
.feeTransactionPayFromComponent(account, maxFee)
|
|
1065
|
+
.addInput({ substate_id: resourceAddress, version: null })
|
|
1066
|
+
.addInput({ substate_id: stealthUtxoSubstateId(resourceAddress, commitment), version: null })
|
|
1067
|
+
.addInput({ substate_id: account, version: null });
|
|
1068
|
+
for (const vaultId of await getVaultIdsForAccount(provider, account)) {
|
|
1069
|
+
builder.addInput({ substate_id: vaultId, version: null });
|
|
1070
|
+
}
|
|
1071
|
+
for (const component of relatedComponents) {
|
|
1072
|
+
builder.addInput({ substate_id: component, version: null });
|
|
1073
|
+
for (const vaultId of await getVaultIdsForAccount(provider, component)) {
|
|
1074
|
+
builder.addInput({ substate_id: vaultId, version: null });
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
const unsignedTx = await resolveTransaction(provider, builder.buildUnsignedTransaction());
|
|
1078
|
+
const spec = {
|
|
1079
|
+
unsignedTx,
|
|
1080
|
+
statement,
|
|
1081
|
+
outputMask: Mask.zero(),
|
|
1082
|
+
state: {
|
|
1083
|
+
resource: resourceAddress,
|
|
1084
|
+
revealedInput: null,
|
|
1085
|
+
inputsToSpend: new Map([[commitmentHex, { input: new StealthInput(commitment), owner: account }]]),
|
|
1086
|
+
outputs: [],
|
|
1087
|
+
revealedOutputAmount: revealedAmount,
|
|
1088
|
+
},
|
|
1089
|
+
requiredSigners: [account],
|
|
1090
|
+
inputs: [{ input: new StealthInput(commitment), owner: account }],
|
|
1091
|
+
};
|
|
1092
|
+
const wallet = new OotleWallet().registerKeyProvider(account, this.signer).setDefaultSigner(account);
|
|
1093
|
+
const viewSecret = await this.signer.getViewSecret();
|
|
1094
|
+
const authorized = await WalletStealthAuthorizer.fromSpec(wallet, spec, { viewSecret, crypto: new WasmStealthCrypto(this.network) }).prepare(provider);
|
|
1095
|
+
const envelope = await authorized.seal();
|
|
1096
|
+
const transactionId = await submitTransaction(provider, envelope);
|
|
1097
|
+
const response = await withTimeout(pollTransactionResult(provider, transactionId), 60_000, "submitting the redemption transaction");
|
|
1098
|
+
await recordKnownVersions(response);
|
|
1099
|
+
return { transactionId };
|
|
1100
|
+
}
|
|
996
1101
|
/**
|
|
997
1102
|
* Funds an HTLC (hashed timelock contract): creates a stealth output for `amount` of
|
|
998
1103
|
* `resourceAddress`, gated not by a normal one-time stealth key but by a two-leaf TIP-0006
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chironbuilder/ootle-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
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",
|