@arkade-os/sdk 0.4.22 → 0.4.24

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 (105) hide show
  1. package/README.md +116 -13
  2. package/dist/cjs/contracts/arkcontract.js +2 -1
  3. package/dist/cjs/contracts/contractManager.js +29 -4
  4. package/dist/cjs/contracts/contractWatcher.js +9 -3
  5. package/dist/cjs/contracts/handlers/default.js +3 -2
  6. package/dist/cjs/contracts/handlers/delegate.js +3 -2
  7. package/dist/cjs/contracts/handlers/helpers.js +2 -58
  8. package/dist/cjs/contracts/handlers/vhtlc.js +7 -6
  9. package/dist/cjs/contracts/vtxoOwnership.js +60 -0
  10. package/dist/cjs/identity/descriptor.js +75 -4
  11. package/dist/cjs/identity/hdCapableIdentity.js +2 -0
  12. package/dist/cjs/identity/seedIdentity.js +225 -103
  13. package/dist/cjs/identity/serialize.js +5 -0
  14. package/dist/cjs/identity/staticDescriptorProvider.js +1 -1
  15. package/dist/cjs/index.js +12 -3
  16. package/dist/cjs/providers/electrum.js +285 -79
  17. package/dist/cjs/providers/expoIndexer.js +1 -1
  18. package/dist/cjs/providers/indexer.js +2 -2
  19. package/dist/cjs/providers/onchain.js +9 -3
  20. package/dist/cjs/repositories/migrations/walletRepositoryImpl.js +6 -2
  21. package/dist/cjs/repositories/realm/walletRepository.js +2 -2
  22. package/dist/cjs/repositories/serialization.js +34 -1
  23. package/dist/cjs/repositories/sqlite/walletRepository.js +4 -2
  24. package/dist/cjs/script/address.js +2 -1
  25. package/dist/cjs/script/base.js +12 -47
  26. package/dist/cjs/script/tapscript.js +97 -73
  27. package/dist/cjs/utils/timelock.js +59 -0
  28. package/dist/cjs/utils/transactionHistory.js +4 -4
  29. package/dist/cjs/utils/unknownFields.js +2 -39
  30. package/dist/cjs/wallet/asset-manager.js +18 -18
  31. package/dist/cjs/wallet/asset.js +10 -8
  32. package/dist/cjs/wallet/delegator.js +2 -2
  33. package/dist/cjs/wallet/hdDescriptorProvider.js +159 -0
  34. package/dist/cjs/wallet/index.js +5 -1
  35. package/dist/cjs/wallet/onchain.js +2 -1
  36. package/dist/cjs/wallet/serviceWorker/wallet-message-handler.js +60 -10
  37. package/dist/cjs/wallet/serviceWorker/wallet.js +5 -4
  38. package/dist/cjs/wallet/unroll.js +79 -67
  39. package/dist/cjs/wallet/validation.js +2 -3
  40. package/dist/cjs/wallet/wallet.js +91 -22
  41. package/dist/cjs/worker/expo/processors/contractPollProcessor.js +7 -2
  42. package/dist/esm/contracts/arkcontract.js +2 -1
  43. package/dist/esm/contracts/contractManager.js +29 -4
  44. package/dist/esm/contracts/contractWatcher.js +9 -3
  45. package/dist/esm/contracts/handlers/default.js +2 -1
  46. package/dist/esm/contracts/handlers/delegate.js +2 -1
  47. package/dist/esm/contracts/handlers/helpers.js +1 -22
  48. package/dist/esm/contracts/handlers/vhtlc.js +2 -1
  49. package/dist/esm/contracts/vtxoOwnership.js +53 -0
  50. package/dist/esm/identity/descriptor.js +74 -5
  51. package/dist/esm/identity/hdCapableIdentity.js +1 -0
  52. package/dist/esm/identity/seedIdentity.js +225 -103
  53. package/dist/esm/identity/serialize.js +5 -0
  54. package/dist/esm/identity/staticDescriptorProvider.js +1 -1
  55. package/dist/esm/index.js +7 -4
  56. package/dist/esm/providers/electrum.js +284 -78
  57. package/dist/esm/providers/expoIndexer.js +1 -1
  58. package/dist/esm/providers/indexer.js +2 -2
  59. package/dist/esm/providers/onchain.js +9 -3
  60. package/dist/esm/repositories/migrations/walletRepositoryImpl.js +6 -2
  61. package/dist/esm/repositories/realm/walletRepository.js +3 -3
  62. package/dist/esm/repositories/serialization.js +27 -0
  63. package/dist/esm/repositories/sqlite/walletRepository.js +5 -3
  64. package/dist/esm/script/address.js +2 -1
  65. package/dist/esm/script/base.js +12 -14
  66. package/dist/esm/script/tapscript.js +97 -40
  67. package/dist/esm/utils/timelock.js +22 -0
  68. package/dist/esm/utils/transactionHistory.js +4 -4
  69. package/dist/esm/utils/unknownFields.js +2 -6
  70. package/dist/esm/wallet/asset-manager.js +18 -18
  71. package/dist/esm/wallet/asset.js +10 -8
  72. package/dist/esm/wallet/delegator.js +2 -2
  73. package/dist/esm/wallet/hdDescriptorProvider.js +155 -0
  74. package/dist/esm/wallet/index.js +4 -0
  75. package/dist/esm/wallet/onchain.js +2 -1
  76. package/dist/esm/wallet/serviceWorker/wallet-message-handler.js +60 -10
  77. package/dist/esm/wallet/serviceWorker/wallet.js +5 -4
  78. package/dist/esm/wallet/unroll.js +78 -67
  79. package/dist/esm/wallet/validation.js +2 -3
  80. package/dist/esm/wallet/wallet.js +88 -20
  81. package/dist/esm/worker/expo/processors/contractPollProcessor.js +7 -2
  82. package/dist/types/contracts/arkcontract.d.ts +1 -1
  83. package/dist/types/contracts/handlers/helpers.d.ts +0 -9
  84. package/dist/types/contracts/vtxoOwnership.d.ts +25 -0
  85. package/dist/types/identity/descriptor.d.ts +26 -0
  86. package/dist/types/identity/descriptorProvider.d.ts +11 -4
  87. package/dist/types/identity/hdCapableIdentity.d.ts +44 -0
  88. package/dist/types/identity/index.d.ts +1 -0
  89. package/dist/types/identity/seedIdentity.d.ts +113 -29
  90. package/dist/types/identity/serialize.d.ts +12 -0
  91. package/dist/types/identity/staticDescriptorProvider.d.ts +1 -1
  92. package/dist/types/index.d.ts +6 -3
  93. package/dist/types/providers/electrum.d.ts +115 -15
  94. package/dist/types/providers/onchain.d.ts +6 -0
  95. package/dist/types/repositories/serialization.d.ts +26 -2
  96. package/dist/types/script/address.d.ts +1 -1
  97. package/dist/types/script/tapscript.d.ts +4 -0
  98. package/dist/types/utils/timelock.d.ts +9 -0
  99. package/dist/types/wallet/hdDescriptorProvider.d.ts +93 -0
  100. package/dist/types/wallet/index.d.ts +19 -10
  101. package/dist/types/wallet/onchain.d.ts +1 -1
  102. package/dist/types/wallet/serviceWorker/wallet.d.ts +1 -1
  103. package/dist/types/wallet/unroll.d.ts +10 -0
  104. package/dist/types/wallet/wallet.d.ts +4 -1
  105. package/package.json +1 -1
@@ -4,6 +4,11 @@ import type { Identity, ReadonlyIdentity } from ".";
4
4
  * service-worker boundary. All variants are structured-clone safe
5
5
  * (plain strings only — no functions or prototypes).
6
6
  *
7
+ * `descriptor` carries the wildcard *template* (e.g.
8
+ * `tr([fp/86'/0'/0']xpub.../0/*)`), not a concrete index — the
9
+ * receiving factories require a template, and storing it directly
10
+ * means nothing here has to convert concrete → template on rehydrate.
11
+ *
7
12
  * Adding a new variant is a source change in every worker build; keep
8
13
  * old variants around until all deployed workers handle them.
9
14
  */
@@ -23,6 +28,8 @@ export type SerializedSigningIdentity = {
23
28
  /**
24
29
  * Tagged envelope for a readonly identity transported across the
25
30
  * service-worker boundary. All variants are structured-clone safe.
31
+ * `descriptor` is the wildcard template (see
32
+ * {@link SerializedSigningIdentity}).
26
33
  */
27
34
  export type SerializedReadonlyIdentity = {
28
35
  type: "readonly-single-key";
@@ -57,6 +64,11 @@ export declare function serializeReadonlyIdentity(identity: ReadonlyIdentity): P
57
64
  * The return type is the union of signing and readonly; use
58
65
  * {@link isSigningSerialized} on the envelope before hydration if the caller
59
66
  * needs to know which side it ends up on.
67
+ *
68
+ * Envelopes store the wildcard template directly (see
69
+ * `serializeSeedOwnedSigningIdentity` / `serializeSeedOwnedReadonlyIdentity`),
70
+ * so the `descriptor` field is passed straight through to the
71
+ * template-only factories.
60
72
  */
61
73
  export declare function hydrateIdentity(s: SerializedIdentity): Identity | ReadonlyIdentity;
62
74
  /**
@@ -11,7 +11,7 @@ export declare class StaticDescriptorProvider implements DescriptorProvider {
11
11
  private readonly pubKeyHex;
12
12
  constructor(identity: Identity, pubKeyHex: string);
13
13
  static create(identity: Identity): Promise<StaticDescriptorProvider>;
14
- getSigningDescriptor(): string;
14
+ getNextSigningDescriptor(): Promise<string>;
15
15
  isOurs(descriptor: string): boolean;
16
16
  signWithDescriptor(requests: DescriptorSigningRequest[]): Promise<Transaction[]>;
17
17
  signMessageWithDescriptor(descriptor: string, message: Uint8Array, type?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
@@ -15,6 +15,7 @@ import { Wallet, ReadonlyWallet, waitForIncomingFunds, IncomingFunds } from "./w
15
15
  import { TxTree, TxTreeNode } from "./tree/txTree";
16
16
  import { SignerSession, TreeNonces, TreePartialSigs } from "./tree/signingSession";
17
17
  import { Ramps } from "./wallet/ramps";
18
+ import { HDDescriptorProvider } from "./wallet/hdDescriptorProvider";
18
19
  import { isVtxoExpiringSoon, VtxoManager } from "./wallet/vtxo-manager";
19
20
  import type { IVtxoManager, SettlementConfig } from "./wallet/vtxo-manager";
20
21
  import { ServiceWorkerWallet, ServiceWorkerReadonlyWallet, DEFAULT_MESSAGE_TIMEOUTS } from "./wallet/serviceWorker/wallet";
@@ -22,7 +23,7 @@ import type { MessageTimeouts } from "./wallet/serviceWorker/wallet";
22
23
  import { OnchainWallet } from "./wallet/onchain";
23
24
  import { setupServiceWorker } from "./worker/browser/utils";
24
25
  import { ESPLORA_URL, EsploraProvider, OnchainProvider, ExplorerTransaction } from "./providers/onchain";
25
- import { ElectrumOnchainProvider, WsElectrumChainSource } from "./providers/electrum";
26
+ import { ELECTRUM_TCP_HOST, ELECTRUM_WS_URL, ElectrumOnchainProvider, WsElectrumChainSource } from "./providers/electrum";
26
27
  import type { TransactionHistory as ElectrumTransactionHistory, BlockHeader as ElectrumBlockHeader, Unspent as ElectrumUnspent } from "./providers/electrum";
27
28
  import { RestArkProvider, ArkProvider, SettlementEvent, SettlementEventType, ArkInfo, SignedIntent, Output, TxNotification, BatchFinalizationEvent, BatchFinalizedEvent, BatchFailedEvent, TreeSigningStartedEvent, TreeNoncesEvent, BatchStartedEvent, TreeTxEvent, TreeSignatureEvent, ScheduledSession, FeeInfo } from "./providers/ark";
28
29
  import { DelegatorProvider, DelegateInfo, DelegateOptions, RestDelegatorProvider } from "./providers/delegator";
@@ -37,6 +38,7 @@ import { RestIndexerProvider, IndexerProvider, IndexerTxType, ChainTxType, PageR
37
38
  import { Nonces } from "./musig2/nonces";
38
39
  import { PartialSig } from "./musig2/sign";
39
40
  import { AnchorBumper, P2A } from "./utils/anchor";
41
+ import { TxWeightEstimator, type VSize } from "./utils/txSizeEstimator";
40
42
  import { Unroll } from "./wallet/unroll";
41
43
  import { ArkError, maybeArkError } from "./providers/errors";
42
44
  import { validateVtxoTxGraph, validateConnectorsTxGraph } from "./tree/validation";
@@ -49,8 +51,9 @@ export * as asset from "./extension/asset";
49
51
  import { ContractManager, ContractWatcher, contractHandlers, DefaultContractHandler, DelegateContractHandler, VHTLCContractHandler, encodeArkContract, decodeArkContract, contractFromArkContract, contractFromArkContractWithAddress, isArkContract } from "./contracts";
50
52
  import type { Contract, ContractVtxo, ContractState, ContractEvent, ContractEventCallback, ContractBalance, ContractWithVtxos, ContractHandler, PathSelection, PathContext, ContractManagerConfig, CreateContractParams, ContractWatcherConfig, ParsedArkContract, DefaultContractParams, DelegateContractParams, VHTLCContractParams } from "./contracts";
51
53
  import { IContractManager } from "./contracts/contractManager";
54
+ import { timelockToSequence, sequenceToTimelock } from "./utils/timelock";
52
55
  import { closeDatabase, openDatabase } from "./repositories/indexedDB/manager";
53
56
  import { WalletMessageHandler, WalletNotInitializedError, ReadonlyWalletError, DelegatorNotConfiguredError } from "./wallet/serviceWorker/wallet-message-handler";
54
57
  import { MESSAGE_BUS_NOT_INITIALIZED, MessageBusNotInitializedError, ServiceWorkerTimeoutError } from "./worker/errors";
55
- export { Wallet, ReadonlyWallet, SingleKey, ReadonlySingleKey, SeedIdentity, MnemonicIdentity, ReadonlyDescriptorIdentity, isBatchSignable, OnchainWallet, Ramps, VtxoManager, DelegatorManagerImpl, RestDelegatorProvider, ESPLORA_URL, EsploraProvider, ElectrumOnchainProvider, WsElectrumChainSource, RestArkProvider, RestIndexerProvider, ArkAddress, DefaultVtxo, DelegateVtxo, VtxoScript, VHTLC, TxType, IndexerTxType, ChainTxType, SettlementEventType, setupServiceWorker, MessageBus, WalletMessageHandler, WalletNotInitializedError, ReadonlyWalletError, DelegatorNotConfiguredError, MESSAGE_BUS_NOT_INITIALIZED, MessageBusNotInitializedError, ServiceWorkerTimeoutError, ServiceWorkerWallet, ServiceWorkerReadonlyWallet, DEFAULT_MESSAGE_TIMEOUTS, decodeTapscript, MultisigTapscript, CSVMultisigTapscript, ConditionCSVMultisigTapscript, ConditionMultisigTapscript, CLTVMultisigTapscript, TapTreeCoder, ArkPsbtFieldKey, ArkPsbtFieldKeyType, setArkPsbtField, getArkPsbtFields, CosignerPublicKey, VtxoTreeExpiry, VtxoTaprootTree, ConditionWitness, buildOffchainTx, verifyTapscriptSignatures, waitForIncomingFunds, hasBoardingTxExpired, combineTapscriptSigs, isVtxoExpiringSoon, isValidArkAddress, ArkNote, networks, closeDatabase, openDatabase, IndexedDBWalletRepository, IndexedDBContractRepository, InMemoryWalletRepository, InMemoryContractRepository, MIGRATION_KEY, migrateWalletRepository, requiresMigration, getMigrationStatus, rollbackMigration, WalletRepositoryImpl, ContractRepositoryImpl, Intent, BIP322, TxTree, P2A, Unroll, Transaction, ArkError, maybeArkError, Batch, validateVtxoTxGraph, validateConnectorsTxGraph, buildForfeitTx, isRecoverable, isSpendable, isSubdust, isExpired, getSequence, ContractManager, ContractWatcher, contractHandlers, DefaultContractHandler, DelegateContractHandler, VHTLCContractHandler, encodeArkContract, decodeArkContract, contractFromArkContract, contractFromArkContractWithAddress, isArkContract, };
56
- export type { Identity, ReadonlyIdentity, BatchSignableIdentity, SignRequest, IWallet, IReadonlyWallet, BaseWalletConfig, WalletConfig, ReadonlyWalletConfig, ProviderClass, ArkTransaction, Coin, ExtendedCoin, ExtendedVirtualCoin, WalletBalance, SendBitcoinParams, SettleParams, Status, VirtualStatus, Outpoint, VirtualCoin, TxKey, TapscriptType, ArkTxInput, OffchainTx, TapLeaves, IncomingFunds, SeedIdentityOptions, MnemonicOptions, NetworkOptions, DescriptorOptions, IndexerProvider, PageResponse, BatchInfo, ChainTx, CommitmentTx, TxHistoryRecord, Vtxo, VtxoChain, Tx, OnchainProvider, ArkProvider, SettlementEvent, FeeInfo, ArkInfo, SignedIntent, Output, TxNotification, ExplorerTransaction, ElectrumTransactionHistory, ElectrumBlockHeader, ElectrumUnspent, BatchFinalizationEvent, BatchFinalizedEvent, BatchFailedEvent, TreeSigningStartedEvent, TreeNoncesEvent, BatchStartedEvent, TreeTxEvent, TreeSignatureEvent, ScheduledSession, PaginationOptions, SubscriptionResponse, SubscriptionHeartbeat, SubscriptionEvent, Network, NetworkName, ArkTapscript, RelativeTimelock, EncodedVtxoScript, TapLeafScript, SignerSession, TreeNonces, TreePartialSigs, GetVtxosFilter, SettlementConfig, IVtxoManager, Asset, Recipient, IssuanceParams, IssuanceResult, ReissuanceParams, BurnParams, AssetDetails, AssetMetadata, KnownMetadata, Nonces, PartialSig, ArkPsbtFieldCoder, TxTreeNode, AnchorBumper, StorageConfig, Contract, ContractVtxo, ContractState, ContractEvent, ContractEventCallback, ContractBalance, ContractWithVtxos, ContractHandler, IContractManager, PathSelection, PathContext, ContractManagerConfig, CreateContractParams, ContractWatcherConfig, ParsedArkContract, DefaultContractParams, DelegateContractParams, VHTLCContractParams, MessageHandler, RequestEnvelope, ResponseEnvelope, MessageTimeouts, IDelegatorManager, DelegatorProvider, DelegateInfo, DelegateOptions, WalletRepository, ContractRepository, MigrationStatus, };
58
+ export { Wallet, ReadonlyWallet, SingleKey, ReadonlySingleKey, SeedIdentity, MnemonicIdentity, ReadonlyDescriptorIdentity, isBatchSignable, OnchainWallet, Ramps, VtxoManager, HDDescriptorProvider, DelegatorManagerImpl, RestDelegatorProvider, ESPLORA_URL, EsploraProvider, ELECTRUM_WS_URL, ELECTRUM_TCP_HOST, ElectrumOnchainProvider, WsElectrumChainSource, RestArkProvider, RestIndexerProvider, ArkAddress, DefaultVtxo, DelegateVtxo, VtxoScript, VHTLC, TxType, IndexerTxType, ChainTxType, SettlementEventType, setupServiceWorker, MessageBus, WalletMessageHandler, WalletNotInitializedError, ReadonlyWalletError, DelegatorNotConfiguredError, MESSAGE_BUS_NOT_INITIALIZED, MessageBusNotInitializedError, ServiceWorkerTimeoutError, ServiceWorkerWallet, ServiceWorkerReadonlyWallet, DEFAULT_MESSAGE_TIMEOUTS, decodeTapscript, MultisigTapscript, CSVMultisigTapscript, ConditionCSVMultisigTapscript, ConditionMultisigTapscript, CLTVMultisigTapscript, TapTreeCoder, ArkPsbtFieldKey, ArkPsbtFieldKeyType, setArkPsbtField, getArkPsbtFields, CosignerPublicKey, VtxoTreeExpiry, VtxoTaprootTree, ConditionWitness, buildOffchainTx, verifyTapscriptSignatures, waitForIncomingFunds, hasBoardingTxExpired, combineTapscriptSigs, isVtxoExpiringSoon, isValidArkAddress, ArkNote, networks, closeDatabase, openDatabase, IndexedDBWalletRepository, IndexedDBContractRepository, InMemoryWalletRepository, InMemoryContractRepository, MIGRATION_KEY, migrateWalletRepository, requiresMigration, getMigrationStatus, rollbackMigration, WalletRepositoryImpl, ContractRepositoryImpl, Intent, BIP322, TxTree, P2A, Unroll, Transaction, TxWeightEstimator, timelockToSequence, sequenceToTimelock, ArkError, maybeArkError, Batch, validateVtxoTxGraph, validateConnectorsTxGraph, buildForfeitTx, isRecoverable, isSpendable, isSubdust, isExpired, getSequence, ContractManager, ContractWatcher, contractHandlers, DefaultContractHandler, DelegateContractHandler, VHTLCContractHandler, encodeArkContract, decodeArkContract, contractFromArkContract, contractFromArkContractWithAddress, isArkContract, };
59
+ export type { Identity, ReadonlyIdentity, BatchSignableIdentity, SignRequest, IWallet, IReadonlyWallet, BaseWalletConfig, WalletConfig, ReadonlyWalletConfig, ProviderClass, ArkTransaction, Coin, ExtendedCoin, ExtendedVirtualCoin, WalletBalance, SendBitcoinParams, SettleParams, Status, VirtualStatus, Outpoint, VirtualCoin, TxKey, TapscriptType, ArkTxInput, OffchainTx, TapLeaves, IncomingFunds, SeedIdentityOptions, MnemonicOptions, NetworkOptions, DescriptorOptions, IndexerProvider, PageResponse, BatchInfo, ChainTx, CommitmentTx, TxHistoryRecord, Vtxo, VtxoChain, Tx, OnchainProvider, ArkProvider, SettlementEvent, FeeInfo, ArkInfo, SignedIntent, Output, TxNotification, ExplorerTransaction, ElectrumTransactionHistory, ElectrumBlockHeader, ElectrumUnspent, BatchFinalizationEvent, BatchFinalizedEvent, BatchFailedEvent, TreeSigningStartedEvent, TreeNoncesEvent, BatchStartedEvent, TreeTxEvent, TreeSignatureEvent, ScheduledSession, PaginationOptions, SubscriptionResponse, SubscriptionHeartbeat, SubscriptionEvent, Network, NetworkName, ArkTapscript, RelativeTimelock, EncodedVtxoScript, TapLeafScript, SignerSession, TreeNonces, TreePartialSigs, GetVtxosFilter, SettlementConfig, IVtxoManager, Asset, Recipient, IssuanceParams, IssuanceResult, ReissuanceParams, BurnParams, AssetDetails, AssetMetadata, KnownMetadata, Nonces, PartialSig, ArkPsbtFieldCoder, TxTreeNode, AnchorBumper, VSize, StorageConfig, Contract, ContractVtxo, ContractState, ContractEvent, ContractEventCallback, ContractBalance, ContractWithVtxos, ContractHandler, IContractManager, PathSelection, PathContext, ContractManagerConfig, CreateContractParams, ContractWatcherConfig, ParsedArkContract, DefaultContractParams, DelegateContractParams, VHTLCContractParams, MessageHandler, RequestEnvelope, ResponseEnvelope, MessageTimeouts, IDelegatorManager, DelegatorProvider, DelegateInfo, DelegateOptions, WalletRepository, ContractRepository, MigrationStatus, };
@@ -1,7 +1,39 @@
1
1
  import type { ElectrumWS } from "ws-electrumx-client";
2
- import type { Network } from "../networks";
2
+ import type { Network, NetworkName } from "../networks";
3
3
  import type { Coin } from "../wallet";
4
4
  import type { ExplorerTransaction, OnchainProvider } from "./onchain";
5
+ /**
6
+ * Default WebSocket Electrum endpoints. Mainnet, mutinynet, and signet
7
+ * point at Ark Labs–operated Fulcrum 2.1 deployments (which support
8
+ * `blockchain.transaction.broadcast_package` for atomic 1P1C TRUC
9
+ * relay; see `ElectrumOnchainProvider.broadcastTransaction`). Testnet
10
+ * defaults to Blockstream's public Fulcrum because Ark doesn't host
11
+ * it. Regtest assumes the `electrum-ws` websocat bridge from
12
+ * `vulpemventures/nigiri`.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { ElectrumWS } from "ws-electrumx-client";
17
+ * import { ELECTRUM_WS_URL, ElectrumOnchainProvider, networks } from "@arkade-os/sdk";
18
+ *
19
+ * const ws = new ElectrumWS(ELECTRUM_WS_URL.bitcoin);
20
+ * const provider = new ElectrumOnchainProvider(ws, networks.bitcoin);
21
+ * ```
22
+ */
23
+ export declare const ELECTRUM_WS_URL: Record<NetworkName, string>;
24
+ /**
25
+ * Hostnames for Electrum endpoints reachable over raw TCP. Provided as
26
+ * a reference for Node-side consumers — the SDK's
27
+ * {@link ElectrumOnchainProvider} only speaks WebSocket because it has
28
+ * to run in browsers, so this map is informational only and not
29
+ * consumed by any built-in provider.
30
+ *
31
+ * Public Ark Labs Fulcrum instances expose:
32
+ * - port 50001 — plain TCP (Electrum protocol)
33
+ * - port 50002 — TCP + TLS (Electrum protocol)
34
+ * - port 50003 — WebSocket (Electrum-over-WS, see {@link ELECTRUM_WS_URL})
35
+ */
36
+ export declare const ELECTRUM_TCP_HOST: Record<NetworkName, string | null>;
5
37
  export type TransactionHistory = {
6
38
  tx_hash: string;
7
39
  height: number;
@@ -70,12 +102,46 @@ export declare class WsElectrumChainSource {
70
102
  private cachedTip;
71
103
  private headersSubscribePromise;
72
104
  constructor(ws: ElectrumWS, network: Network);
105
+ /**
106
+ * Send N requests in parallel and aggregate the results, replacement
107
+ * for `ws.batchRequest`. The library's batchRequest is implemented as
108
+ * `Promise.all` over individual request promises — when one element
109
+ * rejects, the others remain pending. When their (often error)
110
+ * responses arrive later, the library rejects them too, and nobody is
111
+ * awaiting them: the rejections become unhandled and crash the test
112
+ * runner / pollute production logs.
113
+ *
114
+ * `safeBatchRequest` issues each request through `ws.request` (so each
115
+ * has its own request-promise lifecycle), waits for all of them via
116
+ * `Promise.allSettled` (every promise gets an explicit handler), and
117
+ * then surfaces the first error if any failed. Same wall-clock cost
118
+ * as the library's batch (parallel send), no orphan rejections.
119
+ *
120
+ * Use this in place of `ws.batchRequest` for any call where one or
121
+ * more elements may legitimately error (e.g. electrs index lag
122
+ * surfacing as `missingheight` for a subset of heights/txids).
123
+ */
124
+ safeBatchRequest<T>(requests: {
125
+ method: string;
126
+ params: unknown[];
127
+ }[]): Promise<T[]>;
73
128
  fetchTransactions(txids: string[]): Promise<{
74
129
  txID: string;
75
130
  hex: string;
76
131
  }[]>;
77
132
  fetchVerboseTransaction(txid: string): Promise<VerboseTransaction>;
78
133
  fetchVerboseTransactions(txids: string[]): Promise<VerboseTransaction[]>;
134
+ /**
135
+ * Look up the block height of a confirmed transaction without relying
136
+ * on the verbose-tx endpoint. `blockchain.transaction.get_merkle` is
137
+ * part of the standard SPV protocol and is supported by both Fulcrum
138
+ * and electrs (whereas `blockchain.transaction.get` with verbose=true
139
+ * is Fulcrum-only). Returns `null` when the tx is in the mempool —
140
+ * electrs in that case rejects with a "not yet in a block" error.
141
+ */
142
+ fetchTxMerkle(txid: string): Promise<{
143
+ blockHeight: number;
144
+ } | null>;
79
145
  unsubscribeScriptStatus(script: Uint8Array): Promise<void>;
80
146
  subscribeScriptStatus(script: Uint8Array, callback: (scripthash: string, status: string | null) => void): Promise<void>;
81
147
  fetchHistories(scripts: Uint8Array[]): Promise<TransactionHistory[][]>;
@@ -130,19 +196,45 @@ export declare class WsElectrumChainSource {
130
196
  addressForScript(scriptHex: string): string | undefined;
131
197
  }
132
198
  /**
133
- * Electrum-based implementation of the OnchainProvider interface.
134
- * Replaces esplora polling with electrum subscriptions where possible.
199
+ * Electrum-based implementation of the {@link OnchainProvider} interface.
135
200
  *
136
- * @example
201
+ * Built around the subset of the Electrum protocol that both **Fulcrum**
202
+ * and **electrs** support — listunspent, get_history, transaction.get
203
+ * (non-verbose), transaction.get_merkle, block.header,
204
+ * headers.subscribe, scripthash.subscribe, estimatefee, relayfee, and
205
+ * broadcast. The verbose form of `transaction.get` is **not** used (it's
206
+ * Fulcrum-only and rejected by electrs); confirmation status is derived
207
+ * from `transaction.get_merkle` plus parsed block headers.
208
+ *
209
+ * Output amounts are derived from parsed raw transaction bytes (exact
210
+ * bigints), never the floating-point `value` fields some servers return.
211
+ *
212
+ * Atomic 1P1C package broadcast (TRUC / BIP 431) is supported via
213
+ * Fulcrum's `blockchain.transaction.broadcast_package`. There is **no
214
+ * fallback** to sequential parent-then-child broadcasts — TRUC packages
215
+ * with a zero-fee parent would silently fail, so the call surfaces an
216
+ * error against servers that don't support the method.
217
+ *
218
+ * @example Default URL via {@link ELECTRUM_WS_URL}
137
219
  * ```typescript
138
220
  * import { ElectrumWS } from "ws-electrumx-client";
139
- * import { ElectrumOnchainProvider } from "./providers/electrum";
140
- * import { networks } from "./networks";
221
+ * import {
222
+ * ElectrumOnchainProvider,
223
+ * ELECTRUM_WS_URL,
224
+ * networks,
225
+ * } from "@arkade-os/sdk";
141
226
  *
142
- * const ws = new ElectrumWS("wss://electrum.blockstream.info:50004");
227
+ * const ws = new ElectrumWS(ELECTRUM_WS_URL.bitcoin);
143
228
  * const provider = new ElectrumOnchainProvider(ws, networks.bitcoin);
144
229
  *
145
230
  * const coins = await provider.getCoins("bc1q...");
231
+ * await provider.close();
232
+ * ```
233
+ *
234
+ * @example Custom server
235
+ * ```typescript
236
+ * const ws = new ElectrumWS("wss://my-fulcrum.example:50004");
237
+ * const provider = new ElectrumOnchainProvider(ws, networks.bitcoin);
146
238
  * ```
147
239
  */
148
240
  export declare class ElectrumOnchainProvider implements OnchainProvider {
@@ -178,15 +270,23 @@ export declare class ElectrumOnchainProvider implements OnchainProvider {
178
270
  }[]>;
179
271
  getTransactions(address: string): Promise<ExplorerTransaction[]>;
180
272
  /**
181
- * Map an electrum verbose transaction to the ExplorerTransaction shape.
182
- *
183
- * Output values are derived from the raw transaction hex when available,
184
- * never from the floating-point `value` field returned by the daemon.
185
- * That field has 8 decimal places and `Math.round(value * 1e8)` is safe
186
- * in the common case but a footgun for protocol-level money handling —
187
- * the raw bytes are exact.
273
+ * Resolve a list of `{tx_hash, height}` entries (as returned by the
274
+ * scripthash history endpoint) into ExplorerTransaction shape **without
275
+ * using the verbose-tx endpoint**, which only Fulcrum implements. We
276
+ * reconstruct everything the verbose response would have given us:
277
+ * - vouts parse the raw tx (exact sat amounts, no float precision risk)
278
+ * - block_time batch-fetch the block headers for the heights present
279
+ * - addresses decode each output's scriptPubKey via @scure/btc-signer
280
+ */
281
+ private historyToExplorerTxs;
282
+ /**
283
+ * Build an ExplorerTransaction from a history entry plus the raw tx hex
284
+ * (when known) and a height→block_time map. Parse errors propagate —
285
+ * silently returning an empty vout would hide real outputs (e.g. a
286
+ * deposit) and is far worse for protocol-level money handling than
287
+ * failing the whole batch.
188
288
  */
189
- private verboseToExplorer;
289
+ private buildExplorerTx;
190
290
  /**
191
291
  * Decode `address` into its scriptPubKey, throwing a clear error if the
192
292
  * input is malformed. @scure/btc-signer raises a generic decode error
@@ -2,6 +2,12 @@ import type { NetworkName } from "../networks";
2
2
  import { Coin } from "../wallet";
3
3
  /**
4
4
  * The default base URLs for esplora API providers.
5
+ *
6
+ * Mainnet, mutinynet, and signet point at Ark Labs–operated
7
+ * mempool deployments (mempool.space-compatible esplora API).
8
+ * Testnet falls back to the public mempool.space deployment
9
+ * because Ark doesn't host it. Regtest assumes a local nigiri
10
+ * stack on the standard port.
5
11
  */
6
12
  export declare const ESPLORA_URL: Record<NetworkName, string>;
7
13
  export type ExplorerTransaction = {
@@ -1,17 +1,33 @@
1
1
  import { TapLeafScript } from "../script/base";
2
- import { ExtendedCoin, ExtendedVirtualCoin } from "../wallet";
2
+ import { ArkTransaction, Asset, ExtendedCoin, ExtendedVirtualCoin } from "../wallet";
3
3
  export type SerializedTapLeaf = {
4
4
  cb: string;
5
5
  s: string;
6
6
  };
7
7
  export type SerializedVtxo = ReturnType<typeof serializeVtxo>;
8
8
  export type SerializedUtxo = ReturnType<typeof serializeUtxo>;
9
+ export type SerializedTransaction = ReturnType<typeof serializeTransaction>;
10
+ export type SerializedAsset = {
11
+ assetId: string;
12
+ amount: string;
13
+ };
9
14
  export declare const serializeTapLeaf: ([cb, s,]: TapLeafScript) => SerializedTapLeaf;
15
+ export declare const serializeAsset: (a: Asset) => SerializedAsset;
16
+ export declare const deserializeAsset: (a: {
17
+ assetId: string;
18
+ amount: string | number | bigint;
19
+ }) => Asset;
20
+ export declare const serializeAssets: (assets: Asset[] | undefined) => SerializedAsset[] | undefined;
21
+ export declare const deserializeAssets: (assets: Array<{
22
+ assetId: string;
23
+ amount: string | number | bigint;
24
+ }> | undefined) => Asset[] | undefined;
10
25
  export declare const serializeVtxo: (v: ExtendedVirtualCoin) => {
11
26
  tapTree: string;
12
27
  forfeitTapLeafScript: SerializedTapLeaf;
13
28
  intentTapLeafScript: SerializedTapLeaf;
14
29
  extraWitness: string[] | undefined;
30
+ assets: SerializedAsset[] | undefined;
15
31
  virtualStatus: import("../wallet").VirtualStatus;
16
32
  spentBy?: string;
17
33
  settledBy?: string;
@@ -19,7 +35,6 @@ export declare const serializeVtxo: (v: ExtendedVirtualCoin) => {
19
35
  createdAt: Date;
20
36
  isUnrolled: boolean;
21
37
  isSpent?: boolean;
22
- assets?: import("../wallet").Asset[];
23
38
  script: string;
24
39
  value: number;
25
40
  status: import("../wallet").Status;
@@ -36,6 +51,15 @@ export declare const serializeUtxo: (u: ExtendedCoin) => {
36
51
  txid: string;
37
52
  vout: number;
38
53
  };
54
+ export declare const serializeTransaction: (t: ArkTransaction) => {
55
+ assets: SerializedAsset[] | undefined;
56
+ key: import("../wallet").TxKey;
57
+ type: import("../wallet").TxType;
58
+ amount: number;
59
+ settled: boolean;
60
+ createdAt: number;
61
+ };
39
62
  export declare const deserializeTapLeaf: (t: SerializedTapLeaf) => TapLeafScript;
40
63
  export declare const deserializeVtxo: (o: SerializedVtxo) => ExtendedVirtualCoin;
41
64
  export declare const deserializeUtxo: (o: SerializedUtxo) => ExtendedCoin;
65
+ export declare const deserializeTransaction: (o: SerializedTransaction) => ArkTransaction;
@@ -43,7 +43,7 @@ export declare class ArkAddress {
43
43
  * @defaultValue `version = 0`
44
44
  * @throws Error if either public key is not 32 bytes long
45
45
  */
46
- constructor(serverPubKey: Bytes, vtxoTaprootKey: Bytes, hrp: string, version?: number);
46
+ constructor(serverPubKey: Bytes, vtxoTaprootKey: Bytes, hrp?: string, version?: number);
47
47
  /**
48
48
  * Decode an Arkade address from its bech32m string form.
49
49
  *
@@ -90,6 +90,7 @@ export declare namespace CSVMultisigTapscript {
90
90
  function decode(script: Uint8Array): Type;
91
91
  /** Return true when the tapscript is a CSV multisig tapscript. */
92
92
  function is(tapscript: ArkTapscript<any, any>): tapscript is Type;
93
+ function isScriptValid(script: Uint8Array): true | Error;
93
94
  }
94
95
  /**
95
96
  * Combines a condition script with an exit closure. The resulting script requires
@@ -114,6 +115,7 @@ export declare namespace ConditionCSVMultisigTapscript {
114
115
  function decode(script: Uint8Array): Type;
115
116
  /** Return true when the tapscript is a condition + CSV multisig tapscript. */
116
117
  function is(tapscript: ArkTapscript<any, any>): tapscript is Type;
118
+ function isScriptValid(script: Uint8Array): true | Error;
117
119
  }
118
120
  /**
119
121
  * Combines a condition script with a forfeit closure. The resulting script requires
@@ -138,6 +140,7 @@ export declare namespace ConditionMultisigTapscript {
138
140
  function decode(script: Uint8Array): Type;
139
141
  /** Return true when the tapscript is a condition + multisig tapscript. */
140
142
  function is(tapscript: ArkTapscript<any, any>): tapscript is Type;
143
+ function isScriptValid(script: Uint8Array): true | Error;
141
144
  }
142
145
  /**
143
146
  * Implements an absolute timelock (CLTV) script combined with a forfeit closure.
@@ -162,4 +165,5 @@ export declare namespace CLTVMultisigTapscript {
162
165
  function decode(script: Uint8Array): Type;
163
166
  /** Return true when the tapscript is a CLTV multisig tapscript. */
164
167
  function is(tapscript: ArkTapscript<any, any>): tapscript is Type;
168
+ function isScriptValid(script: Uint8Array): true | Error;
165
169
  }
@@ -0,0 +1,9 @@
1
+ import type { RelativeTimelock } from "../script/tapscript";
2
+ /**
3
+ * Convert RelativeTimelock to BIP68 sequence number.
4
+ */
5
+ export declare function timelockToSequence(timelock: RelativeTimelock): number;
6
+ /**
7
+ * Convert BIP68 sequence number back to RelativeTimelock.
8
+ */
9
+ export declare function sequenceToTimelock(sequence: number): RelativeTimelock;
@@ -0,0 +1,93 @@
1
+ import { DescriptorProvider, DescriptorSigningRequest } from "../identity/descriptorProvider";
2
+ import { HDCapableIdentity } from "../identity/hdCapableIdentity";
3
+ import { WalletRepository } from "../repositories/walletRepository";
4
+ import { Transaction } from "../utils/transaction";
5
+ /**
6
+ * HD-wallet {@link DescriptorProvider} that allocates a fresh signing
7
+ * descriptor on every call. The provider holds no notion of "current" — it
8
+ * is a pure rotating allocator. The question of "which descriptor is the
9
+ * wallet currently bound to?" is answered by querying the contract
10
+ * repository for active contracts, not by asking this provider.
11
+ *
12
+ * State is persisted under `WalletRepository.getWalletState().settings.hd` so
13
+ * that no storage-schema migration is required when switching a wallet from
14
+ * single-key to HD. The provider is backed by an {@link HDCapableIdentity},
15
+ * which carries the wildcard account descriptor template (for derivation)
16
+ * and the signing primitives.
17
+ *
18
+ * The read-modify-write of the persisted index runs inside the shared per-
19
+ * repo `updateWalletState` mutex, so two `getNextSigningDescriptor` callers
20
+ * — including those driving separate `HDDescriptorProvider` instances on
21
+ * the same repo — can never observe the same index.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const provider = await HDDescriptorProvider.create(identity, walletRepo);
26
+ * const descriptor = await provider.getNextSigningDescriptor();
27
+ * // descriptor: tr([fp/86'/0'/0']xpub/0/0)
28
+ * const next = await provider.getNextSigningDescriptor();
29
+ * // next: tr([fp/86'/0'/0']xpub/0/1)
30
+ * ```
31
+ */
32
+ export declare class HDDescriptorProvider implements DescriptorProvider {
33
+ private readonly identity;
34
+ private readonly walletRepository;
35
+ private constructor();
36
+ /**
37
+ * Construct an HDDescriptorProvider. No I/O is performed here;
38
+ * persisted state is read lazily on the first call to
39
+ * `getNextSigningDescriptor`. A descriptor-mismatch error surfaces on
40
+ * first use rather than at boot.
41
+ */
42
+ static create(identity: HDCapableIdentity, walletRepository: WalletRepository): Promise<HDDescriptorProvider>;
43
+ /**
44
+ * Allocate the next descriptor and return it. The first call on a fresh
45
+ * wallet returns descriptor at index 0; subsequent calls return 1, 2, 3,
46
+ * ... in order. Each call is atomic with respect to other rotations on
47
+ * the same repo: two concurrent callers can never observe the same
48
+ * index.
49
+ */
50
+ getNextSigningDescriptor(): Promise<string>;
51
+ /**
52
+ * Returns true when the given descriptor is derivable from this wallet's
53
+ * seed. Delegates to the underlying identity, which handles both HD and
54
+ * simple `tr(pubkey)` descriptors.
55
+ */
56
+ isOurs(descriptor: string): boolean;
57
+ /**
58
+ * Signs each request with the key derived from its descriptor. Delegates
59
+ * to the identity's signing primitives — the identity, not the provider,
60
+ * holds the seed.
61
+ */
62
+ signWithDescriptor(requests: DescriptorSigningRequest[]): Promise<Transaction[]>;
63
+ /** Signs a message using the key derived from `descriptor`. */
64
+ signMessageWithDescriptor(descriptor: string, message: Uint8Array, signatureType?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
65
+ /**
66
+ * Substitute the wildcard in the identity's account-descriptor template
67
+ * with a concrete index, going through the descriptors-scure parser
68
+ * rather than ad-hoc string substitution. The parser's `expand({ index })`
69
+ * call validates that the input is a ranged template AND produces a
70
+ * canonical materialized key expression at the given index.
71
+ */
72
+ private materializeAt;
73
+ /**
74
+ * Run the read-modify-write of HD settings inside the shared per-repo
75
+ * wallet-state mutex. The closure receives a freshly-validated settings
76
+ * snapshot, mutates it, and returns whatever value the caller wants to
77
+ * surface; the mutated settings are then persisted as part of the same
78
+ * atomic update.
79
+ *
80
+ * Doing the read inside the lock is what prevents two providers (or two
81
+ * concurrent callers on the same provider) from racing on a stale index.
82
+ */
83
+ private mutate;
84
+ /**
85
+ * Validate the persisted HD settings (or initialize a fresh record when
86
+ * absent) and return a clone safe for the caller to mutate.
87
+ *
88
+ * The cast to `HDWalletSettings` trusts storage; a corrupted or
89
+ * partially-migrated repo could otherwise produce `NaN` descriptors.
90
+ * Fail loud rather than silently derive garbage.
91
+ */
92
+ private parseSettings;
93
+ }
@@ -11,6 +11,10 @@ import { ContractRepository, WalletRepository } from "../repositories";
11
11
  import { IContractManager } from "../contracts/contractManager";
12
12
  import { IDelegatorManager } from "./delegator";
13
13
  import { DelegatorProvider } from "../providers/delegator";
14
+ /** Defaults */
15
+ export declare const DEFAULT_ARKADE_SERVER_URL: "https://arkade.computer";
16
+ export declare const DEFAULT_ARKADE_HRP = "ark";
17
+ export declare const DEFAULT_NETWORK_NAME = "bitcoin";
14
18
  /**
15
19
  * Base configuration options shared by all wallet types.
16
20
  *
@@ -22,9 +26,6 @@ import { DelegatorProvider } from "../providers/delegator";
22
26
  * Provider-based configuration supplies concrete provider instances directly,
23
27
  * including the ArkProvider, IndexerProvider, OnchainProvider, and DelegatorProvider.
24
28
  *
25
- * At least one of the following must be provided:
26
- * - arkServerUrl OR arkProvider
27
- *
28
29
  * The wallet will use provided URLs to create default providers if custom provider
29
30
  * instances are not supplied. If optional parameters are not provided, the wallet
30
31
  * will fetch configuration from the Arkade server.
@@ -255,8 +256,12 @@ export interface SendBitcoinParams {
255
256
  export interface Asset {
256
257
  /** Asset identifier. */
257
258
  assetId: string;
258
- /** Asset amount in base units. */
259
- amount: number;
259
+ /**
260
+ * Asset amount in base units. Typed as `bigint` because asset
261
+ * supplies routinely exceed `Number.MAX_SAFE_INTEGER` (2^53 - 1)
262
+ * and silently truncating in arithmetic would corrupt balances.
263
+ */
264
+ amount: bigint;
260
265
  }
261
266
  /**
262
267
  * Recipient accepted by `IWallet.send`.
@@ -310,8 +315,12 @@ export type AssetMetadata = KnownMetadata & Record<string, unknown>;
310
315
  export type AssetDetails = {
311
316
  /** Asset identifier. */
312
317
  assetId: string;
313
- /** Total issued supply in base units. */
314
- supply: number;
318
+ /**
319
+ * Total issued supply in base units. Typed as `bigint` for the
320
+ * same reason as {@link Asset.amount} — supplies often exceed
321
+ * `Number.MAX_SAFE_INTEGER`.
322
+ */
323
+ supply: bigint;
315
324
  /** Optional immutable metadata associated with the asset. */
316
325
  metadata?: AssetMetadata;
317
326
  /** Optional control asset id required for future reissuance. */
@@ -325,7 +334,7 @@ export type AssetDetails = {
325
334
  */
326
335
  export interface IssuanceParams {
327
336
  /** Initial amount of asset to issue */
328
- amount: number;
337
+ amount: bigint;
329
338
  /** Optional control asset ID that can be used for future reissuance */
330
339
  controlAssetId?: string;
331
340
  /** Immutable asset metadata including `ticker`, `decimals`, `icon` */
@@ -352,7 +361,7 @@ export interface ReissuanceParams {
352
361
  /** Existing asset ID, made up of genesis (Arkade) transaction ID and zero-based asset group index */
353
362
  assetId: string;
354
363
  /** Amount of asset to issue */
355
- amount: number;
364
+ amount: bigint;
356
365
  }
357
366
  /**
358
367
  * Parameters accepted by `IAssetManager.burn`.
@@ -363,7 +372,7 @@ export interface BurnParams {
363
372
  /** Existing asset ID, made up of genesis (Arkade) transaction ID and zero-based asset group index */
364
373
  assetId: string;
365
374
  /** Amount of asset to burn */
366
- amount: number;
375
+ amount: bigint;
367
376
  }
368
377
  /**
369
378
  * Explicit inputs and outputs accepted by `IWallet.settle`.
@@ -39,7 +39,7 @@ export declare class OnchainWallet implements AnchorBumper {
39
39
  * @defaultValue `provider = new EsploraProvider('https://mempool.space/api')`
40
40
  * @throws Error if the configured identity cannot produce a valid x-only public key
41
41
  */
42
- static create(identity: Identity, networkName: NetworkName, provider?: OnchainProvider): Promise<OnchainWallet>;
42
+ static create(identity: Identity, networkName?: NetworkName, provider?: OnchainProvider): Promise<OnchainWallet>;
43
43
  get address(): string;
44
44
  /**
45
45
  * Fetch spendable onchain outputs for the wallet address.
@@ -45,7 +45,7 @@ interface ServiceWorkerWalletOptions {
45
45
  /** Optional Arkade server public key used to construct and validate Arkade addresses. */
46
46
  arkServerPublicKey?: string;
47
47
  /** Base URL of the Arkade server. */
48
- arkServerUrl: string;
48
+ arkServerUrl?: string;
49
49
  /** Optional override for the indexer URL. */
50
50
  indexerUrl?: string;
51
51
  /** Optional override for the Esplora API URL. */
@@ -15,6 +15,7 @@ export declare namespace Unroll {
15
15
  */
16
16
  type UnrollStep = {
17
17
  tx: Transaction;
18
+ pkg: [parent: string, child: string];
18
19
  };
19
20
  /**
20
21
  * Wait step where the transaction has to be confirmed onchain
@@ -102,3 +103,12 @@ export declare namespace Unroll {
102
103
  */
103
104
  function completeUnroll(wallet: Wallet, vtxoTxids: string[], outputAddress: string): Promise<string>;
104
105
  }
106
+ /**
107
+ * Prepares the transaction that spends the CSV path to complete unrolling a VTXO.
108
+ * @param wallet the wallet owning the VTXO(s)
109
+ * @param vtxoTxIds the txids of the VTXO(s) to complete unroll
110
+ * @param outputAddress the address to send the unrolled funds to
111
+ * @throws if the VTXO(s) are not fully unrolled, if the txids are not found, if the tx is not confirmed, if no exit path is found or not available
112
+ * @returns the transaction spending the unrolled funds
113
+ */
114
+ export declare function prepareUnrollTransaction(wallet: Wallet, vtxoTxIds: string[], outputAddress: string): Promise<Transaction>;
@@ -19,6 +19,9 @@ import { DelegatorProvider } from "../providers/delegator";
19
19
  import { DelegateVtxo } from "../script/delegate";
20
20
  import { IDelegatorManager } from "./delegator";
21
21
  import { ContractManager } from "../contracts/contractManager";
22
+ export declare const getArkadeServerUrl: ({ arkServerUrl, }: {
23
+ arkServerUrl?: string;
24
+ }) => string;
22
25
  export type IncomingFunds = {
23
26
  type: "utxo";
24
27
  coins: Coin[];
@@ -321,7 +324,7 @@ export declare class Wallet extends ReadonlyWallet implements IWallet {
321
324
  * const txid = await wallet.send({
322
325
  * address: 'ark1q...',
323
326
  * amount: 1000, // (optional, default to dust) btc amount to send to the output
324
- * assets: [{ assetId: 'abc123...', amount: 50 }] // (optional) list of assets to send
327
+ * assets: [{ assetId: 'abc123...', amount: 50n }] // (optional) list of assets to send
325
328
  * });
326
329
  * ```
327
330
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkade-os/sdk",
3
- "version": "0.4.22",
3
+ "version": "0.4.24",
4
4
  "description": "TypeScript SDK for building Bitcoin wallets using the Arkade protocol",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",