@arkade-os/sdk 0.4.15 → 0.4.17
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 +102 -96
- package/dist/cjs/arkfee/estimator.js +1 -1
- package/dist/cjs/arkfee/types.js +2 -1
- package/dist/cjs/arknote/index.js +43 -4
- package/dist/cjs/bip322/index.js +1 -1
- package/dist/cjs/contracts/arkcontract.js +1 -1
- package/dist/cjs/contracts/contractManager.js +60 -28
- package/dist/cjs/contracts/contractWatcher.js +29 -22
- package/dist/cjs/contracts/handlers/default.js +1 -1
- package/dist/cjs/contracts/handlers/delegate.js +1 -1
- package/dist/cjs/contracts/handlers/helpers.js +1 -1
- package/dist/cjs/extension/asset/assetGroup.js +92 -5
- package/dist/cjs/extension/asset/assetId.js +67 -3
- package/dist/cjs/extension/asset/assetInput.js +18 -0
- package/dist/cjs/extension/asset/assetOutput.js +15 -0
- package/dist/cjs/extension/asset/assetRef.js +66 -0
- package/dist/cjs/extension/asset/metadata.js +15 -0
- package/dist/cjs/extension/asset/packet.js +4 -1
- package/dist/cjs/extension/index.js +1 -1
- package/dist/cjs/forfeit.js +14 -0
- package/dist/cjs/identity/seedIdentity.js +2 -2
- package/dist/cjs/identity/singleKey.js +4 -0
- package/dist/cjs/intent/index.js +28 -12
- package/dist/cjs/providers/ark.js +3 -2
- package/dist/cjs/providers/delegator.js +20 -1
- package/dist/cjs/providers/expoArk.js +2 -2
- package/dist/cjs/providers/indexer.js +2 -2
- package/dist/cjs/providers/onchain.js +2 -1
- package/dist/cjs/repositories/realm/schemas.js +2 -2
- package/dist/cjs/repositories/realm/types.js +1 -1
- package/dist/cjs/script/address.js +37 -6
- package/dist/cjs/script/base.js +70 -1
- package/dist/cjs/script/default.js +3 -0
- package/dist/cjs/script/delegate.js +4 -0
- package/dist/cjs/script/tapscript.js +17 -2
- package/dist/cjs/script/vhtlc.js +35 -27
- package/dist/cjs/storage/fileSystem.js +1 -1
- package/dist/cjs/storage/inMemory.js +1 -1
- package/dist/cjs/storage/indexedDB.js +1 -1
- package/dist/cjs/storage/localStorage.js +1 -1
- package/dist/cjs/tree/validation.js +1 -1
- package/dist/cjs/utils/arkTransaction.js +5 -5
- package/dist/cjs/utils/bip21.js +16 -3
- package/dist/cjs/utils/syncCursors.js +4 -4
- package/dist/cjs/utils/transaction.js +1 -1
- package/dist/cjs/utils/transactionHistory.js +11 -11
- package/dist/cjs/utils/unknownFields.js +3 -3
- package/dist/cjs/wallet/asset-manager.js +4 -4
- package/dist/cjs/wallet/batch.js +5 -5
- package/dist/cjs/wallet/delegator.js +9 -8
- package/dist/cjs/wallet/expo/background.js +3 -3
- package/dist/cjs/wallet/expo/wallet.js +7 -7
- package/dist/cjs/wallet/index.js +43 -0
- package/dist/cjs/wallet/onchain.js +43 -5
- package/dist/cjs/wallet/ramps.js +44 -14
- package/dist/cjs/wallet/serviceWorker/wallet-message-handler.js +22 -22
- package/dist/cjs/wallet/serviceWorker/wallet.js +28 -24
- package/dist/cjs/wallet/unroll.js +12 -8
- package/dist/cjs/wallet/utils.js +1 -1
- package/dist/cjs/wallet/vtxo-manager.js +122 -82
- package/dist/cjs/wallet/wallet.js +140 -77
- package/dist/cjs/worker/expo/asyncStorageTaskQueue.js +1 -1
- package/dist/cjs/worker/expo/processors/contractPollProcessor.js +2 -2
- package/dist/cjs/worker/expo/taskRunner.js +3 -3
- package/dist/cjs/worker/messageBus.js +3 -0
- package/dist/esm/arkfee/estimator.js +1 -1
- package/dist/esm/arkfee/types.js +2 -1
- package/dist/esm/arknote/index.js +43 -4
- package/dist/esm/bip322/index.js +1 -1
- package/dist/esm/contracts/arkcontract.js +1 -1
- package/dist/esm/contracts/contractManager.js +60 -28
- package/dist/esm/contracts/contractWatcher.js +29 -22
- package/dist/esm/contracts/handlers/default.js +1 -1
- package/dist/esm/contracts/handlers/delegate.js +1 -1
- package/dist/esm/contracts/handlers/helpers.js +1 -1
- package/dist/esm/extension/asset/assetGroup.js +92 -5
- package/dist/esm/extension/asset/assetId.js +67 -3
- package/dist/esm/extension/asset/assetInput.js +18 -0
- package/dist/esm/extension/asset/assetOutput.js +15 -0
- package/dist/esm/extension/asset/assetRef.js +66 -0
- package/dist/esm/extension/asset/metadata.js +15 -0
- package/dist/esm/extension/asset/packet.js +4 -1
- package/dist/esm/extension/index.js +1 -1
- package/dist/esm/forfeit.js +14 -0
- package/dist/esm/identity/seedIdentity.js +2 -2
- package/dist/esm/identity/singleKey.js +4 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/intent/index.js +28 -12
- package/dist/esm/providers/ark.js +3 -2
- package/dist/esm/providers/delegator.js +20 -1
- package/dist/esm/providers/expoArk.js +2 -2
- package/dist/esm/providers/indexer.js +2 -2
- package/dist/esm/providers/onchain.js +2 -1
- package/dist/esm/repositories/realm/schemas.js +2 -2
- package/dist/esm/repositories/realm/types.js +1 -1
- package/dist/esm/script/address.js +37 -6
- package/dist/esm/script/base.js +70 -1
- package/dist/esm/script/default.js +3 -0
- package/dist/esm/script/delegate.js +4 -0
- package/dist/esm/script/tapscript.js +17 -2
- package/dist/esm/script/vhtlc.js +35 -27
- package/dist/esm/storage/fileSystem.js +1 -1
- package/dist/esm/storage/inMemory.js +1 -1
- package/dist/esm/storage/indexedDB.js +1 -1
- package/dist/esm/storage/localStorage.js +1 -1
- package/dist/esm/tree/validation.js +1 -1
- package/dist/esm/utils/arkTransaction.js +5 -5
- package/dist/esm/utils/bip21.js +16 -3
- package/dist/esm/utils/syncCursors.js +4 -4
- package/dist/esm/utils/transaction.js +1 -1
- package/dist/esm/utils/transactionHistory.js +11 -11
- package/dist/esm/utils/unknownFields.js +3 -3
- package/dist/esm/wallet/asset-manager.js +4 -4
- package/dist/esm/wallet/batch.js +5 -5
- package/dist/esm/wallet/delegator.js +9 -8
- package/dist/esm/wallet/expo/background.js +3 -3
- package/dist/esm/wallet/expo/wallet.js +7 -7
- package/dist/esm/wallet/index.js +43 -0
- package/dist/esm/wallet/onchain.js +43 -5
- package/dist/esm/wallet/ramps.js +44 -14
- package/dist/esm/wallet/serviceWorker/wallet-message-handler.js +22 -22
- package/dist/esm/wallet/serviceWorker/wallet.js +28 -24
- package/dist/esm/wallet/unroll.js +12 -8
- package/dist/esm/wallet/utils.js +1 -1
- package/dist/esm/wallet/vtxo-manager.js +121 -81
- package/dist/esm/wallet/wallet.js +140 -77
- package/dist/esm/worker/expo/asyncStorageTaskQueue.js +1 -1
- package/dist/esm/worker/expo/processors/contractPollProcessor.js +2 -2
- package/dist/esm/worker/expo/taskRunner.js +3 -3
- package/dist/esm/worker/messageBus.js +3 -0
- package/dist/types/arkfee/estimator.d.ts +1 -1
- package/dist/types/arkfee/types.d.ts +2 -1
- package/dist/types/arknote/index.d.ts +44 -4
- package/dist/types/bip322/index.d.ts +1 -1
- package/dist/types/contracts/arkcontract.d.ts +1 -1
- package/dist/types/contracts/contractManager.d.ts +39 -65
- package/dist/types/contracts/contractWatcher.d.ts +39 -18
- package/dist/types/contracts/handlers/default.d.ts +1 -1
- package/dist/types/contracts/handlers/delegate.d.ts +1 -1
- package/dist/types/contracts/handlers/helpers.d.ts +1 -1
- package/dist/types/contracts/types.d.ts +36 -26
- package/dist/types/extension/asset/assetGroup.d.ts +92 -1
- package/dist/types/extension/asset/assetId.d.ts +67 -3
- package/dist/types/extension/asset/assetInput.d.ts +18 -0
- package/dist/types/extension/asset/assetOutput.d.ts +15 -0
- package/dist/types/extension/asset/assetRef.d.ts +66 -0
- package/dist/types/extension/asset/metadata.d.ts +15 -0
- package/dist/types/extension/asset/packet.d.ts +4 -1
- package/dist/types/extension/index.d.ts +1 -1
- package/dist/types/forfeit.d.ts +14 -0
- package/dist/types/identity/index.d.ts +16 -0
- package/dist/types/identity/seedIdentity.d.ts +8 -6
- package/dist/types/identity/singleKey.d.ts +4 -0
- package/dist/types/intent/index.d.ts +19 -6
- package/dist/types/providers/ark.d.ts +40 -2
- package/dist/types/providers/delegator.d.ts +54 -1
- package/dist/types/providers/expoArk.d.ts +2 -2
- package/dist/types/providers/indexer.d.ts +105 -2
- package/dist/types/providers/onchain.d.ts +62 -1
- package/dist/types/repositories/realm/schemas.d.ts +2 -2
- package/dist/types/repositories/realm/types.d.ts +2 -2
- package/dist/types/repositories/walletRepository.d.ts +16 -0
- package/dist/types/script/address.d.ts +35 -2
- package/dist/types/script/base.d.ts +66 -1
- package/dist/types/script/default.d.ts +3 -0
- package/dist/types/script/delegate.d.ts +4 -0
- package/dist/types/script/tapscript.d.ts +17 -2
- package/dist/types/script/vhtlc.d.ts +35 -27
- package/dist/types/storage/fileSystem.d.ts +1 -1
- package/dist/types/storage/inMemory.d.ts +1 -1
- package/dist/types/storage/index.d.ts +1 -1
- package/dist/types/storage/indexedDB.d.ts +1 -1
- package/dist/types/storage/localStorage.d.ts +1 -1
- package/dist/types/utils/arkTransaction.d.ts +3 -3
- package/dist/types/utils/bip21.d.ts +17 -0
- package/dist/types/utils/syncCursors.d.ts +4 -4
- package/dist/types/utils/transaction.d.ts +1 -1
- package/dist/types/utils/transactionHistory.d.ts +3 -3
- package/dist/types/utils/unknownFields.d.ts +5 -5
- package/dist/types/wallet/asset-manager.d.ts +3 -3
- package/dist/types/wallet/batch.d.ts +27 -7
- package/dist/types/wallet/delegator.d.ts +10 -0
- package/dist/types/wallet/expo/background.d.ts +4 -4
- package/dist/types/wallet/expo/wallet.d.ts +10 -10
- package/dist/types/wallet/index.d.ts +457 -25
- package/dist/types/wallet/onchain.d.ts +42 -4
- package/dist/types/wallet/ramps.d.ts +40 -10
- package/dist/types/wallet/serviceWorker/wallet-message-handler.d.ts +4 -4
- package/dist/types/wallet/serviceWorker/wallet.d.ts +71 -33
- package/dist/types/wallet/unroll.d.ts +8 -6
- package/dist/types/wallet/vtxo-manager.d.ts +146 -93
- package/dist/types/wallet/wallet.d.ts +91 -33
- package/dist/types/worker/expo/asyncStorageTaskQueue.d.ts +1 -1
- package/dist/types/worker/expo/processors/contractPollProcessor.d.ts +1 -1
- package/dist/types/worker/expo/taskRunner.d.ts +6 -6
- package/dist/types/worker/messageBus.d.ts +5 -3
- package/package.json +1 -1
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
import { ExtendedCoin, ExtendedVirtualCoin, IWallet } from ".";
|
|
2
2
|
import { SettlementEvent } from "../providers/ark";
|
|
3
|
-
|
|
3
|
+
/** Default renewal threshold in seconds (3 days). */
|
|
4
4
|
export declare const DEFAULT_THRESHOLD_SECONDS: number;
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
|
|
6
|
+
* Default renewal threshold in milliseconds (3 days).
|
|
7
|
+
*/
|
|
8
|
+
export declare const DEFAULT_THRESHOLD_MS: number;
|
|
9
|
+
/**
|
|
10
|
+
* Configuration options for automatic virtual output renewal
|
|
11
|
+
*
|
|
12
|
+
* @see DEFAULT_RENEWAL_CONFIG
|
|
13
|
+
* @deprecated Leave `renewalConfig` undefined and use `settlementConfig` instead.
|
|
14
|
+
* @see SettlementConfig
|
|
8
15
|
*/
|
|
9
16
|
export interface RenewalConfig {
|
|
10
17
|
/**
|
|
11
18
|
* Enable automatic renewal monitoring
|
|
12
|
-
*
|
|
19
|
+
*
|
|
20
|
+
* @defaultValue `false`
|
|
21
|
+
* @deprecated Explicitly set `settlementConfig` to `false` to disable VTXO renewal.
|
|
13
22
|
*/
|
|
14
23
|
enabled?: boolean;
|
|
15
24
|
/**
|
|
16
25
|
* Threshold in milliseconds to use as threshold for renewal
|
|
17
|
-
* E.g.,
|
|
18
|
-
*
|
|
19
|
-
* @
|
|
26
|
+
* E.g., 86_400_000 means renew when 24 hours until expiry remains
|
|
27
|
+
*
|
|
28
|
+
* @defaultValue `259_200_000` (3 days).
|
|
29
|
+
* @deprecated Use `SettlementConfig.vtxoThreshold` (in seconds) instead.
|
|
20
30
|
*/
|
|
21
31
|
thresholdMs?: number;
|
|
22
32
|
}
|
|
@@ -24,111 +34,142 @@ export interface RenewalConfig {
|
|
|
24
34
|
* Configuration for automatic settlement and renewal.
|
|
25
35
|
*
|
|
26
36
|
* Controls two behaviors:
|
|
27
|
-
* 1. **VTXO renewal**: Automatically renew
|
|
28
|
-
* 2. **Boarding UTXO sweep**: Sweep expired boarding
|
|
29
|
-
* via the unilateral exit path (
|
|
37
|
+
* 1. **VTXO renewal**: Automatically renew virtual outputs that are close to expiry
|
|
38
|
+
* 2. **Boarding UTXO sweep**: Sweep expired boarding inputs back to a fresh boarding address
|
|
39
|
+
* via the unilateral exit path (onchain self-spend to restart the timelock)
|
|
30
40
|
*
|
|
31
41
|
* Enabled by default when no config is provided.
|
|
32
42
|
* Pass `false` to explicitly disable all settlement behavior.
|
|
33
43
|
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* VTXO renewal and boarding UTXO sweep are both coordinated by `VtxoManager`, which periodically
|
|
46
|
+
* inspects wallet virtual outputs and boarding inputs and decides whether action is needed.
|
|
47
|
+
*
|
|
48
|
+
* @see DEFAULT_SETTLEMENT_CONFIG
|
|
49
|
+
*
|
|
34
50
|
* @example
|
|
35
51
|
* ```typescript
|
|
36
|
-
* // Default behavior:
|
|
52
|
+
* // Default behavior: virtual output renewal at 3 days, boarding sweep enabled, polling every minute
|
|
37
53
|
* const wallet = await Wallet.create({
|
|
38
|
-
* identity:
|
|
39
|
-
* arkServerUrl: 'https://
|
|
54
|
+
* identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
|
|
55
|
+
* arkServerUrl: 'https://arkade.computer',
|
|
40
56
|
* });
|
|
41
57
|
*
|
|
42
|
-
* // Custom threshold
|
|
58
|
+
* // Custom expiry threshold of 24 hours
|
|
43
59
|
* const wallet = await Wallet.create({
|
|
44
|
-
* identity:
|
|
45
|
-
* arkServerUrl: 'https://
|
|
60
|
+
* identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
|
|
61
|
+
* arkServerUrl: 'https://arkade.computer',
|
|
46
62
|
* settlementConfig: {
|
|
47
|
-
* vtxoThreshold:
|
|
63
|
+
* vtxoThreshold: 60 * 60 * 24, // 24 hours in seconds
|
|
48
64
|
* },
|
|
49
65
|
* });
|
|
50
66
|
*
|
|
51
67
|
* // Explicitly disable
|
|
52
68
|
* const wallet = await Wallet.create({
|
|
53
|
-
* identity:
|
|
54
|
-
* arkServerUrl: 'https://
|
|
69
|
+
* identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
|
|
70
|
+
* arkServerUrl: 'https://arkade.computer',
|
|
55
71
|
* settlementConfig: false,
|
|
56
72
|
* });
|
|
57
73
|
* ```
|
|
58
74
|
*/
|
|
59
75
|
export interface SettlementConfig {
|
|
60
76
|
/**
|
|
61
|
-
* Seconds before
|
|
62
|
-
*
|
|
77
|
+
* Seconds before virtual output expiry to trigger renewal.
|
|
78
|
+
*
|
|
79
|
+
* @defaultValue `259_200` (3 days)
|
|
63
80
|
*/
|
|
64
81
|
vtxoThreshold?: number;
|
|
65
82
|
/**
|
|
66
|
-
* Sweep expired boarding
|
|
67
|
-
* via the unilateral exit path (
|
|
83
|
+
* Sweep expired boarding inputs back to a fresh boarding address
|
|
84
|
+
* via the unilateral exit path (onchain self-spend to restart the timelock).
|
|
85
|
+
*
|
|
86
|
+
* When enabled, expired boarding inputs are batched into a single onchain
|
|
87
|
+
* transaction with multiple inputs and one output.
|
|
68
88
|
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* performed when the output after fees is above dust.
|
|
89
|
+
* A dust check ensures the sweep is only performed when the output
|
|
90
|
+
* after fees is above dust.
|
|
72
91
|
*
|
|
73
|
-
* @
|
|
92
|
+
* @defaultValue `true`
|
|
74
93
|
*/
|
|
75
94
|
boardingUtxoSweep?: boolean;
|
|
76
95
|
/**
|
|
77
|
-
* Polling interval in milliseconds for checking boarding
|
|
78
|
-
* The poll loop auto-settles new boarding
|
|
96
|
+
* Polling interval in milliseconds for checking boarding inputs.
|
|
97
|
+
* The poll loop auto-settles new boarding inputs into Arkade and
|
|
79
98
|
* sweeps expired ones (when boardingUtxoSweep is enabled).
|
|
80
99
|
*
|
|
81
|
-
* @
|
|
100
|
+
* @defaultValue `60_000` (1 minute)
|
|
82
101
|
*/
|
|
83
102
|
pollIntervalMs?: number;
|
|
84
103
|
}
|
|
85
104
|
/**
|
|
86
|
-
* Default renewal configuration values
|
|
87
|
-
*
|
|
105
|
+
* Default renewal configuration values.
|
|
106
|
+
*
|
|
107
|
+
* @see RenewalConfig
|
|
108
|
+
* @deprecated Leave `renewalConfig` undefined and use `settlementConfig` instead.
|
|
109
|
+
* @see SettlementConfig
|
|
88
110
|
*/
|
|
89
111
|
export declare const DEFAULT_RENEWAL_CONFIG: Required<Omit<RenewalConfig, "enabled">>;
|
|
90
112
|
/**
|
|
91
|
-
* Default settlement configuration values
|
|
113
|
+
* Default settlement configuration values.
|
|
114
|
+
*
|
|
115
|
+
* @see SettlementConfig
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* const wallet = await Wallet.create({
|
|
120
|
+
* identity,
|
|
121
|
+
* arkServerUrl: 'https://arkade.computer',
|
|
122
|
+
* settlementConfig: DEFAULT_SETTLEMENT_CONFIG,
|
|
123
|
+
* })
|
|
124
|
+
* ```
|
|
92
125
|
*/
|
|
93
126
|
export declare const DEFAULT_SETTLEMENT_CONFIG: Required<SettlementConfig>;
|
|
94
127
|
/**
|
|
95
|
-
* Check if a
|
|
128
|
+
* Check if a virtual output is expiring soon based on threshold
|
|
96
129
|
*
|
|
97
|
-
* @param vtxo - The virtual
|
|
130
|
+
* @param vtxo - The virtual output to check
|
|
98
131
|
* @param thresholdMs - Threshold in milliseconds from now
|
|
99
|
-
* @returns true if
|
|
132
|
+
* @returns true if virtual output expires within threshold, false otherwise
|
|
100
133
|
*/
|
|
101
134
|
export declare function isVtxoExpiringSoon(vtxo: ExtendedVirtualCoin, thresholdMs: number): boolean;
|
|
102
135
|
/**
|
|
103
|
-
* Filter
|
|
136
|
+
* Filter virtual outputs that are expiring soon or are recoverable/subdust
|
|
104
137
|
*
|
|
105
|
-
* @param vtxos - Array of virtual
|
|
138
|
+
* @param vtxos - Array of virtual outputs to check
|
|
106
139
|
* @param thresholdMs - Threshold in milliseconds from now
|
|
107
140
|
* @param dustAmount - Dust threshold amount in satoshis
|
|
108
|
-
* @returns Array of
|
|
141
|
+
* @returns Array of virtual outputs expiring within threshold
|
|
109
142
|
*/
|
|
110
143
|
export declare function getExpiringAndRecoverableVtxos(vtxos: ExtendedVirtualCoin[], thresholdMs: number, dustAmount: bigint): ExtendedVirtualCoin[];
|
|
111
144
|
/**
|
|
112
|
-
* VtxoManager is a unified class for managing
|
|
113
|
-
* recovery of swept/expired
|
|
145
|
+
* VtxoManager is a unified class for managing virtual output lifecycle operations including
|
|
146
|
+
* recovery of swept/expired virtual outputs and renewal to prevent expiration.
|
|
114
147
|
*
|
|
115
148
|
* Key Features:
|
|
116
|
-
* - **Recovery**: Reclaim swept or expired
|
|
117
|
-
* - **Renewal**: Refresh
|
|
118
|
-
* - **Smart subdust handling**: Automatically includes subdust
|
|
119
|
-
* - **Expiry monitoring**: Check for
|
|
149
|
+
* - **Recovery**: Reclaim swept or expired virtual outputs back to the wallet
|
|
150
|
+
* - **Renewal**: Refresh virtual output expiration time before they expire
|
|
151
|
+
* - **Smart subdust handling**: Automatically includes subdust virtual outputs when economically viable
|
|
152
|
+
* - **Expiry monitoring**: Check for virtual outputs that are expiring soon
|
|
120
153
|
*
|
|
121
|
-
*
|
|
122
|
-
* - The
|
|
123
|
-
* - They are preconfirmed subdust (to consolidate small amounts without locking liquidity on settled
|
|
154
|
+
* Virtual outputs become recoverable when:
|
|
155
|
+
* - The Arkade server sweeps them (virtualStatus.state === "swept") and they remain spendable
|
|
156
|
+
* - They are preconfirmed subdust (to consolidate small amounts without locking liquidity on settled virtual outputs)
|
|
124
157
|
*
|
|
125
158
|
* @example
|
|
126
159
|
* ```typescript
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
160
|
+
* const wallet = await Wallet.create({
|
|
161
|
+
* identity,
|
|
162
|
+
* arkServerUrl: 'https://arkade.computer',
|
|
163
|
+
* settlementConfig: {
|
|
164
|
+
* // Seconds before virtual output expiry to trigger renewal
|
|
165
|
+
* vtxoThreshold: 259_200, // 3 days
|
|
166
|
+
* // Whether to sweep expired boarding inputs back to a fresh boarding address
|
|
167
|
+
* boardingUtxoSweep: true,
|
|
168
|
+
* // Polling interval in milliseconds for checking boarding inputs
|
|
169
|
+
* pollIntervalMs: 60_000 // 1 minute
|
|
170
|
+
* },
|
|
131
171
|
* });
|
|
172
|
+
* const manager = await wallet.getVtxoManager();
|
|
132
173
|
*
|
|
133
174
|
* // Check recoverable balance
|
|
134
175
|
* const balance = await manager.getRecoverableBalance();
|
|
@@ -137,10 +178,10 @@ export declare function getExpiringAndRecoverableVtxos(vtxos: ExtendedVirtualCoi
|
|
|
137
178
|
* const txid = await manager.recoverVtxos();
|
|
138
179
|
* }
|
|
139
180
|
*
|
|
140
|
-
* // Check for expiring
|
|
181
|
+
* // Check for expiring virtual outputs
|
|
141
182
|
* const expiring = await manager.getExpiringVtxos();
|
|
142
183
|
* if (expiring.length > 0) {
|
|
143
|
-
* console.log(`${expiring.length}
|
|
184
|
+
* console.log(`${expiring.length} virtual outputs expiring soon`);
|
|
144
185
|
* const txid = await manager.renewVtxos();
|
|
145
186
|
* }
|
|
146
187
|
* ```
|
|
@@ -183,24 +224,24 @@ export declare class VtxoManager implements AsyncDisposable, IVtxoManager {
|
|
|
183
224
|
/** @deprecated Use settlementConfig instead */
|
|
184
225
|
renewalConfig?: RenewalConfig | undefined, settlementConfig?: SettlementConfig | false);
|
|
185
226
|
/**
|
|
186
|
-
* Recover swept/expired
|
|
227
|
+
* Recover swept/expired virtual outputs by settling them back to the wallet's Arkade address.
|
|
187
228
|
*
|
|
188
229
|
* This method:
|
|
189
|
-
* 1. Fetches all
|
|
190
|
-
* 2. Filters for swept but still spendable
|
|
191
|
-
* 3. Includes subdust
|
|
192
|
-
* 4. Settles everything back to the wallet's
|
|
230
|
+
* 1. Fetches all virtual outputs (including recoverable ones)
|
|
231
|
+
* 2. Filters for swept but still spendable virtual outputs and preconfirmed subdust
|
|
232
|
+
* 3. Includes subdust virtual outputs if the total value >= dust threshold
|
|
233
|
+
* 4. Settles everything back to the wallet's Arkade address
|
|
193
234
|
*
|
|
194
|
-
* Note: Settled
|
|
235
|
+
* Note: Settled virtual outputs with long expiry are NOT recovered to avoid locking liquidity unnecessarily.
|
|
195
236
|
* Only preconfirmed subdust is recovered to consolidate small amounts.
|
|
196
237
|
*
|
|
197
238
|
* @param eventCallback - Optional callback to receive settlement events
|
|
198
239
|
* @returns Settlement transaction ID
|
|
199
|
-
* @throws Error if no recoverable
|
|
240
|
+
* @throws Error if no recoverable virtual outputs found
|
|
200
241
|
*
|
|
201
242
|
* @example
|
|
202
243
|
* ```typescript
|
|
203
|
-
* const manager =
|
|
244
|
+
* const manager = await wallet.getVtxoManager();
|
|
204
245
|
*
|
|
205
246
|
* // Simple recovery
|
|
206
247
|
* const txid = await manager.recoverVtxos();
|
|
@@ -221,13 +262,13 @@ export declare class VtxoManager implements AsyncDisposable, IVtxoManager {
|
|
|
221
262
|
*
|
|
222
263
|
* @example
|
|
223
264
|
* ```typescript
|
|
224
|
-
* const manager =
|
|
265
|
+
* const manager = await wallet.getVtxoManager();
|
|
225
266
|
* const balance = await manager.getRecoverableBalance();
|
|
226
267
|
*
|
|
227
268
|
* if (balance.recoverable > 0n) {
|
|
228
269
|
* console.log(`You can recover ${balance.recoverable} sats`);
|
|
229
270
|
* if (balance.includesSubdust) {
|
|
230
|
-
* console.log(`This includes ${balance.subdust} sats from subdust
|
|
271
|
+
* console.log(`This includes ${balance.subdust} sats from subdust virtual outputs`);
|
|
231
272
|
* }
|
|
232
273
|
* }
|
|
233
274
|
* ```
|
|
@@ -239,36 +280,43 @@ export declare class VtxoManager implements AsyncDisposable, IVtxoManager {
|
|
|
239
280
|
vtxoCount: number;
|
|
240
281
|
}>;
|
|
241
282
|
/**
|
|
242
|
-
* Get
|
|
283
|
+
* Get virtual outputs that are expiring soon based on renewal configuration
|
|
243
284
|
*
|
|
244
285
|
* @param thresholdMs - Optional override for threshold in milliseconds
|
|
245
|
-
* @returns Array of expiring
|
|
286
|
+
* @returns Array of expiring virtual outputs, empty array if renewal is disabled or no virtual outputs expiring
|
|
246
287
|
*
|
|
247
288
|
* @example
|
|
248
289
|
* ```typescript
|
|
249
|
-
* const
|
|
290
|
+
* const wallet = await Wallet.create({
|
|
291
|
+
* identity,
|
|
292
|
+
* arkServerUrl: 'https://arkade.computer',
|
|
293
|
+
* settlementConfig: {
|
|
294
|
+
* vtxoThreshold: 86_400 // 24 hours
|
|
295
|
+
* },
|
|
296
|
+
* });
|
|
297
|
+
* const manager = await wallet.getVtxoManager();
|
|
250
298
|
* const expiringVtxos = await manager.getExpiringVtxos();
|
|
251
299
|
* if (expiringVtxos.length > 0) {
|
|
252
|
-
* console.log(`${expiringVtxos.length}
|
|
300
|
+
* console.log(`${expiringVtxos.length} virtual outputs expiring soon`);
|
|
253
301
|
* }
|
|
254
302
|
* ```
|
|
255
303
|
*/
|
|
256
304
|
getExpiringVtxos(thresholdMs?: number): Promise<ExtendedVirtualCoin[]>;
|
|
257
305
|
/**
|
|
258
|
-
* Renew expiring
|
|
306
|
+
* Renew expiring virtual outputs by settling them back to the wallet's address
|
|
259
307
|
*
|
|
260
|
-
* This method collects all expiring spendable
|
|
308
|
+
* This method collects all expiring spendable virtual outputs (including recoverable ones) and settles
|
|
261
309
|
* them back to the wallet, effectively refreshing their expiration time. This is the
|
|
262
|
-
* primary way to prevent
|
|
310
|
+
* primary way to prevent virtual outputs from expiring.
|
|
263
311
|
*
|
|
264
312
|
* @param eventCallback - Optional callback for settlement events
|
|
265
313
|
* @returns Settlement transaction ID
|
|
266
|
-
* @throws Error if no
|
|
314
|
+
* @throws Error if no virtual outputs available to renew
|
|
267
315
|
* @throws Error if total amount is below dust threshold
|
|
268
316
|
*
|
|
269
317
|
* @example
|
|
270
318
|
* ```typescript
|
|
271
|
-
* const manager =
|
|
319
|
+
* const manager = await wallet.getVtxoManager();
|
|
272
320
|
*
|
|
273
321
|
* // Simple renewal
|
|
274
322
|
* const txid = await manager.renewVtxos();
|
|
@@ -281,49 +329,54 @@ export declare class VtxoManager implements AsyncDisposable, IVtxoManager {
|
|
|
281
329
|
*/
|
|
282
330
|
renewVtxos(eventCallback?: (event: SettlementEvent) => void): Promise<string>;
|
|
283
331
|
/**
|
|
284
|
-
* Get boarding
|
|
332
|
+
* Get boarding inputs whose timelock has expired.
|
|
285
333
|
*
|
|
286
|
-
* These
|
|
334
|
+
* These inputs can no longer be onboarded cooperatively via `settle()` and
|
|
287
335
|
* must be swept back to a fresh boarding address using the unilateral exit path.
|
|
288
336
|
*
|
|
289
|
-
* @returns Array of expired boarding
|
|
337
|
+
* @returns Array of expired boarding inputs
|
|
290
338
|
*
|
|
291
339
|
* @example
|
|
292
340
|
* ```typescript
|
|
293
|
-
* const manager =
|
|
341
|
+
* const manager = await wallet.getVtxoManager();
|
|
294
342
|
* const expired = await manager.getExpiredBoardingUtxos();
|
|
295
343
|
* if (expired.length > 0) {
|
|
296
|
-
* console.log(`${expired.length} expired boarding
|
|
344
|
+
* console.log(`${expired.length} expired boarding inputs to sweep`);
|
|
297
345
|
* }
|
|
298
346
|
* ```
|
|
299
347
|
*/
|
|
300
348
|
getExpiredBoardingUtxos(prefetchedUtxos?: ExtendedCoin[]): Promise<ExtendedCoin[]>;
|
|
301
349
|
/**
|
|
302
|
-
* Sweep expired boarding
|
|
303
|
-
* the unilateral exit path (
|
|
350
|
+
* Sweep expired boarding inputs back to a fresh boarding address via
|
|
351
|
+
* the unilateral exit path (onchain self-spend).
|
|
304
352
|
*
|
|
305
|
-
* This builds a raw
|
|
306
|
-
* - Uses all expired boarding
|
|
353
|
+
* This builds a raw onchain transaction that:
|
|
354
|
+
* - Uses all expired boarding inputs as inputs (spent via the CSV exit script path)
|
|
307
355
|
* - Has a single output to the wallet's boarding address (restarts the timelock)
|
|
308
|
-
* - Batches multiple expired
|
|
356
|
+
* - Batches multiple expired boarding inputs into one transaction
|
|
309
357
|
* - Skips the sweep if the output after fees would be below dust
|
|
310
358
|
*
|
|
311
|
-
* No
|
|
359
|
+
* No Arkade server involvement is needed — this is a pure onchain transaction.
|
|
312
360
|
*
|
|
313
361
|
* @returns The broadcast transaction ID
|
|
314
|
-
* @throws Error if no expired boarding
|
|
362
|
+
* @throws Error if no expired boarding inputs are found
|
|
315
363
|
* @throws Error if output after fees is below dust (not economical to sweep)
|
|
316
|
-
* @throws Error if boarding
|
|
364
|
+
* @throws Error if boarding input sweep is not enabled in settlementConfig
|
|
317
365
|
*
|
|
318
366
|
* @example
|
|
319
367
|
* ```typescript
|
|
320
|
-
* const
|
|
321
|
-
*
|
|
368
|
+
* const wallet = await Wallet.create({
|
|
369
|
+
* identity,
|
|
370
|
+
* arkServerUrl: 'https://arkade.computer',
|
|
371
|
+
* settlementConfig: {
|
|
372
|
+
* boardingUtxoSweep: true,
|
|
373
|
+
* },
|
|
322
374
|
* });
|
|
375
|
+
* const manager = await wallet.getVtxoManager();
|
|
323
376
|
*
|
|
324
377
|
* try {
|
|
325
378
|
* const txid = await manager.sweepExpiredBoardingUtxos();
|
|
326
|
-
* console.log('Swept expired boarding
|
|
379
|
+
* console.log('Swept expired boarding inputs:', txid);
|
|
327
380
|
* } catch (e) {
|
|
328
381
|
* console.log('No sweep needed or not economical');
|
|
329
382
|
* }
|
|
@@ -338,7 +391,7 @@ export declare class VtxoManager implements AsyncDisposable, IVtxoManager {
|
|
|
338
391
|
private getBoardingExitLeaf;
|
|
339
392
|
/** Returns the pkScript (output script) of the boarding tapscript. */
|
|
340
393
|
private getBoardingOutputScript;
|
|
341
|
-
/** Returns the
|
|
394
|
+
/** Returns the onchain provider for fee estimation and broadcasting. */
|
|
342
395
|
private getOnchainProvider;
|
|
343
396
|
/** Returns the Bitcoin network configuration from the wallet. */
|
|
344
397
|
private getNetwork;
|
|
@@ -349,8 +402,8 @@ export declare class VtxoManager implements AsyncDisposable, IVtxoManager {
|
|
|
349
402
|
private getNextPollDelay;
|
|
350
403
|
/**
|
|
351
404
|
* Starts a polling loop that:
|
|
352
|
-
* 1. Auto-settles new boarding
|
|
353
|
-
* 2. Sweeps expired boarding
|
|
405
|
+
* 1. Auto-settles new boarding inputs into Arkade
|
|
406
|
+
* 2. Sweeps expired boarding inputs (when boardingUtxoSweep is enabled)
|
|
354
407
|
*
|
|
355
408
|
* Uses setTimeout chaining (not setInterval) so a slow/blocked poll
|
|
356
409
|
* cannot stack up and the next delay can incorporate backoff.
|
|
@@ -359,7 +412,7 @@ export declare class VtxoManager implements AsyncDisposable, IVtxoManager {
|
|
|
359
412
|
private schedulePoll;
|
|
360
413
|
private pollBoardingUtxos;
|
|
361
414
|
/**
|
|
362
|
-
* Auto-settle new (unexpired) boarding
|
|
415
|
+
* Auto-settle new (unexpired) boarding inputs into Arkade.
|
|
363
416
|
* Skips UTXOs that are already expired (those are handled by sweep).
|
|
364
417
|
* Only settles UTXOs not already in-flight (tracked in knownBoardingUtxos).
|
|
365
418
|
* UTXOs are marked as known only after a successful settle, so failed
|