@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.
Files changed (112) hide show
  1. package/README.md +103 -17
  2. package/dist/adapters/expo.cjs +7 -6
  3. package/dist/adapters/expo.d.cts +4 -3
  4. package/dist/adapters/expo.d.ts +4 -3
  5. package/dist/adapters/expo.js +4 -3
  6. package/dist/{asyncStorageTaskQueue-DTBa8EH7.d.cts → asyncStorageTaskQueue-Bh2n0msM.d.cts} +2 -2
  7. package/dist/{asyncStorageTaskQueue-DHMIxY04.d.ts → asyncStorageTaskQueue-CpkstKZ5.d.ts} +2 -2
  8. package/dist/base-C-Y5t_0F.d.cts +359 -0
  9. package/dist/base-C-Y5t_0F.d.ts +359 -0
  10. package/dist/{chunk-6CUP6ZIF.js → chunk-47Z4LEIW.js} +17 -841
  11. package/dist/chunk-47Z4LEIW.js.map +1 -0
  12. package/dist/{chunk-DNITZVNG.cjs → chunk-4X67IB2V.cjs} +18 -17
  13. package/dist/chunk-4X67IB2V.cjs.map +1 -0
  14. package/dist/{chunk-BTRCN4JJ.js → chunk-C7NY6WSA.js} +64 -4
  15. package/dist/chunk-C7NY6WSA.js.map +1 -0
  16. package/dist/{chunk-TUOLZBNC.js → chunk-DJYX73W2.js} +5 -4
  17. package/dist/chunk-DJYX73W2.js.map +1 -0
  18. package/dist/chunk-DNFTHG73.js +829 -0
  19. package/dist/chunk-DNFTHG73.js.map +1 -0
  20. package/dist/chunk-FDJ734CH.js +882 -0
  21. package/dist/chunk-FDJ734CH.js.map +1 -0
  22. package/dist/chunk-FLPWNMX3.cjs +930 -0
  23. package/dist/chunk-FLPWNMX3.cjs.map +1 -0
  24. package/dist/{chunk-WXNSISXK.cjs → chunk-HKEPJBTY.cjs} +79 -18
  25. package/dist/chunk-HKEPJBTY.cjs.map +1 -0
  26. package/dist/chunk-JFJNB7ZH.cjs +884 -0
  27. package/dist/chunk-JFJNB7ZH.cjs.map +1 -0
  28. package/dist/{chunk-GHUUT54D.cjs → chunk-LZAINCGU.cjs} +89 -933
  29. package/dist/chunk-LZAINCGU.cjs.map +1 -0
  30. package/dist/{chunk-E6OOJEHL.cjs → chunk-NDQ4LB4X.cjs} +60 -934
  31. package/dist/chunk-NDQ4LB4X.cjs.map +1 -0
  32. package/dist/{chunk-AG4TFD6F.js → chunk-QTMK34TP.js} +79 -884
  33. package/dist/chunk-QTMK34TP.js.map +1 -0
  34. package/dist/chunk-V3ZLL5VY.js +380 -0
  35. package/dist/chunk-V3ZLL5VY.js.map +1 -0
  36. package/dist/{chunk-MWVAWFX6.js → chunk-VWW2ZBPI.js} +4 -4
  37. package/dist/{chunk-MWVAWFX6.js.map → chunk-VWW2ZBPI.js.map} +1 -1
  38. package/dist/chunk-X6ZI53DZ.cjs +383 -0
  39. package/dist/chunk-X6ZI53DZ.cjs.map +1 -0
  40. package/dist/{chunk-F3FAE7VJ.cjs → chunk-Y3CDDPWI.cjs} +3138 -1764
  41. package/dist/chunk-Y3CDDPWI.cjs.map +1 -0
  42. package/dist/{chunk-ZJHLLDBP.js → chunk-YKT4NAQG.js} +2653 -1295
  43. package/dist/chunk-YKT4NAQG.js.map +1 -0
  44. package/dist/{chunk-B6VNKGIH.cjs → chunk-YS76JSGP.cjs} +10 -10
  45. package/dist/{chunk-B6VNKGIH.cjs.map → chunk-YS76JSGP.cjs.map} +1 -1
  46. package/dist/compiler.cjs +50 -0
  47. package/dist/compiler.cjs.map +1 -0
  48. package/dist/compiler.d.cts +38 -0
  49. package/dist/compiler.d.ts +38 -0
  50. package/dist/compiler.js +47 -0
  51. package/dist/compiler.js.map +1 -0
  52. package/dist/contracts/handlers/index.cjs +11 -9
  53. package/dist/contracts/handlers/index.d.cts +6 -4
  54. package/dist/contracts/handlers/index.d.ts +6 -4
  55. package/dist/contracts/handlers/index.js +4 -2
  56. package/dist/{delegate-xrSBNybC.d.ts → delegate-gGkUnYpi.d.cts} +1 -1
  57. package/dist/{delegate-f4_t864Z.d.cts → delegate-iyDum4fw.d.ts} +1 -1
  58. package/dist/{index-BJDz15ms.d.ts → index-2wKMrT0a.d.ts} +5 -270
  59. package/dist/{index-BjiVGtp8.d.cts → index-46g577Ka.d.cts} +5 -270
  60. package/dist/{index-DRwe0UDN.d.cts → index-C66rjxz2.d.ts} +1603 -1721
  61. package/dist/{index-DRwe0UDN.d.ts → index-Dqk07NwJ.d.cts} +1603 -1721
  62. package/dist/index.cjs +457 -378
  63. package/dist/index.d.cts +640 -385
  64. package/dist/index.d.ts +640 -385
  65. package/dist/index.js +7 -4
  66. package/dist/{wallet-jVBDQl6R.d.cts → keyringDescriptorProvider-DiBM4GmB.d.ts} +417 -366
  67. package/dist/{wallet-Oc3Wd5gv.d.ts → keyringDescriptorProvider-DnaLUC7v.d.cts} +417 -366
  68. package/dist/program-BARSNg3X.d.ts +286 -0
  69. package/dist/program-znrWkxE4.d.cts +286 -0
  70. package/dist/repositories/realm/index.cjs +71 -51
  71. package/dist/repositories/realm/index.cjs.map +1 -1
  72. package/dist/repositories/realm/index.d.cts +20 -9
  73. package/dist/repositories/realm/index.d.ts +20 -9
  74. package/dist/repositories/realm/index.js +42 -23
  75. package/dist/repositories/realm/index.js.map +1 -1
  76. package/dist/repositories/sqlite/index.cjs +81 -56
  77. package/dist/repositories/sqlite/index.cjs.map +1 -1
  78. package/dist/repositories/sqlite/index.d.cts +17 -8
  79. package/dist/repositories/sqlite/index.d.ts +17 -8
  80. package/dist/repositories/sqlite/index.js +55 -31
  81. package/dist/repositories/sqlite/index.js.map +1 -1
  82. package/dist/{taskRunner-CDlNeth0.d.ts → taskRunner-BM6IAKlS.d.ts} +2 -2
  83. package/dist/{taskRunner-BPPU-YHG.d.cts → taskRunner-BmDIZiSl.d.cts} +2 -2
  84. package/dist/wallet/expo/background.cjs +17 -14
  85. package/dist/wallet/expo/background.cjs.map +1 -1
  86. package/dist/wallet/expo/background.d.cts +5 -4
  87. package/dist/wallet/expo/background.d.ts +5 -4
  88. package/dist/wallet/expo/background.js +9 -6
  89. package/dist/wallet/expo/background.js.map +1 -1
  90. package/dist/wallet/expo/index.cjs +29 -16
  91. package/dist/wallet/expo/index.cjs.map +1 -1
  92. package/dist/wallet/expo/index.d.cts +12 -7
  93. package/dist/wallet/expo/index.d.ts +12 -7
  94. package/dist/wallet/expo/index.js +19 -6
  95. package/dist/wallet/expo/index.js.map +1 -1
  96. package/dist/worker/expo/index.cjs +12 -9
  97. package/dist/worker/expo/index.cjs.map +1 -1
  98. package/dist/worker/expo/index.d.cts +6 -5
  99. package/dist/worker/expo/index.d.ts +6 -5
  100. package/dist/worker/expo/index.js +8 -5
  101. package/dist/worker/expo/index.js.map +1 -1
  102. package/package.json +16 -1
  103. package/dist/chunk-6CUP6ZIF.js.map +0 -1
  104. package/dist/chunk-AG4TFD6F.js.map +0 -1
  105. package/dist/chunk-BTRCN4JJ.js.map +0 -1
  106. package/dist/chunk-DNITZVNG.cjs.map +0 -1
  107. package/dist/chunk-E6OOJEHL.cjs.map +0 -1
  108. package/dist/chunk-F3FAE7VJ.cjs.map +0 -1
  109. package/dist/chunk-GHUUT54D.cjs.map +0 -1
  110. package/dist/chunk-TUOLZBNC.js.map +0 -1
  111. package/dist/chunk-WXNSISXK.cjs.map +0 -1
  112. package/dist/chunk-ZJHLLDBP.js.map +0 -1
package/README.md CHANGED
@@ -398,6 +398,68 @@ import { Ramps } from '@arkade-os/sdk'
398
398
  const boardingTxId = await new Ramps(wallet).onboard();
399
399
  ```
400
400
 
401
+ ### Onchain cosigning
402
+
403
+ Boarding UTXOs and server-supported unrolled virtual outputs can be spent immediately with a server cosignature, without waiting for the exit timelock or joining a batch. This needs an Arkade server that exposes onchain cosigning (`POST /v1/tx/onchain/cosign`) and accepts the selected coin type; automatic flows fall back to the previous paths on an unsupported endpoint or a definite server rejection.
404
+
405
+ ```typescript
406
+ // Pay onchain from boarding / unrolled coins
407
+ const txid = await wallet.sendOnchain({
408
+ outputs: [{ address: 'bc1q...', amount: 50_000 }]
409
+ })
410
+
411
+ // Sweep every cosignable onchain coin (inputs minus fee) to one address
412
+ await wallet.sendOnchain({ outputs: [], sweepTo: 'bc1q...' })
413
+
414
+ // Cosign a PSBT built elsewhere; returns the broadcast txid
415
+ await wallet.cosignOnchainTx(psbt) // base64 string or Transaction
416
+ ```
417
+
418
+ For `cosignOnchainTx`, foreign inputs must already be signed but not finalized: the wallet signs only its own inputs, and arkd refuses a finalized input and finalizes the transaction itself.
419
+
420
+ Preflight: a confirmed wallet input must be more than `onchainCosignMarginBlocks` (wallet config, default 6) blocks from exit maturity; an unconfirmed one is accepted, since its exit cannot have matured. arkd cosigns at most 64 inputs, so a sweep takes the 64 largest coins and leaves the rest for the next one. Failures surface as `OnchainCosignPreflightError` (nothing was submitted), `OnchainCosignRejectedError` (server refused; `arkErrorName` holds its error code) or `OnchainCosignUnsupportedError` (server lacks the endpoint). Use `isCosignFallback(e)` to decide whether paying another way is safe; the automatic paths below do exactly that:
421
+
422
+ ```typescript
423
+ import { isCosignFallback, OnchainCosignAmbiguousError } from '@arkade-os/sdk'
424
+
425
+ try {
426
+ await wallet.sendOnchain({ outputs: [{ address, amount }] })
427
+ } catch (e) {
428
+ if (!isCosignFallback(e)) throw e // includes OnchainCosignAmbiguousError
429
+ await payThroughABatch()
430
+ }
431
+ ```
432
+
433
+ `OnchainCosignAmbiguousError` means the transaction may have been broadcast (a transport failure, or a server error after submission): do not retry with other coins. The inputs stay pending until the chain resolves.
434
+
435
+ Contracts carry a `scope`: `"offchain"`, `"onchain"` or `"both"`. It controls whether the contract's onchain coins are watched and spent through cosigning; boarding contracts default to `"onchain"`.
436
+
437
+ Automatic behaviour:
438
+
439
+ - `VtxoManager` renews boarding coins that are near expiry via cosign, falling back to the CSV path. It never sweeps unrolled outputs (that would undo the exit); spend those with `sendOnchain` or `cosignOnchainTx`.
440
+ - `Ramps.offboardExact` and the payment router's onchain rail spend onchain coins directly when they alone cover the amount; otherwise they use the batch path. `Ramps.offboard` always uses the batch path.
441
+
442
+ #### Arkade contracts
443
+
444
+ Arkade contracts can spend their own onchain UTXOs. Pass an `emulator` (cosigner for covenant leaves) and an `onchain` provider to `connect`:
445
+
446
+ ```typescript
447
+ import { arkade } from '@arkade-os/sdk'
448
+
449
+ const ark = await arkade.Arkade.connect({ arkade: arkProvider, emulator, onchain })
450
+ const contract = ark.contract(program)
451
+
452
+ const txid = await contract.functions
453
+ .claim(/* args */)
454
+ .from(utxo)
455
+ .to(destinationScript, 40_000n)
456
+ .onchainFee(500n) // must not exceed the surplus; without change() it must equal it
457
+ .change(changeScript)
458
+ .sendOnchain() // or .buildOnchain() for the unsigned Transaction
459
+ ```
460
+
461
+ Covenant leaves spent onchain must not include the Arkade server key; the emulator's onchain endpoint refuses them.
462
+
401
463
  ### Checking Balance
402
464
 
403
465
  ```typescript
@@ -414,7 +476,7 @@ const balance = await wallet.getBalance()
414
476
  | `preconfirmed` | Owned offchain funds not yet finalized in a batch. |
415
477
  | `available` | What `send` and every other automatic coin selection can spend now. |
416
478
  | `contractLocked` | Held by a contract that generic spending refuses (chiefly swap escrow); only that contract can spend it ([Contract Management](#contract-management)). |
417
- | `pendingSettlement` | Committed to an in-flight settlement intent; back in `available` when the intent ends. Always `0` without `storage.intentRepository`. |
479
+ | `pendingSettlement` | Committed to an in-flight batch registration; back in `available` when the registration ends. Always `0` without `storage.intentRepository`. |
418
480
  | `reserved` | Held by [`reserveVtxos`](#holding-vtxos-for-your-own-use) until released. |
419
481
  | `recoverable` | Swept or subdust virtual outputs that [`recoverVtxos`](#recovery-reclaim-swept-vtxos) can reclaim; `getRecoverableBalance()` gives what a batch would return today. |
420
482
  | `deprecatedSignerLocked` | Under an operator signer past its cutoff, which the operator no longer cosigns; recovers once swept and re-settled. |
@@ -804,8 +866,8 @@ const wallet = await Wallet.create({
804
866
  identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
805
867
  })
806
868
 
807
- // Get fee information from the server
808
- const { fees: feeInfo } = await wallet.getArkadeInfo();
869
+ // Get fee information from the operator
870
+ const { fees: feeInfo } = await wallet.getOperatorInfo();
809
871
 
810
872
  const exitTxid = await new Ramps(wallet).offboard(
811
873
  'bc1p...',
@@ -813,9 +875,9 @@ const exitTxid = await new Ramps(wallet).offboard(
813
875
  );
814
876
  ```
815
877
 
816
- `getArkadeInfo()` is part of the `IReadonlyWallet` interface, so the same call works on the
817
- service-worker and Expo wallets too. It answers with the server's live `ArkadeInfo`, falling back
818
- to the snapshot persisted at wallet construction when the server is unreachable.
878
+ `getOperatorInfo()` is part of the `IReadonlyWallet` interface, so the same call works on the
879
+ service-worker and Expo wallets too. It answers with the operator's live `OperatorInfo`, falling back
880
+ to the snapshot persisted at wallet construction when the operator is unreachable.
819
881
 
820
882
  ### Concurrent Spending & Coin Reservations
821
883
 
@@ -884,12 +946,12 @@ If your app keeps its own reserved-outpoint set, call `reserveVtxos` where you a
884
946
 
885
947
  ### Talking to the operator through the wallet
886
948
 
887
- `getArkadeInfo()` is one of three seams that let a plugin work from a wallet alone, never a
888
- server URL of its own:
949
+ `getOperatorInfo()` is one of three seams that let a plugin work from a wallet alone, never an
950
+ operator URL of its own:
889
951
 
890
952
  | Seam | Interface | For |
891
953
  | --- | --- | --- |
892
- | `getArkadeInfo()` | `IReadonlyWallet` | Network, signer key, delays, dust, fees, limits |
954
+ | `getOperatorInfo()` | `IReadonlyWallet` | Network, signer key, delays, dust, fees, limits |
893
955
  | `getArkadeReader()` | `IReadonlyWallet` | Chain reads for scripts the wallet does not own |
894
956
  | `getArkadeBroadcaster()` | `IWallet` | `submitTx` / `finalizeTx` |
895
957
 
@@ -1137,7 +1199,7 @@ import {
1137
1199
  WalletMessageHandler,
1138
1200
  IndexedDBWalletRepository,
1139
1201
  IndexedDBContractRepository,
1140
- IndexedDBIntentRepository,
1202
+ IndexedDBBatchRegistrationRepository,
1141
1203
  } from '@arkade-os/sdk'
1142
1204
 
1143
1205
  const walletRepo = new IndexedDBWalletRepository()
@@ -1147,10 +1209,10 @@ const bus = new MessageBus(walletRepo, contractRepo, {
1147
1209
  messageHandlers: [new WalletMessageHandler()],
1148
1210
  tickIntervalMs: 10_000, // default 10s
1149
1211
  // Optional, same opt-in as `storage.intentRepository` on a main-thread
1150
- // wallet. Omit it and the worker persists no settlement intent, reconciles
1151
- // none on restart, and counts intent-locked VTXOs as available
1212
+ // wallet. Omit it and the worker persists no batch registration, reconciles
1213
+ // none on restart, and counts registration-locked virtual outputs as available
1152
1214
  // (`pendingSettlement` stays 0).
1153
- intentRepository: new IndexedDBIntentRepository(),
1215
+ intentRepository: new IndexedDBBatchRegistrationRepository(),
1154
1216
  })
1155
1217
 
1156
1218
  bus.start()
@@ -1230,7 +1292,7 @@ SDK uses IndexedDB repositories with the default database name.
1230
1292
  #### Paged repository reads
1231
1293
 
1232
1294
  Collection repositories expose `getVtxosPage`, `getVtxosForScriptPage`, `getUtxosPage`,
1233
- `getTransactionHistoryPage`, `getContractsPage`, and `getIntentsPage`.
1295
+ `getTransactionHistoryPage`, `getContractsPage`, and `getBatchRegistrationsPage`.
1234
1296
  Each accepts `{ limit, after? }` and returns
1235
1297
  `{ items, nextCursor? }`; pass `nextCursor` as `after` until it is absent.
1236
1298
  Limits must be 1–500. History pages are ordered by `(createdAt, transaction key)`;
@@ -1238,7 +1300,7 @@ Limits must be 1–500. History pages are ordered by `(createdAt, transaction ke
1238
1300
  by their script and intent transaction ID. Filters must stay the same across
1239
1301
  pages. Repository collection reads use pages directly; `collectVtxos`,
1240
1302
  `collectScriptVtxos`, `collectUtxos`, `collectTransactionHistory`, `collectContracts`, and
1241
- `collectIntents` traverse all pages when a complete snapshot is required.
1303
+ `collectBatchRegistrations` traverse all pages when a complete snapshot is required.
1242
1304
  Wallet spending paths consume every VTXO or UTXO page before coin selection.
1243
1305
  In `@arkade-os/swap`, RFQ page `since` values use Unix seconds instead.
1244
1306
 
@@ -1256,7 +1318,7 @@ do {
1256
1318
 
1257
1319
  #### Repository Versioning
1258
1320
 
1259
- `WalletRepository`, `ContractRepository`, `IntentRepository`,
1321
+ `WalletRepository`, `ContractRepository`, `BatchRegistrationRepository`,
1260
1322
  `VirtualTxRepository`, and `AssetSwapRepository` (in `@arkade-os/swap`) each
1261
1323
  declare a `readonly version` field with a literal type. All built-in
1262
1324
  implementations set this to the current version. If you maintain a custom
@@ -1508,7 +1570,7 @@ import { arkade, Arkade, ArkAddress } from '@arkade-os/sdk'
1508
1570
 
1509
1571
  const program = arkade.programFromArtifact(artifactJson)
1510
1572
  const client = await Arkade.connect({
1511
- service: { network: 'bitcoin' }, // operator, indexer, esplora, and covenant cosigner
1573
+ service: { network: 'bitcoin' }, // operator, indexer and esplora
1512
1574
  identity: wallet.identity,
1513
1575
  contractManager: await wallet.getContractManager(),
1514
1576
  })
@@ -1532,6 +1594,30 @@ The connected operator supplies `<SERVER_KEY>` (the reserved `server` parameter
1532
1594
 
1533
1595
  For compiler-derived programs, call arguments are covenant inputs in declaration order, followed by non-signature leaf inputs in declaration order, one argument per source parameter: a struct or array input is passed whole, as in `contract.functions.spend(request, oracles)`. Same-named inputs in the two scopes remain separate positional arguments. Leaf signatures are PSBT signatures, not condition arguments: `send()` supports the connected identity and infrastructure signers; additional identities and covenant-tweaked leaf keys require explicit PSBT signing via `build()`. Covenant signature arguments remain caller-provided; transaction-bound Arkade `checkSig` signatures require an Arkade-specific digest helper, which is deferred. CSV leaves require aged onchain outputs and cannot use this offchain builder. Typed call validation and these spending limits apply to every normalized Program. The public `SignerRef` union is unchanged; version 1 programs store emulator signer placement in optional `emulatorIndex` metadata.
1534
1596
 
1597
+ #### Compiling Arkade source
1598
+
1599
+ `@arkade-os/sdk/compiler` compiles Arkade source into the same Program, without a separate compile step. It needs the optional peer `@arkade-os/compiler`, which you install and pin yourself: `npm install --save-exact @arkade-os/compiler`. The root SDK never loads it. `files` maps relative `.ark` paths to their source, and imports resolve relative to the importing file.
1600
+
1601
+ ```typescript
1602
+ import { compile, CompileError } from '@arkade-os/sdk/compiler'
1603
+
1604
+ try {
1605
+ const { program, diagnostics } = await compile({
1606
+ entry: 'contracts/vault.ark',
1607
+ files: { 'contracts/vault.ark': vaultSource, 'shared/limits.ark': limitsSource },
1608
+ })
1609
+ for (const d of diagnostics) console.warn(`${d.file}:${d.start?.line} ${d.message}`)
1610
+ const contract = client.contract(program, { owner, minimum: 1_000n })
1611
+ } catch (e) {
1612
+ if (e instanceof CompileError) for (const d of e.diagnostics) console.error(d.message)
1613
+ else throw e
1614
+ }
1615
+ ```
1616
+
1617
+ Warnings come back in `diagnostics`, and source errors reject with `CompileError`. The result's `artifact` is the compiler's raw output, with the source bundle, compiler version and fingerprint. CommonJS callers can `require('@arkade-os/sdk/compiler')`, which loads the ESM-only compiler through `import()` on the first call. In a browser, the bundler must emit the compiler's WASM asset; see the `@arkade-os/compiler` README.
1618
+
1619
+ By default the result also carries `debug`, the compiler's debug file, and each covenant in `program` carries its `sourceMap`: the `asm` range of each statement, its line and column in the entry file, and its `require()` message when it has one. Pass `{ debug: false }` to leave both out. A file written by `arkadec --debug` attaches the same way through `arkade.programFromArtifact(artifact, debug)`, which refuses a file whose fingerprint does not match the artifact's. Source maps live in memory only: `stringifyArtifact` does not write them, so a restored contract has none.
1620
+
1535
1621
  #### HD look-ahead window
1536
1622
 
1537
1623
  HD wallets (`walletMode: 'hd'`, or an explicit HD `DescriptorProvider`) also watch a band of *unused* offchain receive scripts around their allocation watermark, so a payment to an address that some other party issued from the same seed — a merchant backend such as BTCPay Server, or the .NET SDK driving the same wallet — arrives without the user calling `restore()`. `lookAheadWindow` (default `20`) is the per-side width of that band: the wallet watches `[watermark - N, watermark + N]`. Speculative entries are subscription-only; they become contract rows, and enter balances, only once funded.
@@ -1,22 +1,23 @@
1
1
  'use strict';
2
2
 
3
- var chunkDNITZVNG_cjs = require('../chunk-DNITZVNG.cjs');
4
- require('../chunk-WXNSISXK.cjs');
5
- require('../chunk-GHUUT54D.cjs');
3
+ var chunk4X67IB2V_cjs = require('../chunk-4X67IB2V.cjs');
4
+ require('../chunk-HKEPJBTY.cjs');
5
+ require('../chunk-LZAINCGU.cjs');
6
+ require('../chunk-FLPWNMX3.cjs');
6
7
 
7
8
 
8
9
 
9
10
  Object.defineProperty(exports, "ExpoArkProvider", {
10
11
  enumerable: true,
11
- get: function () { return chunkDNITZVNG_cjs.ExpoArkProvider; }
12
+ get: function () { return chunk4X67IB2V_cjs.ExpoArkProvider; }
12
13
  });
13
14
  Object.defineProperty(exports, "ExpoIndexerProvider", {
14
15
  enumerable: true,
15
- get: function () { return chunkDNITZVNG_cjs.ExpoIndexerProvider; }
16
+ get: function () { return chunk4X67IB2V_cjs.ExpoIndexerProvider; }
16
17
  });
17
18
  Object.defineProperty(exports, "ExpoOperatorProvider", {
18
19
  enumerable: true,
19
- get: function () { return chunkDNITZVNG_cjs.ExpoOperatorProvider; }
20
+ get: function () { return chunk4X67IB2V_cjs.ExpoOperatorProvider; }
20
21
  });
21
22
  //# sourceMappingURL=expo.cjs.map
22
23
  //# sourceMappingURL=expo.cjs.map
@@ -1,8 +1,9 @@
1
- import { r as RestOperatorProvider, o as SettlementEvent, T as TxNotificationEvent, s as RestIndexerProvider, t as SubscriptionEvent, u as SubscriptionHeartbeat } from '../index-DRwe0UDN.cjs';
2
- export { v as ArkProvider, w as IndexerProvider, O as OperatorProvider } from '../index-DRwe0UDN.cjs';
1
+ import { r as RestOperatorProvider, n as SettlementEvent, T as TxNotificationEvent, s as RestIndexerProvider, t as SubscriptionEvent, u as SubscriptionHeartbeat } from '../index-Dqk07NwJ.cjs';
2
+ export { v as ArkProvider, w as IndexerProvider, x as OperatorProvider } from '../index-Dqk07NwJ.cjs';
3
3
  import '@scure/btc-signer/utils.js';
4
- import '@scure/btc-signer/psbt.js';
5
4
  import '@scure/btc-signer';
5
+ import '@scure/btc-signer/psbt.js';
6
+ import '../base-C-Y5t_0F.cjs';
6
7
  import '@scure/btc-signer/transaction.js';
7
8
 
8
9
  /**
@@ -1,8 +1,9 @@
1
- import { r as RestOperatorProvider, o as SettlementEvent, T as TxNotificationEvent, s as RestIndexerProvider, t as SubscriptionEvent, u as SubscriptionHeartbeat } from '../index-DRwe0UDN.js';
2
- export { v as ArkProvider, w as IndexerProvider, O as OperatorProvider } from '../index-DRwe0UDN.js';
1
+ import { r as RestOperatorProvider, n as SettlementEvent, T as TxNotificationEvent, s as RestIndexerProvider, t as SubscriptionEvent, u as SubscriptionHeartbeat } from '../index-C66rjxz2.js';
2
+ export { v as ArkProvider, w as IndexerProvider, x as OperatorProvider } from '../index-C66rjxz2.js';
3
3
  import '@scure/btc-signer/utils.js';
4
- import '@scure/btc-signer/psbt.js';
5
4
  import '@scure/btc-signer';
5
+ import '@scure/btc-signer/psbt.js';
6
+ import '../base-C-Y5t_0F.js';
6
7
  import '@scure/btc-signer/transaction.js';
7
8
 
8
9
  /**
@@ -1,5 +1,6 @@
1
- export { ExpoArkProvider, ExpoIndexerProvider, ExpoOperatorProvider } from '../chunk-TUOLZBNC.js';
2
- import '../chunk-BTRCN4JJ.js';
3
- import '../chunk-AG4TFD6F.js';
1
+ export { ExpoArkProvider, ExpoIndexerProvider, ExpoOperatorProvider } from '../chunk-DJYX73W2.js';
2
+ import '../chunk-C7NY6WSA.js';
3
+ import '../chunk-QTMK34TP.js';
4
+ import '../chunk-FDJ734CH.js';
4
5
  //# sourceMappingURL=expo.js.map
5
6
  //# sourceMappingURL=expo.js.map
@@ -1,4 +1,4 @@
1
- import { c as TaskQueue, b as TaskItem, d as TaskResult } from './taskRunner-BPPU-YHG.cjs';
1
+ import { a as TaskQueue, c as TaskItem, d as TaskResult } from './taskRunner-BmDIZiSl.cjs';
2
2
 
3
3
  /**
4
4
  * Minimal async key-value storage interface.
@@ -46,4 +46,4 @@ declare class AsyncStorageTaskQueue implements TaskQueue {
46
46
  private writeList;
47
47
  }
48
48
 
49
- export { type AsyncStorageLike as A, AsyncStorageTaskQueue as a };
49
+ export { AsyncStorageTaskQueue as A, type AsyncStorageLike as a };
@@ -1,4 +1,4 @@
1
- import { c as TaskQueue, b as TaskItem, d as TaskResult } from './taskRunner-CDlNeth0.js';
1
+ import { a as TaskQueue, c as TaskItem, d as TaskResult } from './taskRunner-BM6IAKlS.js';
2
2
 
3
3
  /**
4
4
  * Minimal async key-value storage interface.
@@ -46,4 +46,4 @@ declare class AsyncStorageTaskQueue implements TaskQueue {
46
46
  private writeList;
47
47
  }
48
48
 
49
- export { type AsyncStorageLike as A, AsyncStorageTaskQueue as a };
49
+ export { AsyncStorageTaskQueue as A, type AsyncStorageLike as a };
@@ -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 };