@arkade-os/sdk 0.4.46 → 0.4.47
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/adapters/expo.cjs +5 -5
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +3 -3
- package/dist/adapters/indexedDB.cjs +5 -5
- package/dist/adapters/indexedDB.js +4 -4
- package/dist/{ark-C9ognsOV.d.cts → ark-CoJgwTi_.d.cts} +26 -2
- package/dist/{ark-C9ognsOV.d.ts → ark-CoJgwTi_.d.ts} +26 -2
- package/dist/{asyncStorageTaskQueue-CmBYVlxw.d.cts → asyncStorageTaskQueue-Dowyo59a.d.cts} +2 -2
- package/dist/{asyncStorageTaskQueue-BAKZ5cS5.d.ts → asyncStorageTaskQueue-Z3aFoXCl.d.ts} +2 -2
- package/dist/{chunk-R2SVAM5Q.js → chunk-3N5I6GT6.js} +3 -3
- package/dist/{chunk-R2SVAM5Q.js.map → chunk-3N5I6GT6.js.map} +1 -1
- package/dist/{chunk-JTCQ6QXQ.js → chunk-AJQ4AOT3.js} +4 -4
- package/dist/{chunk-JTCQ6QXQ.js.map → chunk-AJQ4AOT3.js.map} +1 -1
- package/dist/{chunk-FWG4TSPN.js → chunk-C7TXXTMS.js} +4 -5
- package/dist/chunk-C7TXXTMS.js.map +1 -0
- package/dist/{chunk-CWJ7ZCP7.js → chunk-CDDWXBEM.js} +87 -16
- package/dist/chunk-CDDWXBEM.js.map +1 -0
- package/dist/{chunk-7IYIFMF4.cjs → chunk-HHV5FPC6.cjs} +94 -20
- package/dist/chunk-HHV5FPC6.cjs.map +1 -0
- package/dist/{chunk-SOXGAA52.cjs → chunk-JAYOXOLT.cjs} +14 -14
- package/dist/{chunk-SOXGAA52.cjs.map → chunk-JAYOXOLT.cjs.map} +1 -1
- package/dist/{chunk-MQB5H4X5.cjs → chunk-L5ND2FJJ.cjs} +4 -5
- package/dist/chunk-L5ND2FJJ.cjs.map +1 -0
- package/dist/{chunk-P6VBP3CT.js → chunk-OCS5S3L3.js} +1010 -98
- package/dist/chunk-OCS5S3L3.js.map +1 -0
- package/dist/chunk-RQSA7ADZ.cjs +2286 -0
- package/dist/chunk-RQSA7ADZ.cjs.map +1 -0
- package/dist/{chunk-6TQJOD72.cjs → chunk-VE67GMGM.cjs} +7 -7
- package/dist/{chunk-6TQJOD72.cjs.map → chunk-VE67GMGM.cjs.map} +1 -1
- package/dist/{chunk-D46YDM36.cjs → chunk-WTTLIFS7.cjs} +1207 -285
- package/dist/chunk-WTTLIFS7.cjs.map +1 -0
- package/dist/chunk-XN3554FT.js +2244 -0
- package/dist/chunk-XN3554FT.js.map +1 -0
- package/dist/contracts/handlers/index.cjs +11 -7
- package/dist/contracts/handlers/index.d.cts +3 -3
- package/dist/contracts/handlers/index.d.ts +3 -3
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/{delegate-aOd5qINr.d.ts → delegate-CuaDqqQi.d.ts} +1 -1
- package/dist/{delegate-DVEgyRwI.d.cts → delegate-Dl87_zMA.d.cts} +1 -1
- package/dist/index-BC_G0VTh.d.cts +512 -0
- package/dist/index-CKwpZEpw.d.ts +512 -0
- package/dist/index.cjs +213 -161
- package/dist/index.d.cts +3097 -2090
- package/dist/index.d.ts +3097 -2090
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +19 -19
- package/dist/repositories/realm/index.d.cts +2 -2
- package/dist/repositories/realm/index.d.ts +2 -2
- package/dist/repositories/realm/index.js +5 -5
- package/dist/repositories/sqlite/index.cjs +18 -18
- package/dist/repositories/sqlite/index.d.cts +2 -2
- package/dist/repositories/sqlite/index.d.ts +2 -2
- package/dist/repositories/sqlite/index.js +5 -5
- package/dist/{taskRunner-B48-V-Pb.d.ts → taskRunner-Dz-TI4Rb.d.ts} +2 -2
- package/dist/{taskRunner-nNecmQ2C.d.cts → taskRunner-Dz47k0lp.d.cts} +2 -2
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/index.cjs +14 -14
- package/dist/wallet/expo/index.d.cts +4 -4
- package/dist/wallet/expo/index.d.ts +4 -4
- package/dist/wallet/expo/index.js +5 -5
- package/dist/{wallet-BUg3D4WJ.d.cts → wallet-Oxz_wLxo.d.cts} +13 -3
- package/dist/{wallet-DM0oShTu.d.ts → wallet-x7egmXq6.d.ts} +13 -3
- package/dist/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +5 -5
- package/package.json +1 -1
- package/dist/chunk-4KXOCVXP.cjs +0 -973
- package/dist/chunk-4KXOCVXP.cjs.map +0 -1
- package/dist/chunk-7IYIFMF4.cjs.map +0 -1
- package/dist/chunk-CWJ7ZCP7.js.map +0 -1
- package/dist/chunk-D46YDM36.cjs.map +0 -1
- package/dist/chunk-FWG4TSPN.js.map +0 -1
- package/dist/chunk-MQB5H4X5.cjs.map +0 -1
- package/dist/chunk-P6VBP3CT.js.map +0 -1
- package/dist/chunk-QKC2T54O.js +0 -960
- package/dist/chunk-QKC2T54O.js.map +0 -1
- package/dist/index-CPzL4tqg.d.ts +0 -259
- package/dist/index-D8vmtWWO.d.cts +0 -259
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../../chunk-
|
|
3
|
+
var chunkRQSA7ADZ_cjs = require('../../chunk-RQSA7ADZ.cjs');
|
|
4
|
+
require('../../chunk-L5ND2FJJ.cjs');
|
|
5
5
|
require('../../chunk-5BLDMQED.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
Object.defineProperty(exports, "ArkadeContractHandler", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return chunkRQSA7ADZ_cjs.ArkadeContractHandler; }
|
|
12
|
+
});
|
|
9
13
|
Object.defineProperty(exports, "BoardingContractHandler", {
|
|
10
14
|
enumerable: true,
|
|
11
|
-
get: function () { return
|
|
15
|
+
get: function () { return chunkRQSA7ADZ_cjs.BoardingContractHandler; }
|
|
12
16
|
});
|
|
13
17
|
Object.defineProperty(exports, "DefaultContractHandler", {
|
|
14
18
|
enumerable: true,
|
|
15
|
-
get: function () { return
|
|
19
|
+
get: function () { return chunkRQSA7ADZ_cjs.DefaultContractHandler; }
|
|
16
20
|
});
|
|
17
21
|
Object.defineProperty(exports, "DelegateContractHandler", {
|
|
18
22
|
enumerable: true,
|
|
19
|
-
get: function () { return
|
|
23
|
+
get: function () { return chunkRQSA7ADZ_cjs.DelegateContractHandler; }
|
|
20
24
|
});
|
|
21
25
|
Object.defineProperty(exports, "VHTLCContractHandler", {
|
|
22
26
|
enumerable: true,
|
|
23
|
-
get: function () { return
|
|
27
|
+
get: function () { return chunkRQSA7ADZ_cjs.VHTLCContractHandler; }
|
|
24
28
|
});
|
|
25
29
|
Object.defineProperty(exports, "contractHandlers", {
|
|
26
30
|
enumerable: true,
|
|
27
|
-
get: function () { return
|
|
31
|
+
get: function () { return chunkRQSA7ADZ_cjs.contractHandlers; }
|
|
28
32
|
});
|
|
29
33
|
//# sourceMappingURL=index.cjs.map
|
|
30
34
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { B as BoardingContractHandler,
|
|
2
|
-
import '../../ark-
|
|
1
|
+
export { n as ArkadeContractHandler, B as BoardingContractHandler, o as BoardingContractParams, D as DefaultContractHandler, q as DefaultContractParams, t as DelegateContractHandler, u as DelegateContractParams, x as VHTLCContractHandler, y as VHTLCContractParams, z as contractHandlers } from '../../index-BC_G0VTh.cjs';
|
|
2
|
+
import '../../ark-CoJgwTi_.cjs';
|
|
3
3
|
import '@scure/btc-signer/transaction.js';
|
|
4
4
|
import '@scure/btc-signer/utils.js';
|
|
5
5
|
import '@scure/btc-signer/psbt.js';
|
|
6
6
|
import '@scure/btc-signer';
|
|
7
|
-
import '../../delegate-
|
|
7
|
+
import '../../delegate-Dl87_zMA.cjs';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { B as BoardingContractHandler,
|
|
2
|
-
import '../../ark-
|
|
1
|
+
export { n as ArkadeContractHandler, B as BoardingContractHandler, o as BoardingContractParams, D as DefaultContractHandler, q as DefaultContractParams, t as DelegateContractHandler, u as DelegateContractParams, x as VHTLCContractHandler, y as VHTLCContractParams, z as contractHandlers } from '../../index-CKwpZEpw.js';
|
|
2
|
+
import '../../ark-CoJgwTi_.js';
|
|
3
3
|
import '@scure/btc-signer/transaction.js';
|
|
4
4
|
import '@scure/btc-signer/utils.js';
|
|
5
5
|
import '@scure/btc-signer/psbt.js';
|
|
6
6
|
import '@scure/btc-signer';
|
|
7
|
-
import '../../delegate-
|
|
7
|
+
import '../../delegate-CuaDqqQi.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { BoardingContractHandler, DefaultContractHandler, DelegateContractHandler, VHTLCContractHandler, contractHandlers } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
1
|
+
export { ArkadeContractHandler, BoardingContractHandler, DefaultContractHandler, DelegateContractHandler, VHTLCContractHandler, contractHandlers } from '../../chunk-XN3554FT.js';
|
|
2
|
+
import '../../chunk-C7TXXTMS.js';
|
|
3
3
|
import '../../chunk-NSBPE2FW.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Bytes } from '@scure/btc-signer/utils.js';
|
|
2
|
-
import { q as RelativeTimelock, V as VtxoScript, r as TapLeafScript } from './ark-
|
|
2
|
+
import { q as RelativeTimelock, V as VtxoScript, r as TapLeafScript } from './ark-CoJgwTi_.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* DefaultVtxo is the default implementation of a VtxoScript.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Bytes } from '@scure/btc-signer/utils.js';
|
|
2
|
-
import { q as RelativeTimelock, V as VtxoScript, r as TapLeafScript } from './ark-
|
|
2
|
+
import { q as RelativeTimelock, V as VtxoScript, r as TapLeafScript } from './ark-CoJgwTi_.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* DefaultVtxo is the default implementation of a VtxoScript.
|
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
import { q as RelativeTimelock, V as VtxoScript, r as TapLeafScript, b3 as ContractHandler, bf as Discoverable, ck as TapscriptDeriving } from './ark-CoJgwTi_.cjs';
|
|
2
|
+
import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-Dl87_zMA.cjs';
|
|
3
|
+
import { Bytes } from '@scure/btc-signer/utils.js';
|
|
4
|
+
|
|
5
|
+
/** Virtual Hash Time Lock Contract (VHTLC) namespace. */
|
|
6
|
+
declare namespace VHTLC {
|
|
7
|
+
interface Options {
|
|
8
|
+
sender: Bytes;
|
|
9
|
+
receiver: Bytes;
|
|
10
|
+
server: Bytes;
|
|
11
|
+
preimageHash: Bytes;
|
|
12
|
+
refundLocktime: bigint;
|
|
13
|
+
unilateralClaimDelay: RelativeTimelock;
|
|
14
|
+
unilateralRefundDelay: RelativeTimelock;
|
|
15
|
+
unilateralRefundWithoutReceiverDelay: RelativeTimelock;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Virtual Hash Time Lock Contract (VHTLC) script implementation.
|
|
19
|
+
*
|
|
20
|
+
* VHTLC enables atomic swaps and conditional payments in the Arkade protocol.
|
|
21
|
+
* It provides multiple spending paths:
|
|
22
|
+
*
|
|
23
|
+
* - **claim**: Receiver can claim funds by revealing the preimage
|
|
24
|
+
* - **refund**: Sender and receiver can collaboratively refund
|
|
25
|
+
* - **refundWithoutReceiver**: Sender can refund after locktime expires
|
|
26
|
+
* - **unilateralClaim**: Receiver can claim unilaterally after delay
|
|
27
|
+
* - **unilateralRefund**: Sender and receiver can refund unilaterally after delay
|
|
28
|
+
* - **unilateralRefundWithoutReceiver**: Sender can refund unilaterally after delay
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const vhtlc = new VHTLC.Script({
|
|
33
|
+
* sender: alicePubKey,
|
|
34
|
+
* receiver: bobPubKey,
|
|
35
|
+
* server: serverPubKey,
|
|
36
|
+
* preimageHash: hash160(secret),
|
|
37
|
+
* refundLocktime: BigInt(chainTip + 10),
|
|
38
|
+
* unilateralClaimDelay: { type: 'blocks', value: 100n },
|
|
39
|
+
* unilateralRefundDelay: { type: 'blocks', value: 102n },
|
|
40
|
+
* unilateralRefundWithoutReceiverDelay: { type: 'blocks', value: 103n }
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
class Script extends VtxoScript {
|
|
45
|
+
readonly options: Options;
|
|
46
|
+
readonly claimScript: string;
|
|
47
|
+
readonly refundScript: string;
|
|
48
|
+
readonly refundWithoutReceiverScript: string;
|
|
49
|
+
readonly unilateralClaimScript: string;
|
|
50
|
+
readonly unilateralRefundScript: string;
|
|
51
|
+
readonly unilateralRefundWithoutReceiverScript: string;
|
|
52
|
+
/** Create a VHTLC script from the supplied participant keys, hash, and timelocks. */
|
|
53
|
+
constructor(options: Options);
|
|
54
|
+
/** Return the collaborative claim tapleaf script. */
|
|
55
|
+
claim(): TapLeafScript;
|
|
56
|
+
/** Return the collaborative refund tapleaf script. */
|
|
57
|
+
refund(): TapLeafScript;
|
|
58
|
+
/** Return the refund-without-receiver tapleaf script. */
|
|
59
|
+
refundWithoutReceiver(): TapLeafScript;
|
|
60
|
+
/** Return the unilateral claim tapleaf script. */
|
|
61
|
+
unilateralClaim(): TapLeafScript;
|
|
62
|
+
/** Return the unilateral refund tapleaf script. */
|
|
63
|
+
unilateralRefund(): TapLeafScript;
|
|
64
|
+
/** Return the unilateral refund-without-receiver tapleaf script. */
|
|
65
|
+
unilateralRefundWithoutReceiver(): TapLeafScript;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Registry for contract handlers.
|
|
71
|
+
*
|
|
72
|
+
* Each contract type ("default", "vhtlc", etc.) has a handler that knows
|
|
73
|
+
* how to create VtxoScripts, serialize params, and select spending paths.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* // Register a custom handler
|
|
78
|
+
* contractHandlers.register(myCustomHandler);
|
|
79
|
+
*
|
|
80
|
+
* // Get handler for a type
|
|
81
|
+
* const handler = contractHandlers.get("vhtlc");
|
|
82
|
+
* const script = handler.createScript(contract.params);
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
declare class ContractHandlerRegistry {
|
|
86
|
+
private handlers;
|
|
87
|
+
/**
|
|
88
|
+
* Register a contract handler.
|
|
89
|
+
*
|
|
90
|
+
* @param handler - The handler to register
|
|
91
|
+
* @throws If a handler for this type is already registered
|
|
92
|
+
*/
|
|
93
|
+
register(handler: ContractHandler<unknown>): void;
|
|
94
|
+
/**
|
|
95
|
+
* Get a handler by type.
|
|
96
|
+
*
|
|
97
|
+
* @param type - The contract type
|
|
98
|
+
* @returns The handler, or undefined if not found
|
|
99
|
+
*/
|
|
100
|
+
get(type: string): ContractHandler<unknown> | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* Get a handler by type, throwing if not found.
|
|
103
|
+
*
|
|
104
|
+
* @param type - The contract type
|
|
105
|
+
* @returns The handler
|
|
106
|
+
* @throws If no handler is registered for this type
|
|
107
|
+
*/
|
|
108
|
+
getOrThrow(type: string): ContractHandler<unknown>;
|
|
109
|
+
/**
|
|
110
|
+
* Check if a handler is registered.
|
|
111
|
+
*
|
|
112
|
+
* @param type - The contract type
|
|
113
|
+
*/
|
|
114
|
+
has(type: string): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Get all registered types.
|
|
117
|
+
*/
|
|
118
|
+
getRegisteredTypes(): string[];
|
|
119
|
+
/**
|
|
120
|
+
* Unregister a handler (mainly for testing).
|
|
121
|
+
*/
|
|
122
|
+
unregister(type: string): boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Clear all handlers (mainly for testing).
|
|
125
|
+
*/
|
|
126
|
+
clear(): void;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Global registry of contract handlers.
|
|
130
|
+
*/
|
|
131
|
+
declare const contractHandlers: ContractHandlerRegistry;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Typed parameters for DefaultVtxo contracts.
|
|
135
|
+
*/
|
|
136
|
+
interface DefaultContractParams {
|
|
137
|
+
pubKey: Uint8Array;
|
|
138
|
+
serverPubKey: Uint8Array;
|
|
139
|
+
csvTimelock: RelativeTimelock;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Handler for default wallet VTXOs.
|
|
143
|
+
*
|
|
144
|
+
* Default contracts use the standard forfeit + exit tapscript:
|
|
145
|
+
* - forfeit: (Alice + Server) multisig for collaborative spending
|
|
146
|
+
* - exit: (Alice) + CSV timelock for unilateral exit
|
|
147
|
+
*/
|
|
148
|
+
declare const DefaultContractHandler: ContractHandler<DefaultContractParams, DefaultVtxo.Script> & Discoverable;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Typed parameters for DelegateVtxo contracts.
|
|
152
|
+
*/
|
|
153
|
+
interface DelegateContractParams {
|
|
154
|
+
pubKey: Uint8Array;
|
|
155
|
+
serverPubKey: Uint8Array;
|
|
156
|
+
delegatePubKey: Uint8Array;
|
|
157
|
+
csvTimelock: RelativeTimelock;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Handler for delegate wallet virtual outputs.
|
|
161
|
+
*
|
|
162
|
+
* Delegate contracts extend the default tapscript with an additional delegate path:
|
|
163
|
+
* - forfeit: (Alice + Server) multisig for collaborative spending
|
|
164
|
+
* - exit: (Alice) + CSV timelock for unilateral exit
|
|
165
|
+
* - delegate: (Alice + Delegate + Server) multisig for delegated renewal
|
|
166
|
+
*/
|
|
167
|
+
declare const DelegateContractHandler: ContractHandler<DelegateContractParams, DelegateVtxo.Script> & Discoverable;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Typed parameters for VHTLC contracts.
|
|
171
|
+
*/
|
|
172
|
+
interface VHTLCContractParams {
|
|
173
|
+
sender: Uint8Array;
|
|
174
|
+
receiver: Uint8Array;
|
|
175
|
+
server: Uint8Array;
|
|
176
|
+
preimageHash: Uint8Array;
|
|
177
|
+
refundLocktime: bigint;
|
|
178
|
+
unilateralClaimDelay: RelativeTimelock;
|
|
179
|
+
unilateralRefundDelay: RelativeTimelock;
|
|
180
|
+
unilateralRefundWithoutReceiverDelay: RelativeTimelock;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Handler for Virtual Hash Time Lock Contract (VHTLC).
|
|
184
|
+
*
|
|
185
|
+
* VHTLC supports multiple spending paths:
|
|
186
|
+
*
|
|
187
|
+
* Collaborative paths (with server):
|
|
188
|
+
* - claim: Receiver + Server with preimage
|
|
189
|
+
* - refund: Sender + Receiver + Server
|
|
190
|
+
* - refundWithoutReceiver: Sender + Server after CLTV locktime
|
|
191
|
+
*
|
|
192
|
+
* Unilateral paths (without server):
|
|
193
|
+
* - unilateralClaim: Receiver with preimage after CSV delay
|
|
194
|
+
* - unilateralRefund: Sender + Receiver after CSV delay
|
|
195
|
+
* - unilateralRefundWithoutReceiver: Sender after CSV delay
|
|
196
|
+
*/
|
|
197
|
+
declare const VHTLCContractHandler: ContractHandler<VHTLCContractParams, VHTLC.Script>;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Typed parameters for boarding contracts.
|
|
201
|
+
*
|
|
202
|
+
* Boarding reuses the exact `default` contract parameter shape
|
|
203
|
+
* (`pubKey` / `serverPubKey` / `csvTimelock`) rather than inventing
|
|
204
|
+
* boarding-specific names — the boarding semantics come from the
|
|
205
|
+
* contract type and from populating `csvTimelock` with the server's
|
|
206
|
+
* boarding-exit delay (`ArkInfo.boardingExitDelay`) instead of the
|
|
207
|
+
* offchain unilateral-exit delay.
|
|
208
|
+
*/
|
|
209
|
+
type BoardingContractParams = DefaultContractParams;
|
|
210
|
+
/**
|
|
211
|
+
* Handler for the boarding contract (registered type `boarding`).
|
|
212
|
+
*
|
|
213
|
+
* The boarding contract derives the on-chain Bitcoin address used to
|
|
214
|
+
* board funds onto Arkade. It shares the exact `DefaultVtxo.Script`
|
|
215
|
+
* shape with the `default` contract — a Taproot output co-owned by the
|
|
216
|
+
* wallet and the Ark server, with a CSV exit path back to the wallet —
|
|
217
|
+
* and therefore reuses the `default` handler's path logic (forfeit via
|
|
218
|
+
* server cooperation, exit after the boarding CSV).
|
|
219
|
+
*
|
|
220
|
+
* Boarding semantics come entirely from the contract type and from
|
|
221
|
+
* sourcing the CSV timelock from the server's boarding-exit delay
|
|
222
|
+
* (`ArkInfo.boardingExitDelay`), not from renamed parameters. The
|
|
223
|
+
* offchain `default` contract is built from `ArkInfo.unilateralExitDelay`
|
|
224
|
+
* instead, so the two share a script shape but differ in their CSV
|
|
225
|
+
* timelock value. Parameters round-trip through the same
|
|
226
|
+
* `timelockToSequence` / `sequenceToTimelock` helpers and BIP68 sequence
|
|
227
|
+
* encoding as `default` / `delegate`.
|
|
228
|
+
*
|
|
229
|
+
* Like `default` / `delegate`, the boarding handler implements
|
|
230
|
+
* {@link Discoverable.discoverAt} so `wallet.restore()` can rediscover
|
|
231
|
+
* used boarding indices from authoritative on-chain data. It differs from
|
|
232
|
+
* the L2 handlers in its source of truth: boarding probes the **on-chain**
|
|
233
|
+
* UTXO set at its P2TR address (`OnchainProvider.getCoins`) rather than the
|
|
234
|
+
* Ark indexer, and builds its candidate from the boarding-exit CSV
|
|
235
|
+
* (`deps.boardingTimelock`). When boarding discovery is not plumbed (no
|
|
236
|
+
* `deps.boardingTimelock` / `deps.onchainNetwork`) `discoverAt` no-ops.
|
|
237
|
+
*
|
|
238
|
+
* Identity & the default/boarding collision: a contract's `script` (pkScript)
|
|
239
|
+
* is its unique identity — a script owns exactly one repository row. `boarding`
|
|
240
|
+
* is a first-class type with its own row **when its script is distinct** from
|
|
241
|
+
* the wallet's `default` baseline — the real-world case, since a sound Ark
|
|
242
|
+
* server keeps boardingExitDelay strictly longer than unilateralExitDelay (equal
|
|
243
|
+
* delays would expose the provider to a double-spend). Should those delays ever
|
|
244
|
+
* coincide (a misconfigured/malicious server), the boarding script is
|
|
245
|
+
* byte-identical to the default script. `discoverAt` does NOT pre-coalesce that
|
|
246
|
+
* collision: it always emits `type: "boarding"`, and the single shared row is
|
|
247
|
+
* resolved FIRST-WINS at the persistence layer
|
|
248
|
+
* ({@link ContractManager.upsertContract}) — whichever purpose is persisted
|
|
249
|
+
* first keeps the row, and the scan deliberately probes boarding first
|
|
250
|
+
* (see docs/hd-wallets_onchain_rotation_collision_fix.md §5.1–5.2). Either way
|
|
251
|
+
* the funds are equally spendable through the shared `DefaultVtxo.Script` paths.
|
|
252
|
+
* Consumers must NOT rely on `contract.type === "boarding"` to identify the
|
|
253
|
+
* boarding purpose — resolve the boarding script via
|
|
254
|
+
* `wallet.getBoardingAddress()` / `wallet.boardingTapscript` (which never depend
|
|
255
|
+
* on the persisted contract's type) and match by script when needed.
|
|
256
|
+
*/
|
|
257
|
+
declare const BoardingContractHandler: ContractHandler<BoardingContractParams, DefaultVtxo.Script> & Discoverable;
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Arkade Program model & compiler.
|
|
261
|
+
*
|
|
262
|
+
* A {@link Program} is the artifact shape shared with the ArkadeScript
|
|
263
|
+
* compiler: named functions, each split into a `tapscript` segment enforced
|
|
264
|
+
* on-chain and an optional `arkadeScript` segment emulated by the co-signing
|
|
265
|
+
* service. This module owns everything that is *pure data → script*:
|
|
266
|
+
*
|
|
267
|
+
* - the Program/segment/token types,
|
|
268
|
+
* - `$param` resolution ({@link resolveAsm}), witness and timelock resolution,
|
|
269
|
+
* - program validation ({@link validateProgram}) — typed constructor params
|
|
270
|
+
* are authoritative when present,
|
|
271
|
+
* - {@link ArkadeProgramScript} — a {@link VtxoScript} compiled from a
|
|
272
|
+
* program, its constructor args and the signer keys,
|
|
273
|
+
* - artifact JSON (de)serialization ({@link parseArtifact} /
|
|
274
|
+
* {@link stringifyArtifact}) and the string-keyed contract params used to
|
|
275
|
+
* persist a program contract through the `src/contracts` pipeline.
|
|
276
|
+
*
|
|
277
|
+
* Keeping this free of provider/transaction imports lets the generic
|
|
278
|
+
* `arkade` contract handler (src/contracts/handlers/arkade.ts) and the
|
|
279
|
+
* high-level `ArkadeContract` client share one compilation path.
|
|
280
|
+
*
|
|
281
|
+
* @module arkade/program
|
|
282
|
+
*/
|
|
283
|
+
|
|
284
|
+
/** A token in an `asm` array: an opcode name, a number/bigint push, raw bytes, or a `$param` placeholder. */
|
|
285
|
+
type AsmToken = string | number | bigint | Uint8Array;
|
|
286
|
+
/** A constructor argument or resolved value. */
|
|
287
|
+
type ArkadeParamValue = Uint8Array | bigint | number;
|
|
288
|
+
/** A function call argument (function input). */
|
|
289
|
+
type ArkadeArgValue = Uint8Array | bigint | number;
|
|
290
|
+
/**
|
|
291
|
+
* The declared type of a function input, used to derive the static TS type of
|
|
292
|
+
* the corresponding `functions.<name>(...)` argument. Byte-like types map to
|
|
293
|
+
* `Uint8Array`; `int` maps to `bigint | number`.
|
|
294
|
+
*/
|
|
295
|
+
type ArkadeArgType = "bytes" | "pubkey" | "sig" | "hash" | "int";
|
|
296
|
+
/**
|
|
297
|
+
* Maps an {@link ArkadeArgType} to its TypeScript argument type.
|
|
298
|
+
* @internal
|
|
299
|
+
*/
|
|
300
|
+
interface ArkadeValueType {
|
|
301
|
+
bytes: Uint8Array;
|
|
302
|
+
pubkey: Uint8Array;
|
|
303
|
+
sig: Uint8Array;
|
|
304
|
+
hash: Uint8Array;
|
|
305
|
+
int: bigint | number;
|
|
306
|
+
}
|
|
307
|
+
/** A typed function input or constructor param: a name plus its {@link ArkadeArgType}. */
|
|
308
|
+
interface InputDef {
|
|
309
|
+
name: string;
|
|
310
|
+
type: ArkadeArgType;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* A function input or constructor param declaration: either a typed descriptor
|
|
314
|
+
* `{ name, type }` (the argument is statically typed and its bound value is
|
|
315
|
+
* validated) or a bare name string (the argument falls back to the loose
|
|
316
|
+
* {@link ArkadeArgValue}).
|
|
317
|
+
*/
|
|
318
|
+
type InputRef = string | InputDef;
|
|
319
|
+
/** Reference to a signer key: a `"$param"` reference or literal x-only bytes. */
|
|
320
|
+
type SignerRef = string | Uint8Array;
|
|
321
|
+
/** A witness-stack item: a function-input name, a `"$param"`, a literal number/bigint (minimal script-num), or raw bytes. */
|
|
322
|
+
type WitnessRef = string | number | bigint | Uint8Array;
|
|
323
|
+
/** Bitcoin Script segment of a spending path — enforced on-chain. */
|
|
324
|
+
interface TapscriptSegment {
|
|
325
|
+
/** Required signers. The tweaked co-signer is appended automatically when the path has an `arkadeScript`. */
|
|
326
|
+
signers: SignerRef[];
|
|
327
|
+
/**
|
|
328
|
+
* Optional standard-opcode condition (e.g. a hashlock), encoded into a
|
|
329
|
+
* ConditionMultisig leaf — or ConditionCSVMultisig when combined with `csv`.
|
|
330
|
+
*/
|
|
331
|
+
asm?: AsmToken[];
|
|
332
|
+
/**
|
|
333
|
+
* Relative timelock (CSV). The value is a literal or a `"$param"` reference
|
|
334
|
+
* resolved against the constructor args (same convention as {@link SignerRef}).
|
|
335
|
+
* Combinable with `asm` (condition + CSV); mutually exclusive with `cltv`.
|
|
336
|
+
*/
|
|
337
|
+
csv?: {
|
|
338
|
+
type: "blocks" | "seconds";
|
|
339
|
+
value: bigint | string;
|
|
340
|
+
};
|
|
341
|
+
/**
|
|
342
|
+
* Absolute timelock (CLTV): a literal or a `"$param"` reference.
|
|
343
|
+
* Mutually exclusive with `csv`/`asm`.
|
|
344
|
+
*/
|
|
345
|
+
cltv?: bigint | string;
|
|
346
|
+
/** Items satisfying the condition (e.g. an HTLC preimage); set via the ConditionWitness PSBT field. */
|
|
347
|
+
witness?: WitnessRef[];
|
|
348
|
+
}
|
|
349
|
+
/** Arkade Script segment of a spending path — emulated, bound via the key tweak. */
|
|
350
|
+
interface ArkadeSegment {
|
|
351
|
+
/** Raw Arkade opcodes with `$param` placeholders. */
|
|
352
|
+
asm: AsmToken[];
|
|
353
|
+
/** The arkade-script witness stack (e.g. an output index). */
|
|
354
|
+
witness?: WitnessRef[];
|
|
355
|
+
}
|
|
356
|
+
/** One named spending path. */
|
|
357
|
+
interface ArkadeFunction {
|
|
358
|
+
/**
|
|
359
|
+
* The function ABI: an ordered list of call arguments. Each entry is a typed
|
|
360
|
+
* descriptor `{ name, type }` (which gives the matching `functions.<name>`
|
|
361
|
+
* argument a precise static type) or a bare name string (loose
|
|
362
|
+
* {@link ArkadeArgValue}). Absent for nullary paths (e.g. exit/cancel).
|
|
363
|
+
*/
|
|
364
|
+
inputs?: readonly InputRef[];
|
|
365
|
+
tapscript: TapscriptSegment;
|
|
366
|
+
/** Present for covenant paths; absent for pure-tapscript paths (cancel/exit). */
|
|
367
|
+
arkadeScript?: ArkadeSegment;
|
|
368
|
+
}
|
|
369
|
+
declare const SUPPORTED_PROGRAM_VERSION = 0;
|
|
370
|
+
/** An Arkade contract program (hand-written or compiler-emitted). */
|
|
371
|
+
interface Program {
|
|
372
|
+
version: number;
|
|
373
|
+
/**
|
|
374
|
+
* Optional program name — metadata only: round-tripped through the
|
|
375
|
+
* artifact JSON, never used in compilation or the taproot tree.
|
|
376
|
+
*/
|
|
377
|
+
name?: string;
|
|
378
|
+
/**
|
|
379
|
+
* Ordered constructor parameters. Bare name strings are documentation only
|
|
380
|
+
* (the legacy hand-written form); typed descriptors `{ name, type }` make
|
|
381
|
+
* the list authoritative — see {@link validateProgram}.
|
|
382
|
+
*/
|
|
383
|
+
params?: readonly InputRef[];
|
|
384
|
+
functions: Record<string, ArkadeFunction>;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Resolve an `asm` array to bytes: substitute `$param` placeholders from `bind`,
|
|
388
|
+
* pass everything else (opcode names, numbers, raw byte pushes) through to the
|
|
389
|
+
* Arkade script encoder. The SDK does not interpret opcodes — this is pure
|
|
390
|
+
* substitution + encoding. To embed a signer key (server, user, or any
|
|
391
|
+
* other), pass it as a `$param` in the constructor args; there is no
|
|
392
|
+
* `<SERVER_KEY>`/`<COSIGNER_KEY>` token.
|
|
393
|
+
*/
|
|
394
|
+
declare function resolveAsm(asm: AsmToken[], bind: Record<string, ArkadeParamValue>): Uint8Array;
|
|
395
|
+
/**
|
|
396
|
+
* Resolve one witness-stack item to bytes.
|
|
397
|
+
*
|
|
398
|
+
* - raw bytes pass through;
|
|
399
|
+
* - numbers/bigints encode as minimal script-nums;
|
|
400
|
+
* - `"$param"` strings resolve against the program's constructor args;
|
|
401
|
+
* - any other string is a function-input name and resolves against `callArgs`
|
|
402
|
+
* (throws when the input is unbound — e.g. outside a function call).
|
|
403
|
+
*/
|
|
404
|
+
declare function witnessRefToBytes(ref: WitnessRef, callArgs: Record<string, ArkadeArgValue>, programArgs: Record<string, ArkadeParamValue>): Uint8Array;
|
|
405
|
+
/**
|
|
406
|
+
* Validate a program's constructor-parameter declarations against the bound
|
|
407
|
+
* args. A `params` list of bare name strings is documentation only (the
|
|
408
|
+
* legacy hand-written form — no checks). When at least one entry is a typed
|
|
409
|
+
* descriptor (the compiler-emitted form), the list is authoritative: every
|
|
410
|
+
* declared param must be bound in `args`, every `"$name"` reference in the
|
|
411
|
+
* program must be declared, and typed entries validate their bound value
|
|
412
|
+
* (bytes-like types require a Uint8Array — 32 bytes for `pubkey`, 64 for
|
|
413
|
+
* `sig`; `int` requires a bigint/number).
|
|
414
|
+
*/
|
|
415
|
+
declare function validateProgram(program: Program, args: Record<string, ArkadeParamValue>): void;
|
|
416
|
+
/** The signer keys a program is compiled against. */
|
|
417
|
+
interface ProgramKeys {
|
|
418
|
+
/** The Arkade Service signer key (x-only) — used for address derivation and collaborative-path detection, not for `$param` resolution. */
|
|
419
|
+
serverKey: Uint8Array;
|
|
420
|
+
/** The wallet's x-only key — identifies which inputs the wallet signs. */
|
|
421
|
+
userKey?: Uint8Array;
|
|
422
|
+
/** The co-signer (emulator) key — required only for covenant (`arkadeScript`) functions. */
|
|
423
|
+
emulatorKey?: Uint8Array;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* A single spending path, fully resolved at compilation: its definition, the
|
|
427
|
+
* committed leaf body, the per-path arkade-script bytes (covenant paths only),
|
|
428
|
+
* and the {@link TapLeafScript} (control block) for spending it.
|
|
429
|
+
*/
|
|
430
|
+
interface CompiledProgramFunction {
|
|
431
|
+
name: string;
|
|
432
|
+
def: ArkadeFunction;
|
|
433
|
+
/** The committed leaf script (body). */
|
|
434
|
+
leafScript: Uint8Array;
|
|
435
|
+
/** Resolved arkade-script bytes; undefined for pure-tapscript paths. */
|
|
436
|
+
arkadeScript?: Uint8Array;
|
|
437
|
+
/** Resolved signer keys (x-only), in the declared `signers` order. */
|
|
438
|
+
signerKeys: Uint8Array[];
|
|
439
|
+
/** Resolved once — the taproot leaf + control block for this path. */
|
|
440
|
+
tapLeafScript: TapLeafScript;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* A {@link VtxoScript} compiled from an Arkade {@link Program}, its
|
|
444
|
+
* constructor args and the signer keys.
|
|
445
|
+
*
|
|
446
|
+
* This is the single compilation path shared by the high-level
|
|
447
|
+
* `ArkadeContract` client and the `"arkade"` contract handler: both produce
|
|
448
|
+
* byte-identical taproot trees for the same (program, args, keys), so a
|
|
449
|
+
* contract registered through the `src/contracts` pipeline re-derives the
|
|
450
|
+
* exact script it was created with.
|
|
451
|
+
*/
|
|
452
|
+
declare class ArkadeProgramScript extends VtxoScript {
|
|
453
|
+
readonly program: Program;
|
|
454
|
+
readonly args: Record<string, ArkadeParamValue>;
|
|
455
|
+
readonly keys: ProgramKeys;
|
|
456
|
+
/** Spending paths in declaration order. */
|
|
457
|
+
readonly compiled: CompiledProgramFunction[];
|
|
458
|
+
constructor(program: Program, args: Record<string, ArkadeParamValue>, keys: ProgramKeys);
|
|
459
|
+
/** The compiled spending path with the given function name, if any. */
|
|
460
|
+
functionByName(name: string): CompiledProgramFunction | undefined;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Convert a compiler-style JSON artifact into a {@link Program}. Byte values are
|
|
464
|
+
* encoded as `0x`-prefixed hex strings in `asm`/`witness`/`signers`; opcode names,
|
|
465
|
+
* `$param` placeholders and numbers pass through unchanged.
|
|
466
|
+
*/
|
|
467
|
+
declare function parseArtifact(artifact: {
|
|
468
|
+
version?: number;
|
|
469
|
+
name?: string;
|
|
470
|
+
params?: readonly InputRef[];
|
|
471
|
+
functions: Record<string, any>;
|
|
472
|
+
}): Program;
|
|
473
|
+
/**
|
|
474
|
+
* Serialize a {@link Program} to compiler-artifact JSON — the inverse of
|
|
475
|
+
* {@link parseArtifact}: bytes become `0x`-hex strings; bigint tokens become
|
|
476
|
+
* plain numbers (or, above `Number.MAX_SAFE_INTEGER`, `0x`-hex of their
|
|
477
|
+
* minimal script-num bytes, which the script encoder pushes identically);
|
|
478
|
+
* literal timelock values serialize as decimal strings while `"$param"`
|
|
479
|
+
* timelock references are emitted as-is.
|
|
480
|
+
*/
|
|
481
|
+
declare function stringifyArtifact(program: Program): string;
|
|
482
|
+
/**
|
|
483
|
+
* Typed parameters of an `"arkade"` contract as persisted through the
|
|
484
|
+
* `src/contracts` pipeline. The program serializes as artifact JSON, args as
|
|
485
|
+
* a JSON map (`0x`-hex bytes, decimal-string bigints), keys as hex — so a
|
|
486
|
+
* stored contract row re-derives its script fully offline.
|
|
487
|
+
*/
|
|
488
|
+
interface ArkadeContractParams {
|
|
489
|
+
program: Program;
|
|
490
|
+
args: Record<string, ArkadeParamValue>;
|
|
491
|
+
serverKey: Uint8Array;
|
|
492
|
+
userKey?: Uint8Array;
|
|
493
|
+
emulatorKey?: Uint8Array;
|
|
494
|
+
}
|
|
495
|
+
/** Serialize {@link ArkadeContractParams} to the string map `Contract.params` requires. */
|
|
496
|
+
declare function serializeArkadeContractParams(typed: ArkadeContractParams): Record<string, string>;
|
|
497
|
+
/** Parse the string map persisted in `Contract.params` back into typed params. */
|
|
498
|
+
declare function deserializeArkadeContractParams(params: Record<string, string>): ArkadeContractParams;
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Generic handler for artifact/program-based Arkade contracts.
|
|
502
|
+
*
|
|
503
|
+
* Persists the full {@link ArkadeContractParams} (program artifact JSON, args,
|
|
504
|
+
* signer keys) as string params, so any contract created via
|
|
505
|
+
* `arkade.contract(program, args)` participates in the standard contract
|
|
506
|
+
* pipeline: ContractManager persistence and validation, watcher events,
|
|
507
|
+
* repository-backed balances, and offline script re-derivation. Rebuild a
|
|
508
|
+
* callable contract from a stored row with `ArkadeContract.fromContract`.
|
|
509
|
+
*/
|
|
510
|
+
declare const ArkadeContractHandler: ContractHandler<ArkadeContractParams, ArkadeProgramScript> & TapscriptDeriving<ArkadeProgramScript>;
|
|
511
|
+
|
|
512
|
+
export { type ArkadeParamValue as A, BoardingContractHandler as B, type CompiledProgramFunction as C, DefaultContractHandler as D, type InputRef as I, type Program as P, SUPPORTED_PROGRAM_VERSION as S, type TapscriptSegment as T, VHTLC as V, type WitnessRef as W, ArkadeProgramScript as a, type ProgramKeys as b, type ArkadeArgValue as c, type ArkadeFunction as d, type InputDef as e, type ArkadeValueType as f, type ArkadeArgType as g, type ArkadeContractParams as h, type ArkadeSegment as i, type AsmToken as j, type SignerRef as k, deserializeArkadeContractParams as l, stringifyArtifact as m, ArkadeContractHandler as n, type BoardingContractParams as o, parseArtifact as p, type DefaultContractParams as q, resolveAsm as r, serializeArkadeContractParams as s, DelegateContractHandler as t, type DelegateContractParams as u, validateProgram as v, witnessRefToBytes as w, VHTLCContractHandler as x, type VHTLCContractParams as y, contractHandlers as z };
|