@arkade-os/sdk 0.5.4 → 0.5.6
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 +103 -17
- package/dist/adapters/expo.cjs +7 -6
- package/dist/adapters/expo.d.cts +4 -3
- package/dist/adapters/expo.d.ts +4 -3
- package/dist/adapters/expo.js +4 -3
- package/dist/{asyncStorageTaskQueue-DTBa8EH7.d.cts → asyncStorageTaskQueue-Bh2n0msM.d.cts} +2 -2
- package/dist/{asyncStorageTaskQueue-DHMIxY04.d.ts → asyncStorageTaskQueue-CpkstKZ5.d.ts} +2 -2
- package/dist/base-C-Y5t_0F.d.cts +359 -0
- package/dist/base-C-Y5t_0F.d.ts +359 -0
- package/dist/{chunk-6CUP6ZIF.js → chunk-47Z4LEIW.js} +17 -841
- package/dist/chunk-47Z4LEIW.js.map +1 -0
- package/dist/{chunk-DNITZVNG.cjs → chunk-4X67IB2V.cjs} +18 -17
- package/dist/chunk-4X67IB2V.cjs.map +1 -0
- package/dist/{chunk-BTRCN4JJ.js → chunk-C7NY6WSA.js} +64 -4
- package/dist/chunk-C7NY6WSA.js.map +1 -0
- package/dist/{chunk-TUOLZBNC.js → chunk-DJYX73W2.js} +5 -4
- package/dist/chunk-DJYX73W2.js.map +1 -0
- package/dist/chunk-DNFTHG73.js +829 -0
- package/dist/chunk-DNFTHG73.js.map +1 -0
- package/dist/chunk-FDJ734CH.js +882 -0
- package/dist/chunk-FDJ734CH.js.map +1 -0
- package/dist/chunk-FLPWNMX3.cjs +930 -0
- package/dist/chunk-FLPWNMX3.cjs.map +1 -0
- package/dist/{chunk-WXNSISXK.cjs → chunk-HKEPJBTY.cjs} +79 -18
- package/dist/chunk-HKEPJBTY.cjs.map +1 -0
- package/dist/chunk-JFJNB7ZH.cjs +884 -0
- package/dist/chunk-JFJNB7ZH.cjs.map +1 -0
- package/dist/{chunk-GHUUT54D.cjs → chunk-LZAINCGU.cjs} +89 -933
- package/dist/chunk-LZAINCGU.cjs.map +1 -0
- package/dist/{chunk-E6OOJEHL.cjs → chunk-NDQ4LB4X.cjs} +60 -934
- package/dist/chunk-NDQ4LB4X.cjs.map +1 -0
- package/dist/{chunk-AG4TFD6F.js → chunk-QTMK34TP.js} +79 -884
- package/dist/chunk-QTMK34TP.js.map +1 -0
- package/dist/chunk-V3ZLL5VY.js +380 -0
- package/dist/chunk-V3ZLL5VY.js.map +1 -0
- package/dist/{chunk-MWVAWFX6.js → chunk-VWW2ZBPI.js} +4 -4
- package/dist/{chunk-MWVAWFX6.js.map → chunk-VWW2ZBPI.js.map} +1 -1
- package/dist/chunk-X6ZI53DZ.cjs +383 -0
- package/dist/chunk-X6ZI53DZ.cjs.map +1 -0
- package/dist/{chunk-F3FAE7VJ.cjs → chunk-Y3CDDPWI.cjs} +3138 -1764
- package/dist/chunk-Y3CDDPWI.cjs.map +1 -0
- package/dist/{chunk-ZJHLLDBP.js → chunk-YKT4NAQG.js} +2653 -1295
- package/dist/chunk-YKT4NAQG.js.map +1 -0
- package/dist/{chunk-B6VNKGIH.cjs → chunk-YS76JSGP.cjs} +10 -10
- package/dist/{chunk-B6VNKGIH.cjs.map → chunk-YS76JSGP.cjs.map} +1 -1
- package/dist/compiler.cjs +50 -0
- package/dist/compiler.cjs.map +1 -0
- package/dist/compiler.d.cts +38 -0
- package/dist/compiler.d.ts +38 -0
- package/dist/compiler.js +47 -0
- package/dist/compiler.js.map +1 -0
- package/dist/contracts/handlers/index.cjs +11 -9
- package/dist/contracts/handlers/index.d.cts +6 -4
- package/dist/contracts/handlers/index.d.ts +6 -4
- package/dist/contracts/handlers/index.js +4 -2
- package/dist/{delegate-xrSBNybC.d.ts → delegate-gGkUnYpi.d.cts} +1 -1
- package/dist/{delegate-f4_t864Z.d.cts → delegate-iyDum4fw.d.ts} +1 -1
- package/dist/{index-BJDz15ms.d.ts → index-2wKMrT0a.d.ts} +5 -270
- package/dist/{index-BjiVGtp8.d.cts → index-46g577Ka.d.cts} +5 -270
- package/dist/{index-DRwe0UDN.d.cts → index-C66rjxz2.d.ts} +1603 -1721
- package/dist/{index-DRwe0UDN.d.ts → index-Dqk07NwJ.d.cts} +1603 -1721
- package/dist/index.cjs +457 -378
- package/dist/index.d.cts +640 -385
- package/dist/index.d.ts +640 -385
- package/dist/index.js +7 -4
- package/dist/{wallet-jVBDQl6R.d.cts → keyringDescriptorProvider-DiBM4GmB.d.ts} +417 -366
- package/dist/{wallet-Oc3Wd5gv.d.ts → keyringDescriptorProvider-DnaLUC7v.d.cts} +417 -366
- package/dist/program-BARSNg3X.d.ts +286 -0
- package/dist/program-znrWkxE4.d.cts +286 -0
- package/dist/repositories/realm/index.cjs +71 -51
- package/dist/repositories/realm/index.cjs.map +1 -1
- package/dist/repositories/realm/index.d.cts +20 -9
- package/dist/repositories/realm/index.d.ts +20 -9
- package/dist/repositories/realm/index.js +42 -23
- package/dist/repositories/realm/index.js.map +1 -1
- package/dist/repositories/sqlite/index.cjs +81 -56
- package/dist/repositories/sqlite/index.cjs.map +1 -1
- package/dist/repositories/sqlite/index.d.cts +17 -8
- package/dist/repositories/sqlite/index.d.ts +17 -8
- package/dist/repositories/sqlite/index.js +55 -31
- package/dist/repositories/sqlite/index.js.map +1 -1
- package/dist/{taskRunner-CDlNeth0.d.ts → taskRunner-BM6IAKlS.d.ts} +2 -2
- package/dist/{taskRunner-BPPU-YHG.d.cts → taskRunner-BmDIZiSl.d.cts} +2 -2
- package/dist/wallet/expo/background.cjs +17 -14
- package/dist/wallet/expo/background.cjs.map +1 -1
- package/dist/wallet/expo/background.d.cts +5 -4
- package/dist/wallet/expo/background.d.ts +5 -4
- package/dist/wallet/expo/background.js +9 -6
- package/dist/wallet/expo/background.js.map +1 -1
- package/dist/wallet/expo/index.cjs +29 -16
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +12 -7
- package/dist/wallet/expo/index.d.ts +12 -7
- package/dist/wallet/expo/index.js +19 -6
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/worker/expo/index.cjs +12 -9
- package/dist/worker/expo/index.cjs.map +1 -1
- package/dist/worker/expo/index.d.cts +6 -5
- package/dist/worker/expo/index.d.ts +6 -5
- package/dist/worker/expo/index.js +8 -5
- package/dist/worker/expo/index.js.map +1 -1
- package/package.json +16 -1
- package/dist/chunk-6CUP6ZIF.js.map +0 -1
- package/dist/chunk-AG4TFD6F.js.map +0 -1
- package/dist/chunk-BTRCN4JJ.js.map +0 -1
- package/dist/chunk-DNITZVNG.cjs.map +0 -1
- package/dist/chunk-E6OOJEHL.cjs.map +0 -1
- package/dist/chunk-F3FAE7VJ.cjs.map +0 -1
- package/dist/chunk-GHUUT54D.cjs.map +0 -1
- package/dist/chunk-TUOLZBNC.js.map +0 -1
- package/dist/chunk-WXNSISXK.cjs.map +0 -1
- package/dist/chunk-ZJHLLDBP.js.map +0 -1
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import { NETWORK } from '@scure/btc-signer';
|
|
2
|
+
import { PSBTOutput } from '@scure/btc-signer/psbt.js';
|
|
3
|
+
import { Bytes } from '@scure/btc-signer/utils.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* RelativeTimelock lets to create timelocked with CHECKSEQUENCEVERIFY script.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const timelock = { value: 144n, type: "blocks" }; // 1 day in blocks
|
|
11
|
+
* const timelock = { value: 512n, type: "seconds" }; // 8 minutes in seconds
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
type RelativeTimelock = {
|
|
15
|
+
value: bigint;
|
|
16
|
+
type: "seconds" | "blocks";
|
|
17
|
+
};
|
|
18
|
+
declare enum TapscriptType {
|
|
19
|
+
Multisig = "multisig",
|
|
20
|
+
CSVMultisig = "csv-multisig",
|
|
21
|
+
ConditionCSVMultisig = "condition-csv-multisig",
|
|
22
|
+
ConditionMultisig = "condition-multisig",
|
|
23
|
+
CLTVMultisig = "cltv-multisig"
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* ArkTapscript is the base element of vtxo scripts.
|
|
27
|
+
* It is used to encode and decode the different types of vtxo scripts.
|
|
28
|
+
*/
|
|
29
|
+
interface ArkTapscript<T extends TapscriptType, Params> {
|
|
30
|
+
type: T;
|
|
31
|
+
params: Params;
|
|
32
|
+
script: Uint8Array;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* decodeTapscript is a function that decodes an Arkade tapscript from a raw script.
|
|
36
|
+
*
|
|
37
|
+
* @throws {Error} if the script is not a valid Arkade tapscript
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const arkTapscript = decodeTapscript(new Uint8Array(32));
|
|
41
|
+
* console.log("type:", arkTapscript.type);
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
declare function decodeTapscript(script: Uint8Array): ArkTapscript<TapscriptType, any>;
|
|
45
|
+
/**
|
|
46
|
+
* Implements a multi-signature tapscript.
|
|
47
|
+
*
|
|
48
|
+
* <pubkey> CHECKSIGVERIFY <pubkey> CHECKSIG
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const multisigTapscript = MultisigTapscript.encode({ pubkeys: [new Uint8Array(32), new Uint8Array(32)] });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
declare namespace MultisigTapscript {
|
|
56
|
+
type Type = ArkTapscript<TapscriptType.Multisig, Params>;
|
|
57
|
+
enum MultisigType {
|
|
58
|
+
CHECKSIG = 0,
|
|
59
|
+
CHECKSIGADD = 1
|
|
60
|
+
}
|
|
61
|
+
type Params = {
|
|
62
|
+
pubkeys: Bytes[];
|
|
63
|
+
type?: MultisigType;
|
|
64
|
+
};
|
|
65
|
+
/** Encode a plain multisig tapscript. */
|
|
66
|
+
function encode(params: Params): Type;
|
|
67
|
+
/** Decode a plain multisig tapscript from raw script bytes. */
|
|
68
|
+
function decode(script: Uint8Array): Type;
|
|
69
|
+
/** Return true when the tapscript is a plain multisig tapscript. */
|
|
70
|
+
function is(tapscript: ArkTapscript<any, any>): tapscript is Type;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Implements a relative timelock script that requires all specified pubkeys to sign
|
|
74
|
+
* after the relative timelock has expired. The timelock can be specified in blocks or seconds.
|
|
75
|
+
*
|
|
76
|
+
* This is the standard exit closure and it is also used for the sweep closure in vtxo trees.
|
|
77
|
+
*
|
|
78
|
+
* <sequence> CHECKSEQUENCEVERIFY DROP <pubkey> CHECKSIG
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* const csvMultisigTapscript = CSVMultisigTapscript.encode({ timelock: { type: "blocks", value: 144 }, pubkeys: [new Uint8Array(32), new Uint8Array(32)] });
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
declare namespace CSVMultisigTapscript {
|
|
86
|
+
type Type = ArkTapscript<TapscriptType.CSVMultisig, Params>;
|
|
87
|
+
type Params = {
|
|
88
|
+
timelock: RelativeTimelock;
|
|
89
|
+
} & MultisigTapscript.Params;
|
|
90
|
+
/** Encode a CSV multisig tapscript. */
|
|
91
|
+
function encode(params: Params): Type;
|
|
92
|
+
/** Decode a CSV multisig tapscript from raw script bytes. */
|
|
93
|
+
function decode(script: Uint8Array): Type;
|
|
94
|
+
/** Return true when the tapscript is a CSV multisig tapscript. */
|
|
95
|
+
function is(tapscript: ArkTapscript<any, any>): tapscript is Type;
|
|
96
|
+
function isScriptValid(script: Uint8Array): true | Error;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Combines a condition script with an exit closure. The resulting script requires
|
|
100
|
+
* the condition to be met, followed by the standard exit closure requirements
|
|
101
|
+
* (timelock and signatures).
|
|
102
|
+
*
|
|
103
|
+
* <conditionScript> VERIFY <sequence> CHECKSEQUENCEVERIFY DROP <pubkey> CHECKSIGVERIFY <pubkey> CHECKSIG
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* const conditionCSVMultisigTapscript = ConditionCSVMultisigTapscript.encode({ conditionScript: new Uint8Array(32), pubkeys: [new Uint8Array(32), new Uint8Array(32)] });
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
declare namespace ConditionCSVMultisigTapscript {
|
|
111
|
+
type Type = ArkTapscript<TapscriptType.ConditionCSVMultisig, Params>;
|
|
112
|
+
type Params = {
|
|
113
|
+
conditionScript: Bytes;
|
|
114
|
+
} & CSVMultisigTapscript.Params;
|
|
115
|
+
/** Encode a condition + CSV multisig tapscript. */
|
|
116
|
+
function encode(params: Params): Type;
|
|
117
|
+
/** Decode a condition + CSV multisig tapscript from raw script bytes. */
|
|
118
|
+
function decode(script: Uint8Array): Type;
|
|
119
|
+
/** Return true when the tapscript is a condition + CSV multisig tapscript. */
|
|
120
|
+
function is(tapscript: ArkTapscript<any, any>): tapscript is Type;
|
|
121
|
+
function isScriptValid(script: Uint8Array): true | Error;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Combines a condition script with a forfeit closure. The resulting script requires
|
|
125
|
+
* the condition to be met, followed by the standard forfeit closure requirements
|
|
126
|
+
* (multi-signature).
|
|
127
|
+
*
|
|
128
|
+
* <conditionScript> VERIFY <pubkey> CHECKSIGVERIFY <pubkey> CHECKSIG
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* const conditionMultisigTapscript = ConditionMultisigTapscript.encode({ conditionScript: new Uint8Array(32), pubkeys: [new Uint8Array(32), new Uint8Array(32)] });
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
declare namespace ConditionMultisigTapscript {
|
|
136
|
+
type Type = ArkTapscript<TapscriptType.ConditionMultisig, Params>;
|
|
137
|
+
type Params = {
|
|
138
|
+
conditionScript: Bytes;
|
|
139
|
+
} & MultisigTapscript.Params;
|
|
140
|
+
/** Encode a condition + multisig tapscript. */
|
|
141
|
+
function encode(params: Params): Type;
|
|
142
|
+
/** Decode a condition + multisig tapscript from raw script bytes. */
|
|
143
|
+
function decode(script: Uint8Array): Type;
|
|
144
|
+
/** Return true when the tapscript is a condition + multisig tapscript. */
|
|
145
|
+
function is(tapscript: ArkTapscript<any, any>): tapscript is Type;
|
|
146
|
+
function isScriptValid(script: Uint8Array): true | Error;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Implements an absolute timelock (CLTV) script combined with a forfeit closure.
|
|
150
|
+
* The script requires waiting until a specific block height/timestamp before the
|
|
151
|
+
* forfeit closure conditions can be met.
|
|
152
|
+
*
|
|
153
|
+
* <locktime> CHECKLOCKTIMEVERIFY DROP <pubkey> CHECKSIGVERIFY <pubkey> CHECKSIG
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```typescript
|
|
157
|
+
* const cltvMultisigTapscript = CLTVMultisigTapscript.encode({ absoluteTimelock: 144, pubkeys: [new Uint8Array(32), new Uint8Array(32)] });
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
declare namespace CLTVMultisigTapscript {
|
|
161
|
+
type Type = ArkTapscript<TapscriptType.CLTVMultisig, Params>;
|
|
162
|
+
type Params = {
|
|
163
|
+
absoluteTimelock: bigint;
|
|
164
|
+
} & MultisigTapscript.Params;
|
|
165
|
+
/** Encode a CLTV multisig tapscript. */
|
|
166
|
+
function encode(params: Params): Type;
|
|
167
|
+
/** Decode a CLTV multisig tapscript from raw script bytes. */
|
|
168
|
+
function decode(script: Uint8Array): Type;
|
|
169
|
+
/** Return true when the tapscript is a CLTV multisig tapscript. */
|
|
170
|
+
function is(tapscript: ArkTapscript<any, any>): tapscript is Type;
|
|
171
|
+
function isScriptValid(script: Uint8Array): true | Error;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* ArkAddress allows creating and decoding bech32m-encoded Arkade addresses: an hrp plus a
|
|
176
|
+
* 65-byte payload of version byte ‖ 32-byte server pubkey ‖ 32-byte VTXO taproot key.
|
|
177
|
+
*
|
|
178
|
+
* @remarks
|
|
179
|
+
* This is an Arkade-specific address format.
|
|
180
|
+
* It is distinct from the Taproot onchain address returned by `VtxoScript.onchainAddress`.
|
|
181
|
+
*
|
|
182
|
+
* @see VtxoScript
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```typescript
|
|
186
|
+
* const address = new ArkAddress(
|
|
187
|
+
* new Uint8Array(32), // server public key
|
|
188
|
+
* new Uint8Array(32), // vtxo taproot public key
|
|
189
|
+
* "ark"
|
|
190
|
+
* );
|
|
191
|
+
*
|
|
192
|
+
* const encoded = address.encode();
|
|
193
|
+
* console.log("address: ", encoded);
|
|
194
|
+
*
|
|
195
|
+
* const decoded = ArkAddress.decode(encoded);
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
declare class ArkAddress {
|
|
199
|
+
readonly serverPubKey: Bytes;
|
|
200
|
+
readonly vtxoTaprootKey: Bytes;
|
|
201
|
+
readonly hrp: string;
|
|
202
|
+
readonly version: number;
|
|
203
|
+
/**
|
|
204
|
+
* Create an Arkade address from its server public key, Taproot output key, and prefix.
|
|
205
|
+
*
|
|
206
|
+
* @param serverPubKey - 32-byte Arkade server public key
|
|
207
|
+
* @param vtxoTaprootKey - 32-byte Taproot output key (a.k.a. tweaked public key)
|
|
208
|
+
* @param hrp - Bech32 human-readable prefix
|
|
209
|
+
* @param version - Address version byte
|
|
210
|
+
* @defaultValue `version = 0`
|
|
211
|
+
* @throws Error if either public key is not 32 bytes long
|
|
212
|
+
*/
|
|
213
|
+
constructor(serverPubKey: Bytes, vtxoTaprootKey: Bytes, hrp?: string, version?: number);
|
|
214
|
+
/**
|
|
215
|
+
* Decode an Arkade address from its bech32m string form.
|
|
216
|
+
*
|
|
217
|
+
* @param address - Bech32m-encoded Arkade address
|
|
218
|
+
* @returns Decoded Arkade address
|
|
219
|
+
* @throws Error if the address is malformed or has an invalid payload length
|
|
220
|
+
* @see encode
|
|
221
|
+
*/
|
|
222
|
+
static decode(address: string): ArkAddress;
|
|
223
|
+
/**
|
|
224
|
+
* Encode the address to its bech32m string form.
|
|
225
|
+
*
|
|
226
|
+
* @returns Bech32m-encoded Arkade address
|
|
227
|
+
* @see decode
|
|
228
|
+
*/
|
|
229
|
+
encode(): string;
|
|
230
|
+
/** ScriptPubKey used to send non-dust funds to the address. */
|
|
231
|
+
get pkScript(): Bytes;
|
|
232
|
+
/** ScriptPubKey used to send sub-dust funds to the address. */
|
|
233
|
+
get subdustPkScript(): Bytes;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
type TapLeafScript = [
|
|
237
|
+
{
|
|
238
|
+
version: number;
|
|
239
|
+
internalKey: Bytes;
|
|
240
|
+
merklePath: Bytes[];
|
|
241
|
+
},
|
|
242
|
+
Bytes
|
|
243
|
+
];
|
|
244
|
+
declare const TapTreeCoder: (typeof PSBTOutput.tapTree)[2];
|
|
245
|
+
declare function scriptFromTapLeafScript(leaf: TapLeafScript): Bytes;
|
|
246
|
+
/**
|
|
247
|
+
* VtxoScript is a script that contains a list of tapleaf scripts.
|
|
248
|
+
* It is used to create virtual output scripts.
|
|
249
|
+
*
|
|
250
|
+
* @see ArkAddress
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```typescript
|
|
254
|
+
* const vtxoScript = new VtxoScript([new Uint8Array(32), new Uint8Array(32)]);
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
declare class VtxoScript {
|
|
258
|
+
readonly scripts: Bytes[];
|
|
259
|
+
readonly leaves: TapLeafScript[];
|
|
260
|
+
readonly tweakedPublicKey: Bytes;
|
|
261
|
+
readonly pkScript: Bytes;
|
|
262
|
+
/**
|
|
263
|
+
* Decode a virtual output script from an encoded TapTree.
|
|
264
|
+
*
|
|
265
|
+
* Leaves are normally read in construction order and their depths
|
|
266
|
+
* ignored: that covers the {@link encode} form (every depth 1) and the
|
|
267
|
+
* placeholder depths other writers use, such as arkd's. The exception is
|
|
268
|
+
* the BIP-371 form {@link toBIP371TapTree} writes, whose leaves are in the
|
|
269
|
+
* tree's DFS order: for some leaf counts (6, 7, 10, ...) that differs from
|
|
270
|
+
* construction order. A tree whose depths are exactly the shape
|
|
271
|
+
* `assembleBtcdTaprootTree` builds is that form, so its leaves are mapped
|
|
272
|
+
* back to construction order first. No construction-order writer produces
|
|
273
|
+
* that depth sequence when the two orders differ, so this never reorders
|
|
274
|
+
* a tree that decoded correctly before.
|
|
275
|
+
*
|
|
276
|
+
* Every leaf must carry the base tapscript version: the tree is rebuilt
|
|
277
|
+
* with {@link TAP_LEAF_VERSION} leaves, so any other version would
|
|
278
|
+
* silently derive a different taproot key.
|
|
279
|
+
*
|
|
280
|
+
* @param tapTree - Encoded TapTree bytes
|
|
281
|
+
* @returns Decoded virtual output script
|
|
282
|
+
* @throws Error if the TapTree cannot be decoded into a valid script set
|
|
283
|
+
* or a leaf carries a version other than {@link TAP_LEAF_VERSION}
|
|
284
|
+
* @see encode
|
|
285
|
+
*/
|
|
286
|
+
static decode(tapTree: Bytes): VtxoScript;
|
|
287
|
+
/**
|
|
288
|
+
* Create a virtual output script from its tapleaf scripts.
|
|
289
|
+
*
|
|
290
|
+
* The Taproot script tree is assembled using btcd's algorithm
|
|
291
|
+
* (`txscript.AssembleTaprootScriptTree`) so the derived taproot output
|
|
292
|
+
* key agrees with arkd for any leaf count. `@scure/btc-signer`'s
|
|
293
|
+
* default `taprootListToTree` is a Huffman builder that only agrees
|
|
294
|
+
* with arkd for power-of-2 leaf counts.
|
|
295
|
+
*
|
|
296
|
+
* @param scripts - Raw tapscript bytes for each leaf
|
|
297
|
+
* @throws Error if the provided leaves cannot produce a valid Taproot tree
|
|
298
|
+
*/
|
|
299
|
+
constructor(scripts: Bytes[]);
|
|
300
|
+
/**
|
|
301
|
+
* Encode the virtual output script to a TapTree byte representation.
|
|
302
|
+
*
|
|
303
|
+
* @returns Encoded TapTree bytes
|
|
304
|
+
* @see decode
|
|
305
|
+
*/
|
|
306
|
+
encode(): Bytes;
|
|
307
|
+
/**
|
|
308
|
+
* Build the Arkade address corresponding to this virtual output script.
|
|
309
|
+
*
|
|
310
|
+
* @param prefix - Bech32 human-readable prefix
|
|
311
|
+
* @param serverPubKey - 32-byte Arkade server public key
|
|
312
|
+
* @returns Arkade address for this script
|
|
313
|
+
* @see ArkAddress
|
|
314
|
+
*/
|
|
315
|
+
address(prefix: string | undefined, serverPubKey: Bytes): ArkAddress;
|
|
316
|
+
/**
|
|
317
|
+
* Build the Taproot onchain address corresponding to this virtual output script.
|
|
318
|
+
*
|
|
319
|
+
* @param network - Bitcoin network descriptor
|
|
320
|
+
* @returns Taproot onchain address
|
|
321
|
+
* @see address
|
|
322
|
+
*/
|
|
323
|
+
onchainAddress(network?: typeof NETWORK): string;
|
|
324
|
+
/**
|
|
325
|
+
* Look up a tapleaf script by its hex-encoded tapscript body.
|
|
326
|
+
*
|
|
327
|
+
* @param scriptHex - Hex-encoded tapscript body without the leaf version byte
|
|
328
|
+
* @returns Matching tapleaf script
|
|
329
|
+
* @throws Error if no matching leaf exists
|
|
330
|
+
*/
|
|
331
|
+
findLeaf(scriptHex: string): TapLeafScript;
|
|
332
|
+
/**
|
|
333
|
+
* Return all unilateral exit paths embedded in the virtual output script.
|
|
334
|
+
*
|
|
335
|
+
* @returns CSV-based exit paths found in the leaves
|
|
336
|
+
* @see getSequence
|
|
337
|
+
*/
|
|
338
|
+
exitPaths(): Array<CSVMultisigTapscript.Type | ConditionCSVMultisigTapscript.Type>;
|
|
339
|
+
}
|
|
340
|
+
type EncodedVtxoScript = {
|
|
341
|
+
tapTree: Bytes;
|
|
342
|
+
};
|
|
343
|
+
/**
|
|
344
|
+
* Extract the timelock value encoded in a timelocked tapleaf, if any.
|
|
345
|
+
*
|
|
346
|
+
* The return value is unit-ambiguous: for a CSV leaf it is a BIP-68
|
|
347
|
+
* nSequence (relative timelock); for a CLTV leaf it is an absolute
|
|
348
|
+
* nLockTime. Callers must know which leaf shape they are inspecting to
|
|
349
|
+
* interpret the number correctly, and must not copy a CSV result into
|
|
350
|
+
* `Transaction.lockTime` (or vice versa).
|
|
351
|
+
*
|
|
352
|
+
* @param tapLeafScript - Tapleaf script to inspect
|
|
353
|
+
* @returns The encoded timelock value, or `undefined` when neither a CSV
|
|
354
|
+
* nor CLTV path is present
|
|
355
|
+
* @see VtxoScript.exitPaths
|
|
356
|
+
*/
|
|
357
|
+
declare function getSequence(tapLeafScript: TapLeafScript): number | undefined;
|
|
358
|
+
|
|
359
|
+
export { ArkAddress as A, CSVMultisigTapscript as C, type EncodedVtxoScript as E, MultisigTapscript as M, type RelativeTimelock as R, type TapLeafScript as T, VtxoScript as V, type ArkTapscript as a, CLTVMultisigTapscript as b, ConditionCSVMultisigTapscript as c, ConditionMultisigTapscript as d, TapTreeCoder as e, TapscriptType as f, decodeTapscript as g, getSequence as h, scriptFromTapLeafScript as s };
|