@arkade-os/sdk 0.4.15 → 0.4.16
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 +40 -24
- 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 +125 -67
- 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 +40 -24
- 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 +125 -67
- 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 +40 -63
- 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
|
@@ -9,7 +9,7 @@ import { Transaction } from "../utils/transaction";
|
|
|
9
9
|
* Onchain Bitcoin wallet implementation for traditional Bitcoin transactions.
|
|
10
10
|
*
|
|
11
11
|
* This wallet handles regular Bitcoin transactions on the blockchain without
|
|
12
|
-
* using the
|
|
12
|
+
* using the Arkade protocol. It supports P2TR (Pay-to-Taproot) addresses and
|
|
13
13
|
* provides basic Bitcoin wallet functionality.
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
@@ -29,16 +29,38 @@ export declare class OnchainWallet implements AnchorBumper {
|
|
|
29
29
|
readonly provider: OnchainProvider;
|
|
30
30
|
readonly network: Network;
|
|
31
31
|
private constructor();
|
|
32
|
+
/**
|
|
33
|
+
* Create an onchain wallet for the given identity and Bitcoin network.
|
|
34
|
+
*
|
|
35
|
+
* @param identity - Identity used to derive the Taproot key and sign transactions
|
|
36
|
+
* @param networkName - Bitcoin network name, @see NetworkName
|
|
37
|
+
* @param provider - Optional onchain provider override, @see OnchainProvider
|
|
38
|
+
* @returns Configured onchain wallet
|
|
39
|
+
* @defaultValue `provider = new EsploraProvider('https://mempool.space/api')`
|
|
40
|
+
* @throws Error if the configured identity cannot produce a valid x-only public key
|
|
41
|
+
*/
|
|
32
42
|
static create(identity: Identity, networkName: NetworkName, provider?: OnchainProvider): Promise<OnchainWallet>;
|
|
33
43
|
get address(): string;
|
|
44
|
+
/**
|
|
45
|
+
* Fetch spendable onchain outputs for the wallet address.
|
|
46
|
+
*
|
|
47
|
+
* @returns Spendable onchain outputs for the wallet address
|
|
48
|
+
* @see getBalance
|
|
49
|
+
*/
|
|
34
50
|
getCoins(): Promise<Coin[]>;
|
|
51
|
+
/**
|
|
52
|
+
* Return the wallet's total onchain balance in satoshis.
|
|
53
|
+
*
|
|
54
|
+
* @returns Confirmed plus unconfirmed onchain balance
|
|
55
|
+
* @see getCoins
|
|
56
|
+
*/
|
|
35
57
|
getBalance(): Promise<number>;
|
|
36
58
|
/**
|
|
37
59
|
* Iteratively selects coins and estimates transaction fees until convergence.
|
|
38
60
|
*
|
|
39
|
-
* This method handles the circular dependency between
|
|
61
|
+
* This method handles the circular dependency between output selection and fee
|
|
40
62
|
* estimation: the fee depends on transaction size, which depends on the number
|
|
41
|
-
* of inputs (selected
|
|
63
|
+
* of inputs (selected outputs) and whether a change output is needed.
|
|
42
64
|
*
|
|
43
65
|
* The algorithm iterates up to 10 times, refining the fee estimate based on
|
|
44
66
|
* the actual transaction structure. It resolves dust oscillation loops that
|
|
@@ -47,7 +69,7 @@ export declare class OnchainWallet implements AnchorBumper {
|
|
|
47
69
|
* When a lower fee is computed (indicating the change output was dropped),
|
|
48
70
|
* the function accepts this state to guarantee termination.
|
|
49
71
|
*
|
|
50
|
-
* @param coins - Available
|
|
72
|
+
* @param coins - Available onchain outputs to select from
|
|
51
73
|
* @param amount - Target send amount in satoshis
|
|
52
74
|
* @param feeRate - Fee rate in sat/vbyte
|
|
53
75
|
* @param recipientAddress - Destination address for size estimation
|
|
@@ -55,7 +77,23 @@ export declare class OnchainWallet implements AnchorBumper {
|
|
|
55
77
|
* @throws Error if fee estimation fails to converge within max iterations
|
|
56
78
|
*/
|
|
57
79
|
private estimateFeesAndSelectCoins;
|
|
80
|
+
/**
|
|
81
|
+
* Send bitcoin to a single onchain address.
|
|
82
|
+
*
|
|
83
|
+
* @param params - destination `address`, `amount` (in satoshis), and optional `feeRate` override (other fields ignored)
|
|
84
|
+
* @returns Broadcast transaction id
|
|
85
|
+
* @throws Error if the amount is non-positive, below dust, or cannot be funded
|
|
86
|
+
* @see SendBitcoinParams
|
|
87
|
+
*/
|
|
58
88
|
send(params: SendBitcoinParams): Promise<string>;
|
|
89
|
+
/**
|
|
90
|
+
* CPFP-bump a parent transaction that contains a pay-to-anchor output.
|
|
91
|
+
*
|
|
92
|
+
* @param parent - Parent transaction containing a pay-to-anchor output
|
|
93
|
+
* @returns Tuple of parent transaction id and child transaction id
|
|
94
|
+
* @throws Error if the parent transaction has no pay-to-anchor output or bumping cannot be funded
|
|
95
|
+
* @see send
|
|
96
|
+
*/
|
|
59
97
|
bumpP2A(parent: Transaction): Promise<[string, string]>;
|
|
60
98
|
}
|
|
61
99
|
/**
|
|
@@ -1,34 +1,64 @@
|
|
|
1
1
|
import { ExtendedCoin, IWallet } from ".";
|
|
2
2
|
import { FeeInfo, SettlementEvent } from "../providers/ark";
|
|
3
3
|
/**
|
|
4
|
-
* Ramps is a class wrapping
|
|
4
|
+
* Ramps is a class wrapping `settle` method to provide a more convenient interface for onboarding and offboarding operations.
|
|
5
|
+
*
|
|
6
|
+
* @see IWallet.settle
|
|
7
|
+
* @see onboard
|
|
8
|
+
* @see offboard
|
|
5
9
|
*
|
|
6
10
|
* @example
|
|
7
11
|
* ```typescript
|
|
8
12
|
* const ramps = new Ramps(wallet);
|
|
9
|
-
*
|
|
10
|
-
* await ramps.
|
|
13
|
+
* const feeInfo = { intentFee: {}, txFeeRate: '1' };
|
|
14
|
+
* await ramps.onboard(feeInfo); // onboard all boarding inputs
|
|
15
|
+
* await ramps.offboard('bc1q...', feeInfo); // collaboratively exit all virtual outputs to an onchain address
|
|
11
16
|
* ```
|
|
12
17
|
*/
|
|
13
18
|
export declare class Ramps {
|
|
14
19
|
readonly wallet: IWallet;
|
|
20
|
+
/**
|
|
21
|
+
* Create convenience wrappers for onboarding and offboarding flows.
|
|
22
|
+
*
|
|
23
|
+
* @param wallet - Wallet used to query funds and execute settlement transactions
|
|
24
|
+
*/
|
|
15
25
|
constructor(wallet: IWallet);
|
|
16
26
|
/**
|
|
17
|
-
* Onboard boarding
|
|
27
|
+
* Onboard boarding inputs.
|
|
18
28
|
*
|
|
19
29
|
* @param feeInfo - The fee info to deduct from the onboard amount.
|
|
20
|
-
* @param boardingUtxos -
|
|
21
|
-
* @param amount -
|
|
22
|
-
* @param eventCallback -
|
|
30
|
+
* @param boardingUtxos - Specific boarding inputs to onboard. If not provided, all boarding inputs will be used.
|
|
31
|
+
* @param amount - Amount to onboard. If not provided, the total amount of boarding inputs will be onboarded.
|
|
32
|
+
* @param eventCallback - Optional callback that receives settlement events
|
|
33
|
+
* @returns The Arkade transaction id created by settlement
|
|
34
|
+
* @throws Error if no boarding inputs remain after fee deduction or if `amount` exceeds available value
|
|
35
|
+
* @see IWallet.getBoardingUtxos
|
|
36
|
+
* @see IWallet.settle
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const feeInfo = { intentFee: {}, txFeeRate: '1' };
|
|
40
|
+
* const ramps = new Ramps(wallet);
|
|
41
|
+
* await ramps.onboard(feeInfo);
|
|
42
|
+
* ```
|
|
23
43
|
*/
|
|
24
44
|
onboard(feeInfo: FeeInfo, boardingUtxos?: ExtendedCoin[], amount?: bigint, eventCallback?: (event: SettlementEvent) => void): ReturnType<IWallet["settle"]>;
|
|
25
45
|
/**
|
|
26
|
-
* Offboard
|
|
46
|
+
* Offboard virtual outputs, or collaboratively exit them to an onchain address.
|
|
27
47
|
*
|
|
28
48
|
* @param destinationAddress - The destination address to offboard to.
|
|
29
49
|
* @param feeInfo - The fee info to deduct from the offboard amount.
|
|
30
|
-
* @param amount - The amount to offboard. If not provided, the total amount of
|
|
31
|
-
* @param eventCallback -
|
|
50
|
+
* @param amount - The amount to offboard. If not provided, the total amount of virtual outputs will be offboarded.
|
|
51
|
+
* @param eventCallback - Optional callback that receives settlement events
|
|
52
|
+
* @returns The Arkade transaction id created by settlement
|
|
53
|
+
* @throws Error if no virtual outputs remain after fee deduction or the destination address cannot be decoded
|
|
54
|
+
* @see IWallet.getVtxos
|
|
55
|
+
* @see IWallet.settle
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* const feeInfo = { intentFee: {}, txFeeRate: '1' };
|
|
59
|
+
* const ramps = new Ramps(wallet);
|
|
60
|
+
* await ramps.offboard('bc1q...', feeInfo);
|
|
61
|
+
* ```
|
|
32
62
|
*/
|
|
33
63
|
offboard(destinationAddress: string, feeInfo: FeeInfo, amount?: bigint, eventCallback?: (event: SettlementEvent) => void): ReturnType<IWallet["settle"]>;
|
|
34
64
|
}
|
|
@@ -290,7 +290,7 @@ export type ResponseContractEvent = ResponseEnvelope & {
|
|
|
290
290
|
export type RequestSend = RequestEnvelope & {
|
|
291
291
|
type: "SEND";
|
|
292
292
|
payload: {
|
|
293
|
-
recipients: Recipient[];
|
|
293
|
+
recipients: [Recipient, ...Recipient[]];
|
|
294
294
|
};
|
|
295
295
|
};
|
|
296
296
|
export type ResponseSend = ResponseEnvelope & {
|
|
@@ -479,7 +479,7 @@ export declare class WalletMessageHandler implements MessageHandler<WalletUpdate
|
|
|
479
479
|
private getSpendableVtxos;
|
|
480
480
|
private onWalletInitialized;
|
|
481
481
|
/**
|
|
482
|
-
* Refresh
|
|
482
|
+
* Refresh virtual outputs, boarding inputs, and transaction history from cache.
|
|
483
483
|
* Shared by onWalletInitialized (full bootstrap) and reloadWallet
|
|
484
484
|
* (post-refresh), avoiding duplicate subscriptions and VtxoManager restarts.
|
|
485
485
|
*/
|
|
@@ -497,12 +497,12 @@ export declare class WalletMessageHandler implements MessageHandler<WalletUpdate
|
|
|
497
497
|
private handleGetVtxos;
|
|
498
498
|
private clear;
|
|
499
499
|
/**
|
|
500
|
-
* Read all
|
|
500
|
+
* Read all virtual outputs from the repository, aggregated across all contract
|
|
501
501
|
* addresses and the wallet's primary address, with deduplication.
|
|
502
502
|
*/
|
|
503
503
|
private getVtxosFromRepo;
|
|
504
504
|
/**
|
|
505
|
-
* Build transaction history from cached
|
|
505
|
+
* Build transaction history from cached virtual outputs without hitting the indexer.
|
|
506
506
|
* Falls back to indexer only for uncached transaction timestamps.
|
|
507
507
|
*/
|
|
508
508
|
private buildTransactionHistoryFromCache;
|
|
@@ -25,20 +25,18 @@ type PrivateKeyIdentity = Identity & {
|
|
|
25
25
|
* @example
|
|
26
26
|
* ```typescript
|
|
27
27
|
* // SIMPLE: Recommended approach
|
|
28
|
-
* const identity = SingleKey.fromHex('your_private_key_hex');
|
|
29
28
|
* const wallet = await ServiceWorkerWallet.setup({
|
|
30
29
|
* serviceWorkerPath: '/service-worker.js',
|
|
31
|
-
* arkServerUrl: 'https://
|
|
32
|
-
* identity
|
|
30
|
+
* arkServerUrl: 'https://arkade.computer',
|
|
31
|
+
* identity: MnemonicIdentity.fromMnemonic('abandon abandon...')
|
|
33
32
|
* });
|
|
34
33
|
*
|
|
35
34
|
* // ADVANCED: Manual setup with service worker control
|
|
36
|
-
* const
|
|
37
|
-
* const identity = SingleKey.fromHex('your_private_key_hex');
|
|
35
|
+
* const serviceWorker = await setupServiceWorker("/service-worker.js");
|
|
38
36
|
* const wallet = await ServiceWorkerWallet.create({
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
37
|
+
* serviceWorker,
|
|
38
|
+
* arkServerUrl: 'https://arkade.computer',
|
|
39
|
+
* identity: MnemonicIdentity.fromMnemonic('abandon abandon...')
|
|
42
40
|
* });
|
|
43
41
|
*
|
|
44
42
|
* // Use like any other wallet
|
|
@@ -47,24 +45,60 @@ type PrivateKeyIdentity = Identity & {
|
|
|
47
45
|
* ```
|
|
48
46
|
*/
|
|
49
47
|
interface ServiceWorkerWalletOptions {
|
|
48
|
+
/** Optional Arkade server public key used to construct and validate Arkade addresses. */
|
|
50
49
|
arkServerPublicKey?: string;
|
|
50
|
+
/** Base URL of the Arkade server. */
|
|
51
51
|
arkServerUrl: string;
|
|
52
|
+
/** Optional override for the indexer URL. */
|
|
52
53
|
indexerUrl?: string;
|
|
54
|
+
/** Optional override for the Esplora API URL. */
|
|
53
55
|
esploraUrl?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Repository-backed storage configuration overrides.
|
|
58
|
+
* Defaults to IndexedDB if unset.
|
|
59
|
+
*/
|
|
54
60
|
storage?: StorageConfig;
|
|
61
|
+
/** Identity used to derive addresses and optionally sign operations. */
|
|
55
62
|
identity: ReadonlyIdentity | Identity;
|
|
63
|
+
/** Optional delegation service URL. */
|
|
56
64
|
delegatorUrl?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Override the default tag used for messages sent to and received from the service worker.
|
|
67
|
+
* @see DEFAULT_MESSAGE_TAG
|
|
68
|
+
*/
|
|
57
69
|
walletUpdaterTag?: string;
|
|
70
|
+
/** Timeout used while bootstrapping the message bus inside the service worker. */
|
|
58
71
|
messageBusTimeoutMs?: number;
|
|
72
|
+
/** Optional settlement configuration forwarded to the worker wallet. */
|
|
59
73
|
settlementConfig?: SettlementConfig | false;
|
|
74
|
+
/** Optional contract watcher configuration forwarded to the worker wallet. */
|
|
60
75
|
watcherConfig?: Partial<Omit<ContractWatcherConfig, "indexerProvider">>;
|
|
76
|
+
/**
|
|
77
|
+
* Per-request timeout overrides for wallet-updater messages.
|
|
78
|
+
* @see DEFAULT_MESSAGE_TIMEOUTS
|
|
79
|
+
*/
|
|
61
80
|
messageTimeouts?: MessageTimeouts;
|
|
62
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Options for creating a service-worker wallet with an existing worker instance.
|
|
84
|
+
*
|
|
85
|
+
* @see ServiceWorkerReadonlyWallet.create
|
|
86
|
+
* @see ServiceWorkerWallet.create
|
|
87
|
+
*/
|
|
63
88
|
export type ServiceWorkerWalletCreateOptions = ServiceWorkerWalletOptions & {
|
|
89
|
+
/** Existing service worker instance used for messaging. */
|
|
64
90
|
serviceWorker: ServiceWorker;
|
|
65
91
|
};
|
|
92
|
+
/**
|
|
93
|
+
* Options for registering a service worker and then creating a wallet around it.
|
|
94
|
+
*
|
|
95
|
+
* @see ServiceWorkerReadonlyWallet.setup
|
|
96
|
+
* @see ServiceWorkerWallet.setup
|
|
97
|
+
*/
|
|
66
98
|
export type ServiceWorkerWalletSetupOptions = ServiceWorkerWalletOptions & {
|
|
99
|
+
/** Path to the service worker script to register. */
|
|
67
100
|
serviceWorkerPath: string;
|
|
101
|
+
/** Timeout while waiting for the service worker to activate. */
|
|
68
102
|
serviceWorkerActivationTimeoutMs?: number;
|
|
69
103
|
};
|
|
70
104
|
type MessageBusInitConfig = {
|
|
@@ -101,25 +135,26 @@ export declare class ServiceWorkerReadonlyWallet implements IReadonlyWallet {
|
|
|
101
135
|
get assetManager(): IReadonlyAssetManager;
|
|
102
136
|
protected constructor(serviceWorker: ServiceWorker, identity: ReadonlyIdentity, walletRepository: WalletRepository, contractRepository: ContractRepository, messageTag: string);
|
|
103
137
|
private getTimeoutForRequest;
|
|
138
|
+
/**
|
|
139
|
+
* Create a readonly service-worker wallet bound to an already-registered worker.
|
|
140
|
+
*
|
|
141
|
+
* @param options - Service worker, identity, and backend configuration
|
|
142
|
+
* @returns Initialized readonly service-worker wallet
|
|
143
|
+
* @throws Error if service-worker initialization fails
|
|
144
|
+
*/
|
|
104
145
|
static create(options: ServiceWorkerWalletCreateOptions): Promise<ServiceWorkerReadonlyWallet>;
|
|
105
146
|
/**
|
|
106
|
-
* Simplified setup method that handles service worker registration
|
|
107
|
-
*
|
|
147
|
+
* Simplified setup method that handles service worker registration
|
|
148
|
+
* and wallet initialization automatically.
|
|
149
|
+
*
|
|
150
|
+
* @see ServiceWorkerReadonlyWallet.create
|
|
108
151
|
*
|
|
109
152
|
* @example
|
|
110
153
|
* ```typescript
|
|
111
|
-
* // One-liner setup - handles everything automatically!
|
|
112
|
-
* const wallet = await ServiceWorkerReadonlyWallet.setup({
|
|
113
|
-
* serviceWorkerPath: '/service-worker.js',
|
|
114
|
-
* arkServerUrl: 'https://mutinynet.arkade.sh'
|
|
115
|
-
* });
|
|
116
|
-
*
|
|
117
|
-
* // With custom readonly identity
|
|
118
|
-
* const identity = ReadonlySingleKey.fromPublicKey('your_public_key_hex');
|
|
119
154
|
* const wallet = await ServiceWorkerReadonlyWallet.setup({
|
|
120
155
|
* serviceWorkerPath: '/service-worker.js',
|
|
121
|
-
* arkServerUrl: 'https://
|
|
122
|
-
* identity
|
|
156
|
+
* arkServerUrl: 'https://arkade.computer',
|
|
157
|
+
* identity: ReadonlySingleKey.fromPublicKey('your_public_key_hex')
|
|
123
158
|
* });
|
|
124
159
|
* ```
|
|
125
160
|
*/
|
|
@@ -131,14 +166,25 @@ export declare class ServiceWorkerReadonlyWallet implements IReadonlyWallet {
|
|
|
131
166
|
private sendMessageWithRetry;
|
|
132
167
|
protected sendMessageWithEvents(request: WalletUpdaterRequest, onEvent: (response: WalletUpdaterResponse) => void, isComplete: (response: WalletUpdaterResponse) => boolean): Promise<WalletUpdaterResponse>;
|
|
133
168
|
private reinitialize;
|
|
169
|
+
/** Clear cached wallet state from both the page and service worker storage. */
|
|
134
170
|
clear(): Promise<void>;
|
|
135
171
|
getAddress(): Promise<string>;
|
|
136
172
|
getBoardingAddress(): Promise<string>;
|
|
137
173
|
getBalance(): Promise<WalletBalance>;
|
|
138
174
|
getBoardingUtxos(): Promise<ExtendedCoin[]>;
|
|
175
|
+
/**
|
|
176
|
+
* Return service-worker wallet status, including connectivity and sync state.
|
|
177
|
+
*
|
|
178
|
+
* @returns Current service-worker wallet status payload including `walletInitalized` and `xOnlyPublicKey`
|
|
179
|
+
*/
|
|
139
180
|
getStatus(): Promise<ResponseGetStatus["payload"]>;
|
|
140
181
|
getTransactionHistory(): Promise<ArkTransaction[]>;
|
|
141
182
|
getVtxos(filter?: GetVtxosFilter): Promise<ExtendedVirtualCoin[]>;
|
|
183
|
+
/**
|
|
184
|
+
* Trigger a wallet reload inside the service worker.
|
|
185
|
+
*
|
|
186
|
+
* @returns `true` when the wallet was reloaded
|
|
187
|
+
*/
|
|
142
188
|
reload(): Promise<boolean>;
|
|
143
189
|
getContractManager(): Promise<IContractManager>;
|
|
144
190
|
}
|
|
@@ -153,30 +199,22 @@ export declare class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet imp
|
|
|
153
199
|
get assetManager(): IAssetManager;
|
|
154
200
|
static create(options: ServiceWorkerWalletCreateOptions): Promise<ServiceWorkerWallet>;
|
|
155
201
|
/**
|
|
156
|
-
* Simplified setup method that handles service worker registration
|
|
157
|
-
*
|
|
202
|
+
* Simplified setup method that handles service worker registration
|
|
203
|
+
* and wallet initialization automatically.
|
|
158
204
|
*
|
|
159
205
|
* @example
|
|
160
206
|
* ```typescript
|
|
161
|
-
* // One-liner setup - handles everything automatically!
|
|
162
|
-
* const wallet = await ServiceWorkerWallet.setup({
|
|
163
|
-
* serviceWorkerPath: '/service-worker.js',
|
|
164
|
-
* arkServerUrl: 'https://mutinynet.arkade.sh'
|
|
165
|
-
* });
|
|
166
|
-
*
|
|
167
|
-
* // With custom identity
|
|
168
|
-
* const identity = SingleKey.fromHex('your_private_key_hex');
|
|
169
207
|
* const wallet = await ServiceWorkerWallet.setup({
|
|
170
208
|
* serviceWorkerPath: '/service-worker.js',
|
|
171
|
-
* arkServerUrl: 'https://
|
|
172
|
-
* identity
|
|
209
|
+
* arkServerUrl: 'https://arkade.computer',
|
|
210
|
+
* identity: MnemonicIdentity.fromMnemonic('abandon abandon...')
|
|
173
211
|
* });
|
|
174
212
|
* ```
|
|
175
213
|
*/
|
|
176
214
|
static setup(options: ServiceWorkerWalletSetupOptions): Promise<ServiceWorkerWallet>;
|
|
177
215
|
sendBitcoin(params: SendBitcoinParams): Promise<string>;
|
|
178
216
|
settle(params?: SettleParams, callback?: (event: SettlementEvent) => void): Promise<string>;
|
|
179
|
-
send(...recipients: Recipient[]): Promise<string>;
|
|
217
|
+
send(...recipients: [Recipient, ...Recipient[]]): Promise<string>;
|
|
180
218
|
getDelegatorManager(): Promise<IDelegatorManager | undefined>;
|
|
181
219
|
getVtxoManager(): Promise<IVtxoManager>;
|
|
182
220
|
}
|
|
@@ -36,7 +36,7 @@ export declare namespace Unroll {
|
|
|
36
36
|
type: StepType.WAIT;
|
|
37
37
|
} & WaitStep);
|
|
38
38
|
/**
|
|
39
|
-
* Manages the unrolling process of a
|
|
39
|
+
* Manages the unrolling process of a virtual output back to the Bitcoin blockchain.
|
|
40
40
|
*
|
|
41
41
|
* The Session class implements an async iterator that processes the unrolling steps:
|
|
42
42
|
* 1. **WAIT**: Waits for a transaction to be confirmed onchain (if it's in mempool)
|
|
@@ -60,7 +60,7 @@ export declare namespace Unroll {
|
|
|
60
60
|
* console.log(`Broadcasting transaction ${doneStep.tx.id}`);
|
|
61
61
|
* break;
|
|
62
62
|
* case Unroll.StepType.DONE:
|
|
63
|
-
* console.log(`Unrolling complete for
|
|
63
|
+
* console.log(`Unrolling complete for virtual output ${doneStep.vtxoTxid}`);
|
|
64
64
|
* break;
|
|
65
65
|
* }
|
|
66
66
|
* }
|
|
@@ -73,9 +73,11 @@ export declare namespace Unroll {
|
|
|
73
73
|
readonly bumper: AnchorBumper;
|
|
74
74
|
readonly explorer: OnchainProvider;
|
|
75
75
|
readonly indexer: IndexerProvider;
|
|
76
|
+
/** Create an unroll session from a virtual output outpoint and its dependency chain. */
|
|
76
77
|
constructor(toUnroll: Outpoint & {
|
|
77
78
|
chain: ChainTx[];
|
|
78
79
|
}, bumper: AnchorBumper, explorer: OnchainProvider, indexer: IndexerProvider);
|
|
80
|
+
/** Create an unroll session by loading the virtual output chain from the indexer. */
|
|
79
81
|
static create(toUnroll: Outpoint, bumper: AnchorBumper, explorer: OnchainProvider, indexer: IndexerProvider): Promise<Session>;
|
|
80
82
|
/**
|
|
81
83
|
* Get the next step to be executed
|
|
@@ -91,11 +93,11 @@ export declare namespace Unroll {
|
|
|
91
93
|
[Symbol.asyncIterator](): AsyncIterator<Step>;
|
|
92
94
|
}
|
|
93
95
|
/**
|
|
94
|
-
* Complete the unroll of a
|
|
95
|
-
* @param wallet the wallet owning the
|
|
96
|
-
* @param vtxoTxids the txids of the
|
|
96
|
+
* Complete the unroll of a virtual output by broadcasting the transaction that spends the CSV path.
|
|
97
|
+
* @param wallet the wallet owning the virtual output(s)
|
|
98
|
+
* @param vtxoTxids the txids of the virtual output(s) to complete unroll
|
|
97
99
|
* @param outputAddress the address to send the unrolled funds to
|
|
98
|
-
* @throws if the
|
|
100
|
+
* @throws if the virtual output(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
|
|
99
101
|
* @returns the txid of the transaction spending the unrolled funds
|
|
100
102
|
*/
|
|
101
103
|
function completeUnroll(wallet: Wallet, vtxoTxids: string[], outputAddress: string): Promise<string>;
|