@arkade-os/sdk 0.3.0-alpha.8 → 0.3.1-alpha.1
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 +64 -14
- package/dist/cjs/arknote/index.js +3 -3
- package/dist/cjs/forfeit.js +5 -2
- package/dist/cjs/identity/singleKey.js +5 -4
- package/dist/cjs/index.js +6 -3
- package/dist/cjs/{bip322 → intent}/index.js +37 -55
- package/dist/cjs/providers/ark.js +62 -23
- package/dist/cjs/providers/expoArk.js +15 -170
- package/dist/cjs/providers/expoIndexer.js +22 -111
- package/dist/cjs/providers/expoUtils.js +124 -0
- package/dist/cjs/script/base.js +1 -2
- package/dist/cjs/script/tapscript.js +20 -21
- package/dist/cjs/script/vhtlc.js +2 -2
- package/dist/cjs/tree/signingSession.js +7 -8
- package/dist/cjs/tree/txTree.js +3 -4
- package/dist/cjs/tree/validation.js +2 -3
- package/dist/cjs/utils/arkTransaction.js +104 -12
- package/dist/cjs/utils/unknownFields.js +5 -5
- package/dist/cjs/wallet/onchain.js +4 -5
- package/dist/cjs/wallet/serviceWorker/utils.js +2 -0
- package/dist/cjs/wallet/serviceWorker/wallet.js +4 -8
- package/dist/cjs/wallet/serviceWorker/worker.js +23 -18
- package/dist/cjs/wallet/unroll.js +6 -7
- package/dist/cjs/wallet/vtxo-manager.js +381 -0
- package/dist/cjs/wallet/wallet.js +63 -94
- package/dist/esm/arknote/index.js +2 -2
- package/dist/esm/forfeit.js +4 -1
- package/dist/esm/identity/singleKey.js +7 -6
- package/dist/esm/index.js +7 -6
- package/dist/esm/{bip322 → intent}/index.js +31 -48
- package/dist/esm/providers/ark.js +62 -23
- package/dist/esm/providers/expoArk.js +15 -137
- package/dist/esm/providers/expoIndexer.js +22 -78
- package/dist/esm/providers/expoUtils.js +87 -0
- package/dist/esm/script/base.js +1 -2
- package/dist/esm/script/tapscript.js +1 -2
- package/dist/esm/script/vhtlc.js +1 -1
- package/dist/esm/tree/signingSession.js +8 -9
- package/dist/esm/tree/txTree.js +3 -4
- package/dist/esm/tree/validation.js +2 -3
- package/dist/esm/utils/arkTransaction.js +95 -4
- package/dist/esm/utils/unknownFields.js +1 -1
- package/dist/esm/wallet/onchain.js +1 -2
- package/dist/esm/wallet/serviceWorker/utils.js +1 -0
- package/dist/esm/wallet/serviceWorker/wallet.js +5 -9
- package/dist/esm/wallet/serviceWorker/worker.js +23 -18
- package/dist/esm/wallet/unroll.js +2 -3
- package/dist/esm/wallet/vtxo-manager.js +372 -0
- package/dist/esm/wallet/wallet.js +56 -87
- package/dist/types/arknote/index.d.ts +1 -1
- package/dist/types/forfeit.d.ts +2 -2
- package/dist/types/identity/index.d.ts +1 -1
- package/dist/types/identity/singleKey.d.ts +1 -1
- package/dist/types/index.d.ts +6 -5
- package/dist/types/intent/index.d.ts +41 -0
- package/dist/types/providers/ark.d.ts +55 -21
- package/dist/types/providers/expoIndexer.d.ts +2 -10
- package/dist/types/providers/expoUtils.d.ts +18 -0
- package/dist/types/providers/indexer.d.ts +1 -9
- package/dist/types/script/base.d.ts +3 -2
- package/dist/types/tree/signingSession.d.ts +10 -10
- package/dist/types/utils/anchor.d.ts +2 -2
- package/dist/types/utils/arkTransaction.d.ts +13 -3
- package/dist/types/utils/unknownFields.d.ts +2 -2
- package/dist/types/wallet/index.d.ts +6 -4
- package/dist/types/wallet/onchain.d.ts +1 -1
- package/dist/types/wallet/serviceWorker/utils.d.ts +1 -0
- package/dist/types/wallet/serviceWorker/wallet.d.ts +2 -2
- package/dist/types/wallet/serviceWorker/worker.d.ts +3 -1
- package/dist/types/wallet/unroll.d.ts +1 -1
- package/dist/types/wallet/vtxo-manager.d.ts +207 -0
- package/dist/types/wallet/wallet.d.ts +7 -3
- package/package.json +1 -2
- package/dist/cjs/bip322/errors.js +0 -13
- package/dist/esm/bip322/errors.js +0 -9
- package/dist/types/bip322/errors.d.ts +0 -6
- package/dist/types/bip322/index.d.ts +0 -57
|
@@ -4,7 +4,7 @@ export interface Identity {
|
|
|
4
4
|
signerSession(): SignerSession;
|
|
5
5
|
xOnlyPublicKey(): Promise<Uint8Array>;
|
|
6
6
|
compressedPublicKey(): Promise<Uint8Array>;
|
|
7
|
-
signMessage(message:
|
|
7
|
+
signMessage(message: Uint8Array, signatureType: "schnorr" | "ecdsa"): Promise<Uint8Array>;
|
|
8
8
|
sign(tx: Transaction, inputIndexes?: number[]): Promise<Transaction>;
|
|
9
9
|
}
|
|
10
10
|
export * from "./singleKey";
|
|
@@ -35,5 +35,5 @@ export declare class SingleKey implements Identity {
|
|
|
35
35
|
compressedPublicKey(): Promise<Uint8Array>;
|
|
36
36
|
xOnlyPublicKey(): Promise<Uint8Array>;
|
|
37
37
|
signerSession(): SignerSession;
|
|
38
|
-
signMessage(message:
|
|
38
|
+
signMessage(message: Uint8Array, signatureType?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
|
|
39
39
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { Wallet, waitForIncomingFunds, IncomingFunds } from "./wallet/wallet";
|
|
|
10
10
|
import { TxTree, TxTreeNode } from "./tree/txTree";
|
|
11
11
|
import { SignerSession, TreeNonces, TreePartialSigs } from "./tree/signingSession";
|
|
12
12
|
import { Ramps } from "./wallet/ramps";
|
|
13
|
+
import { VtxoManager } from "./wallet/vtxo-manager";
|
|
13
14
|
import { ServiceWorkerWallet } from "./wallet/serviceWorker/wallet";
|
|
14
15
|
import { OnchainWallet } from "./wallet/onchain";
|
|
15
16
|
import { setupServiceWorker } from "./wallet/serviceWorker/utils";
|
|
@@ -17,11 +18,11 @@ import { Worker } from "./wallet/serviceWorker/worker";
|
|
|
17
18
|
import { Request } from "./wallet/serviceWorker/request";
|
|
18
19
|
import { Response } from "./wallet/serviceWorker/response";
|
|
19
20
|
import { ESPLORA_URL, EsploraProvider, OnchainProvider, ExplorerTransaction } from "./providers/onchain";
|
|
20
|
-
import { RestArkProvider, ArkProvider, SettlementEvent, SettlementEventType, ArkInfo,
|
|
21
|
+
import { RestArkProvider, ArkProvider, SettlementEvent, SettlementEventType, ArkInfo, SignedIntent, Output, TxNotification, BatchFinalizationEvent, BatchFinalizedEvent, BatchFailedEvent, TreeSigningStartedEvent, TreeNoncesAggregatedEvent, BatchStartedEvent, TreeTxEvent, TreeSignatureEvent, ScheduledSession } from "./providers/ark";
|
|
21
22
|
import { CLTVMultisigTapscript, ConditionCSVMultisigTapscript, ConditionMultisigTapscript, CSVMultisigTapscript, decodeTapscript, MultisigTapscript, TapscriptType, ArkTapscript, RelativeTimelock } from "./script/tapscript";
|
|
22
|
-
import { hasBoardingTxExpired, buildOffchainTx, ArkTxInput, OffchainTx } from "./utils/arkTransaction";
|
|
23
|
+
import { hasBoardingTxExpired, buildOffchainTx, verifyTapscriptSignatures, ArkTxInput, OffchainTx } from "./utils/arkTransaction";
|
|
23
24
|
import { VtxoTaprootTree, ConditionWitness, getArkPsbtFields, setArkPsbtField, ArkPsbtFieldCoder, ArkPsbtFieldKey, ArkPsbtFieldKeyType, CosignerPublicKey, VtxoTreeExpiry } from "./utils/unknownFields";
|
|
24
|
-
import {
|
|
25
|
+
import { Intent } from "./intent";
|
|
25
26
|
import { ArkNote } from "./arknote";
|
|
26
27
|
import { networks, Network, NetworkName } from "./networks";
|
|
27
28
|
import { RestIndexerProvider, IndexerProvider, IndexerTxType, ChainTxType, PageResponse, Batch, ChainTx, CommitmentTx, TxHistoryRecord, VtxoChain, Tx, Vtxo, PaginationOptions, SubscriptionResponse, SubscriptionHeartbeat, SubscriptionEvent } from "./providers/indexer";
|
|
@@ -31,5 +32,5 @@ import { AnchorBumper, P2A } from "./utils/anchor";
|
|
|
31
32
|
import { Unroll } from "./wallet/unroll";
|
|
32
33
|
import { WalletRepositoryImpl } from "./repositories/walletRepository";
|
|
33
34
|
import { ContractRepositoryImpl } from "./repositories/contractRepository";
|
|
34
|
-
export { Wallet, SingleKey, OnchainWallet, Ramps, ESPLORA_URL, EsploraProvider, RestArkProvider, RestIndexerProvider, ArkAddress, DefaultVtxo, VtxoScript, VHTLC, TxType, IndexerTxType, ChainTxType, SettlementEventType, setupServiceWorker, Worker, ServiceWorkerWallet, Request, Response, decodeTapscript, MultisigTapscript, CSVMultisigTapscript, ConditionCSVMultisigTapscript, ConditionMultisigTapscript, CLTVMultisigTapscript, ArkPsbtFieldKey, ArkPsbtFieldKeyType, setArkPsbtField, getArkPsbtFields, CosignerPublicKey, VtxoTreeExpiry, VtxoTaprootTree, ConditionWitness, buildOffchainTx, waitForIncomingFunds, hasBoardingTxExpired, ArkNote, networks, WalletRepositoryImpl, ContractRepositoryImpl,
|
|
35
|
-
export type { Identity, IWallet, WalletConfig, ProviderClass, ArkTransaction, Coin, ExtendedCoin, ExtendedVirtualCoin, WalletBalance, SendBitcoinParams, Recipient, SettleParams, Status, VirtualStatus, Outpoint, VirtualCoin, TxKey, TapscriptType, ArkTxInput, OffchainTx, TapLeaves, IncomingFunds, IndexerProvider, PageResponse, Batch, ChainTx, CommitmentTx, TxHistoryRecord, Vtxo, VtxoChain, Tx, OnchainProvider, ArkProvider, SettlementEvent, ArkInfo,
|
|
35
|
+
export { Wallet, SingleKey, OnchainWallet, Ramps, VtxoManager, ESPLORA_URL, EsploraProvider, RestArkProvider, RestIndexerProvider, ArkAddress, DefaultVtxo, VtxoScript, VHTLC, TxType, IndexerTxType, ChainTxType, SettlementEventType, setupServiceWorker, Worker, ServiceWorkerWallet, Request, Response, decodeTapscript, MultisigTapscript, CSVMultisigTapscript, ConditionCSVMultisigTapscript, ConditionMultisigTapscript, CLTVMultisigTapscript, ArkPsbtFieldKey, ArkPsbtFieldKeyType, setArkPsbtField, getArkPsbtFields, CosignerPublicKey, VtxoTreeExpiry, VtxoTaprootTree, ConditionWitness, buildOffchainTx, verifyTapscriptSignatures, waitForIncomingFunds, hasBoardingTxExpired, ArkNote, networks, WalletRepositoryImpl, ContractRepositoryImpl, Intent, TxTree, P2A, Unroll, Transaction, };
|
|
36
|
+
export type { Identity, IWallet, WalletConfig, ProviderClass, ArkTransaction, Coin, ExtendedCoin, ExtendedVirtualCoin, WalletBalance, SendBitcoinParams, Recipient, SettleParams, Status, VirtualStatus, Outpoint, VirtualCoin, TxKey, TapscriptType, ArkTxInput, OffchainTx, TapLeaves, IncomingFunds, IndexerProvider, PageResponse, Batch, ChainTx, CommitmentTx, TxHistoryRecord, Vtxo, VtxoChain, Tx, OnchainProvider, ArkProvider, SettlementEvent, ArkInfo, SignedIntent, Output, TxNotification, ExplorerTransaction, BatchFinalizationEvent, BatchFinalizedEvent, BatchFailedEvent, TreeSigningStartedEvent, TreeNoncesAggregatedEvent, BatchStartedEvent, TreeTxEvent, TreeSignatureEvent, ScheduledSession, PaginationOptions, SubscriptionResponse, SubscriptionHeartbeat, SubscriptionEvent, Network, NetworkName, ArkTapscript, RelativeTimelock, EncodedVtxoScript, TapLeafScript, SignerSession, TreeNonces, TreePartialSigs, GetVtxosFilter, Nonces, PartialSig, ArkPsbtFieldCoder, TxTreeNode, AnchorBumper, };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Transaction } from "@scure/btc-signer";
|
|
2
|
+
import { TransactionInput, TransactionOutput } from "@scure/btc-signer/psbt.js";
|
|
3
|
+
/**
|
|
4
|
+
* Intent proof implementation for Bitcoin message signing.
|
|
5
|
+
*
|
|
6
|
+
* Intent proof defines a standard for signing Bitcoin messages as well as proving
|
|
7
|
+
* ownership of coins. This namespace provides utilities for creating and
|
|
8
|
+
* validating Intent proof.
|
|
9
|
+
*
|
|
10
|
+
* it is greatly inspired by BIP322.
|
|
11
|
+
* @see https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* // Create a Intent proof
|
|
16
|
+
* const proof = Intent.create(
|
|
17
|
+
* "Hello Bitcoin!",
|
|
18
|
+
* [input],
|
|
19
|
+
* [output]
|
|
20
|
+
* );
|
|
21
|
+
*
|
|
22
|
+
* // Sign the proof
|
|
23
|
+
* const signedProof = await identity.sign(proof);
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
export declare namespace Intent {
|
|
27
|
+
type Proof = Transaction;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new Intent proof unsigned transaction.
|
|
30
|
+
*
|
|
31
|
+
* This function constructs a special transaction that can be signed to prove
|
|
32
|
+
* ownership of VTXOs and UTXOs. The proof includes the message to be
|
|
33
|
+
* signed and the inputs/outputs that demonstrate ownership.
|
|
34
|
+
*
|
|
35
|
+
* @param message - The Intent message to be signed
|
|
36
|
+
* @param inputs - Array of transaction inputs to prove ownership of
|
|
37
|
+
* @param outputs - Optional array of transaction outputs
|
|
38
|
+
* @returns An unsigned Intent proof transaction
|
|
39
|
+
*/
|
|
40
|
+
function create(message: string, inputs: TransactionInput[], outputs?: TransactionOutput[]): Proof;
|
|
41
|
+
}
|
|
@@ -63,31 +63,56 @@ export type TreeSignatureEvent = {
|
|
|
63
63
|
signature: string;
|
|
64
64
|
};
|
|
65
65
|
export type SettlementEvent = BatchFinalizationEvent | BatchFinalizedEvent | BatchFailedEvent | TreeSigningStartedEvent | TreeNoncesAggregatedEvent | BatchStartedEvent | TreeTxEvent | TreeSignatureEvent;
|
|
66
|
-
export interface
|
|
67
|
-
|
|
66
|
+
export interface ScheduledSession {
|
|
67
|
+
duration: bigint;
|
|
68
|
+
fees: FeeInfo;
|
|
68
69
|
nextEndTime: bigint;
|
|
70
|
+
nextStartTime: bigint;
|
|
69
71
|
period: bigint;
|
|
70
|
-
roundInterval: bigint;
|
|
71
72
|
}
|
|
73
|
+
export interface IntentFeeInfo {
|
|
74
|
+
offchainInput: string;
|
|
75
|
+
offchainOutput: string;
|
|
76
|
+
onchainInput: string;
|
|
77
|
+
onchainOutput: string;
|
|
78
|
+
}
|
|
79
|
+
export interface FeeInfo {
|
|
80
|
+
intentFee: IntentFeeInfo;
|
|
81
|
+
txFeeRate: string;
|
|
82
|
+
}
|
|
83
|
+
export interface PendingTx {
|
|
84
|
+
arkTxid: string;
|
|
85
|
+
finalArkTx: string;
|
|
86
|
+
signedCheckpointTxs: string[];
|
|
87
|
+
}
|
|
88
|
+
export interface DeprecatedSigner {
|
|
89
|
+
cutoffDate: bigint;
|
|
90
|
+
pubkey: string;
|
|
91
|
+
}
|
|
92
|
+
export type ServiceStatus = Record<string, string>;
|
|
72
93
|
export interface ArkInfo {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
network: string;
|
|
94
|
+
boardingExitDelay: bigint;
|
|
95
|
+
checkpointTapscript: string;
|
|
96
|
+
deprecatedSigners: DeprecatedSigner[];
|
|
97
|
+
digest: string;
|
|
78
98
|
dust: bigint;
|
|
99
|
+
fees: FeeInfo;
|
|
79
100
|
forfeitAddress: string;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
101
|
+
forfeitPubkey: string;
|
|
102
|
+
network: string;
|
|
103
|
+
scheduledSession: ScheduledSession;
|
|
104
|
+
serviceStatus: ServiceStatus;
|
|
105
|
+
sessionDuration: bigint;
|
|
106
|
+
signerPubkey: string;
|
|
107
|
+
unilateralExitDelay: bigint;
|
|
83
108
|
utxoMaxAmount: bigint;
|
|
84
|
-
|
|
109
|
+
utxoMinAmount: bigint;
|
|
110
|
+
version: string;
|
|
85
111
|
vtxoMaxAmount: bigint;
|
|
86
|
-
|
|
87
|
-
checkpointExitClosure: string;
|
|
112
|
+
vtxoMinAmount: bigint;
|
|
88
113
|
}
|
|
89
|
-
export interface
|
|
90
|
-
|
|
114
|
+
export interface SignedIntent {
|
|
115
|
+
proof: string;
|
|
91
116
|
message: string;
|
|
92
117
|
}
|
|
93
118
|
export interface TxNotification {
|
|
@@ -108,8 +133,8 @@ export interface ArkProvider {
|
|
|
108
133
|
signedCheckpointTxs: string[];
|
|
109
134
|
}>;
|
|
110
135
|
finalizeTx(arkTxid: string, finalCheckpointTxs: string[]): Promise<void>;
|
|
111
|
-
registerIntent(intent:
|
|
112
|
-
deleteIntent(intent:
|
|
136
|
+
registerIntent(intent: SignedIntent): Promise<string>;
|
|
137
|
+
deleteIntent(intent: SignedIntent): Promise<void>;
|
|
113
138
|
confirmRegistration(intentId: string): Promise<void>;
|
|
114
139
|
submitTreeNonces(batchId: string, pubkey: string, nonces: TreeNonces): Promise<void>;
|
|
115
140
|
submitTreeSignatures(batchId: string, pubkey: string, signatures: TreePartialSigs): Promise<void>;
|
|
@@ -119,6 +144,7 @@ export interface ArkProvider {
|
|
|
119
144
|
commitmentTx?: TxNotification;
|
|
120
145
|
arkTx?: TxNotification;
|
|
121
146
|
}>;
|
|
147
|
+
getPendingTxs(intent: SignedIntent): Promise<PendingTx[]>;
|
|
122
148
|
}
|
|
123
149
|
/**
|
|
124
150
|
* REST-based Ark provider implementation.
|
|
@@ -139,8 +165,8 @@ export declare class RestArkProvider implements ArkProvider {
|
|
|
139
165
|
signedCheckpointTxs: string[];
|
|
140
166
|
}>;
|
|
141
167
|
finalizeTx(arkTxid: string, finalCheckpointTxs: string[]): Promise<void>;
|
|
142
|
-
registerIntent(intent:
|
|
143
|
-
deleteIntent(intent:
|
|
168
|
+
registerIntent(intent: SignedIntent): Promise<string>;
|
|
169
|
+
deleteIntent(intent: SignedIntent): Promise<void>;
|
|
144
170
|
confirmRegistration(intentId: string): Promise<void>;
|
|
145
171
|
submitTreeNonces(batchId: string, pubkey: string, nonces: TreeNonces): Promise<void>;
|
|
146
172
|
submitTreeSignatures(batchId: string, pubkey: string, signatures: TreePartialSigs): Promise<void>;
|
|
@@ -150,6 +176,7 @@ export declare class RestArkProvider implements ArkProvider {
|
|
|
150
176
|
commitmentTx?: TxNotification;
|
|
151
177
|
arkTx?: TxNotification;
|
|
152
178
|
}>;
|
|
179
|
+
getPendingTxs(intent: SignedIntent): Promise<PendingTx[]>;
|
|
153
180
|
protected parseSettlementEvent(data: ProtoTypes.GetEventStreamResponse): SettlementEvent | null;
|
|
154
181
|
protected parseTransactionNotification(data: ProtoTypes.GetTransactionsStreamResponse): {
|
|
155
182
|
commitmentTx?: TxNotification;
|
|
@@ -181,7 +208,13 @@ declare namespace ProtoTypes {
|
|
|
181
208
|
}
|
|
182
209
|
interface TreeNoncesAggregatedEvent {
|
|
183
210
|
id: string;
|
|
184
|
-
treeNonces: string
|
|
211
|
+
treeNonces: Record<string, string>;
|
|
212
|
+
}
|
|
213
|
+
interface TreeNoncesEvent {
|
|
214
|
+
id: string;
|
|
215
|
+
topic: string[];
|
|
216
|
+
txid: string;
|
|
217
|
+
nonces: Record<string, string>;
|
|
185
218
|
}
|
|
186
219
|
interface TreeTxEvent {
|
|
187
220
|
id: string;
|
|
@@ -225,6 +258,7 @@ declare namespace ProtoTypes {
|
|
|
225
258
|
batchFinalized?: BatchFinalizedEvent;
|
|
226
259
|
treeSigningStarted?: TreeSigningStartedEvent;
|
|
227
260
|
treeNoncesAggregated?: TreeNoncesAggregatedEvent;
|
|
261
|
+
treeNonces?: TreeNoncesEvent;
|
|
228
262
|
treeTx?: TreeTxEvent;
|
|
229
263
|
treeSignature?: TreeSignatureEvent;
|
|
230
264
|
heartbeat?: Heartbeat;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RestIndexerProvider } from "./indexer";
|
|
1
|
+
import { RestIndexerProvider, SubscriptionResponse } from "./indexer";
|
|
2
2
|
/**
|
|
3
3
|
* Expo-compatible Indexer provider implementation using expo/fetch for streaming support.
|
|
4
4
|
* This provider works specifically in React Native/Expo environments where
|
|
@@ -14,13 +14,5 @@ import { RestIndexerProvider } from "./indexer";
|
|
|
14
14
|
*/
|
|
15
15
|
export declare class ExpoIndexerProvider extends RestIndexerProvider {
|
|
16
16
|
constructor(serverUrl: string);
|
|
17
|
-
getSubscription(subscriptionId: string, abortSignal: AbortSignal):
|
|
18
|
-
txid: any;
|
|
19
|
-
scripts: any;
|
|
20
|
-
newVtxos: any;
|
|
21
|
-
spentVtxos: any;
|
|
22
|
-
sweptVtxos: any;
|
|
23
|
-
tx: any;
|
|
24
|
-
checkpointTxs: any;
|
|
25
|
-
}, void, unknown>;
|
|
17
|
+
getSubscription(subscriptionId: string, abortSignal: AbortSignal): AsyncIterableIterator<SubscriptionResponse>;
|
|
26
18
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dynamically imports expo/fetch with fallback to standard fetch.
|
|
3
|
+
* @returns A fetch function suitable for SSE streaming
|
|
4
|
+
*/
|
|
5
|
+
export declare function getExpoFetch(options?: {
|
|
6
|
+
requireExpo?: boolean;
|
|
7
|
+
}): Promise<typeof fetch>;
|
|
8
|
+
/**
|
|
9
|
+
* Generic SSE stream processor using fetch API with ReadableStream.
|
|
10
|
+
* Handles SSE format parsing, buffer management, and abort signals.
|
|
11
|
+
*
|
|
12
|
+
* @param url - The SSE endpoint URL
|
|
13
|
+
* @param abortSignal - Signal to abort the stream
|
|
14
|
+
* @param fetchFn - Fetch function to use (defaults to standard fetch)
|
|
15
|
+
* @param headers - Additional headers to send
|
|
16
|
+
* @param parseData - Function to parse and yield data from SSE events
|
|
17
|
+
*/
|
|
18
|
+
export declare function sseStreamIterator<T>(url: string, abortSignal: AbortSignal, fetchFn: typeof fetch, headers: Record<string, string>, parseData: (data: any) => T | null): AsyncGenerator<T, void, unknown>;
|
|
@@ -165,15 +165,7 @@ export declare class RestIndexerProvider implements IndexerProvider {
|
|
|
165
165
|
txids: string[];
|
|
166
166
|
page?: PageResponse;
|
|
167
167
|
}>;
|
|
168
|
-
getSubscription(subscriptionId: string, abortSignal: AbortSignal):
|
|
169
|
-
txid: any;
|
|
170
|
-
scripts: any;
|
|
171
|
-
newVtxos: any;
|
|
172
|
-
spentVtxos: any;
|
|
173
|
-
sweptVtxos: any;
|
|
174
|
-
tx: any;
|
|
175
|
-
checkpointTxs: any;
|
|
176
|
-
}, void, unknown>;
|
|
168
|
+
getSubscription(subscriptionId: string, abortSignal: AbortSignal): AsyncIterableIterator<SubscriptionResponse>;
|
|
177
169
|
getVirtualTxs(txids: string[], opts?: PaginationOptions): Promise<{
|
|
178
170
|
txs: string[];
|
|
179
171
|
page?: PageResponse;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NETWORK } from "@scure/btc-signer";
|
|
2
|
+
import { Bytes } from "@scure/btc-signer/utils.js";
|
|
2
3
|
import { ArkAddress } from "./address";
|
|
3
4
|
import { ConditionCSVMultisigTapscript, CSVMultisigTapscript } from "./tapscript";
|
|
4
5
|
export type TapLeafScript = [
|
|
@@ -27,7 +28,7 @@ export declare class VtxoScript {
|
|
|
27
28
|
encode(): Bytes;
|
|
28
29
|
address(prefix: string, serverPubKey: Bytes): ArkAddress;
|
|
29
30
|
get pkScript(): Bytes;
|
|
30
|
-
onchainAddress(network:
|
|
31
|
+
onchainAddress(network: typeof NETWORK): string;
|
|
31
32
|
findLeaf(scriptHex: string): TapLeafScript;
|
|
32
33
|
exitPaths(): Array<CSVMultisigTapscript.Type | ConditionCSVMultisigTapscript.Type>;
|
|
33
34
|
}
|
|
@@ -5,11 +5,11 @@ export declare const ErrMissingAggregateKey: Error;
|
|
|
5
5
|
export type TreeNonces = Map<string, Pick<musig2.Nonces, "pubNonce">>;
|
|
6
6
|
export type TreePartialSigs = Map<string, musig2.PartialSig>;
|
|
7
7
|
export interface SignerSession {
|
|
8
|
-
getPublicKey(): Uint8Array
|
|
9
|
-
init(tree: TxTree, scriptRoot: Uint8Array, rootInputAmount: bigint): void
|
|
10
|
-
getNonces(): TreeNonces
|
|
11
|
-
setAggregatedNonces(nonces: TreeNonces): void
|
|
12
|
-
sign(): TreePartialSigs
|
|
8
|
+
getPublicKey(): Promise<Uint8Array>;
|
|
9
|
+
init(tree: TxTree, scriptRoot: Uint8Array, rootInputAmount: bigint): Promise<void>;
|
|
10
|
+
getNonces(): Promise<TreeNonces>;
|
|
11
|
+
setAggregatedNonces(nonces: TreeNonces): Promise<void>;
|
|
12
|
+
sign(): Promise<TreePartialSigs>;
|
|
13
13
|
}
|
|
14
14
|
export declare class TreeSignerSession implements SignerSession {
|
|
15
15
|
private secretKey;
|
|
@@ -21,11 +21,11 @@ export declare class TreeSignerSession implements SignerSession {
|
|
|
21
21
|
private rootSharedOutputAmount;
|
|
22
22
|
constructor(secretKey: Uint8Array);
|
|
23
23
|
static random(): TreeSignerSession;
|
|
24
|
-
init(tree: TxTree, scriptRoot: Uint8Array, rootInputAmount: bigint): void
|
|
25
|
-
getPublicKey(): Uint8Array
|
|
26
|
-
getNonces(): TreeNonces
|
|
27
|
-
setAggregatedNonces(nonces: TreeNonces): void
|
|
28
|
-
sign(): TreePartialSigs
|
|
24
|
+
init(tree: TxTree, scriptRoot: Uint8Array, rootInputAmount: bigint): Promise<void>;
|
|
25
|
+
getPublicKey(): Promise<Uint8Array>;
|
|
26
|
+
getNonces(): Promise<TreeNonces>;
|
|
27
|
+
setAggregatedNonces(nonces: TreeNonces): Promise<void>;
|
|
28
|
+
sign(): Promise<TreePartialSigs>;
|
|
29
29
|
private generateNonces;
|
|
30
30
|
private signPartial;
|
|
31
31
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Transaction } from "@scure/btc-signer
|
|
2
|
-
import { TransactionInputUpdate } from "@scure/btc-signer/psbt";
|
|
1
|
+
import { Transaction } from "@scure/btc-signer";
|
|
2
|
+
import { TransactionInputUpdate } from "@scure/btc-signer/psbt.js";
|
|
3
3
|
export declare const ANCHOR_VALUE = 0n;
|
|
4
4
|
export declare const ANCHOR_PKSCRIPT: Uint8Array<ArrayBuffer>;
|
|
5
5
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Transaction } from "@scure/btc-signer
|
|
1
|
+
import { Transaction } from "@scure/btc-signer";
|
|
2
|
+
import { Bytes } from "@scure/btc-signer/utils.js";
|
|
3
|
+
import { TransactionOutput } from "@scure/btc-signer/psbt.js";
|
|
2
4
|
import { ExtendedCoin, VirtualCoin } from "../wallet";
|
|
3
5
|
import { RelativeTimelock } from "../script/tapscript";
|
|
4
6
|
import { EncodedVtxoScript, TapLeafScript } from "../script/base";
|
|
5
7
|
import { CSVMultisigTapscript } from "../script/tapscript";
|
|
6
|
-
import { TransactionOutput } from "@scure/btc-signer/psbt.js";
|
|
7
|
-
import { Bytes } from "@scure/btc-signer/utils.js";
|
|
8
8
|
export type ArkTxInput = {
|
|
9
9
|
tapLeafScript: TapLeafScript;
|
|
10
10
|
checkpointTapLeafScript?: Bytes;
|
|
@@ -27,3 +27,13 @@ export type OffchainTx = {
|
|
|
27
27
|
*/
|
|
28
28
|
export declare function buildOffchainTx(inputs: ArkTxInput[], outputs: TransactionOutput[], serverUnrollScript: CSVMultisigTapscript.Type): OffchainTx;
|
|
29
29
|
export declare function hasBoardingTxExpired(coin: ExtendedCoin, boardingTimelock: RelativeTimelock): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Verify tapscript signatures on a transaction input
|
|
32
|
+
* @param tx Transaction to verify
|
|
33
|
+
* @param inputIndex Index of the input to verify
|
|
34
|
+
* @param requiredSigners List of required signer pubkeys (hex encoded)
|
|
35
|
+
* @param excludePubkeys List of pubkeys to exclude from verification (hex encoded, e.g., server key not yet signed)
|
|
36
|
+
* @param allowedSighashTypes List of allowed sighash types (defaults to [SigHash.DEFAULT])
|
|
37
|
+
* @throws Error if verification fails
|
|
38
|
+
*/
|
|
39
|
+
export declare function verifyTapscriptSignatures(tx: Transaction, inputIndex: number, requiredSigners: string[], excludePubkeys?: string[], allowedSighashTypes?: number[]): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Transaction } from "@scure/btc-signer
|
|
2
|
-
import { TransactionInputUpdate } from "@scure/btc-signer/psbt";
|
|
1
|
+
import { Transaction } from "@scure/btc-signer";
|
|
2
|
+
import { TransactionInputUpdate } from "@scure/btc-signer/psbt.js";
|
|
3
3
|
/**
|
|
4
4
|
* ArkPsbtFieldKey is the key values for ark psbt fields.
|
|
5
5
|
*/
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { OnchainProvider } from "../providers/onchain";
|
|
1
|
+
import { Bytes } from "@scure/btc-signer/utils.js";
|
|
2
|
+
import { ArkProvider, Output, SettlementEvent } from "../providers/ark";
|
|
4
3
|
import { Identity } from "../identity";
|
|
5
4
|
import { RelativeTimelock } from "../script/tapscript";
|
|
6
5
|
import { EncodedVtxoScript, TapLeafScript } from "../script/base";
|
|
7
|
-
import { Bytes } from "@scure/btc-signer/utils.js";
|
|
8
6
|
import { StorageAdapter } from "../storage";
|
|
7
|
+
import { RenewalConfig } from "./vtxo-manager";
|
|
8
|
+
import { IndexerProvider } from "../providers/indexer";
|
|
9
|
+
import { OnchainProvider } from "../providers/onchain";
|
|
9
10
|
/**
|
|
10
11
|
* Configuration options for wallet initialization.
|
|
11
12
|
*
|
|
@@ -50,6 +51,7 @@ export interface WalletConfig {
|
|
|
50
51
|
arkProvider?: ArkProvider;
|
|
51
52
|
indexerProvider?: IndexerProvider;
|
|
52
53
|
onchainProvider?: OnchainProvider;
|
|
54
|
+
renewalConfig?: RenewalConfig;
|
|
53
55
|
}
|
|
54
56
|
/**
|
|
55
57
|
* Provider class constructor interface for dependency injection.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { Transaction } from "@scure/btc-signer";
|
|
1
2
|
import { P2TR } from "@scure/btc-signer/payment.js";
|
|
2
3
|
import { Coin, SendBitcoinParams } from ".";
|
|
3
4
|
import { Identity } from "../identity";
|
|
4
5
|
import { Network, NetworkName } from "../networks";
|
|
5
6
|
import { OnchainProvider } from "../providers/onchain";
|
|
6
|
-
import { Transaction } from "@scure/btc-signer/transaction.js";
|
|
7
7
|
import { AnchorBumper } from "../utils/anchor";
|
|
8
8
|
/**
|
|
9
9
|
* Onchain Bitcoin wallet implementation for traditional Bitcoin transactions.
|
|
@@ -2,7 +2,6 @@ import { IWallet, WalletBalance, SendBitcoinParams, SettleParams, ArkTransaction
|
|
|
2
2
|
import { Response } from "./response";
|
|
3
3
|
import { SettlementEvent } from "../../providers/ark";
|
|
4
4
|
import { Identity } from "../../identity";
|
|
5
|
-
import { StorageAdapter } from "../../storage";
|
|
6
5
|
import { WalletRepository } from "../../repositories/walletRepository";
|
|
7
6
|
import { ContractRepository } from "../../repositories/contractRepository";
|
|
8
7
|
export type PrivateKeyIdentity = Identity & {
|
|
@@ -44,8 +43,9 @@ interface ServiceWorkerWalletOptions {
|
|
|
44
43
|
arkServerPublicKey?: string;
|
|
45
44
|
arkServerUrl: string;
|
|
46
45
|
esploraUrl?: string;
|
|
46
|
+
dbName?: string;
|
|
47
|
+
dbVersion?: number;
|
|
47
48
|
identity: PrivateKeyIdentity;
|
|
48
|
-
storage?: StorageAdapter;
|
|
49
49
|
}
|
|
50
50
|
export type ServiceWorkerWalletCreateOptions = ServiceWorkerWalletOptions & {
|
|
51
51
|
serviceWorker: ServiceWorker;
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* it aims to be run in a service worker context
|
|
4
4
|
*/
|
|
5
5
|
export declare class Worker {
|
|
6
|
+
readonly dbName: string;
|
|
7
|
+
readonly dbVersion: number;
|
|
6
8
|
private readonly messageCallback;
|
|
7
9
|
private wallet;
|
|
8
10
|
private arkProvider;
|
|
@@ -10,7 +12,7 @@ export declare class Worker {
|
|
|
10
12
|
private incomingFundsSubscription;
|
|
11
13
|
private walletRepository;
|
|
12
14
|
private storage;
|
|
13
|
-
constructor(messageCallback?: (message: ExtendableMessageEvent) => void);
|
|
15
|
+
constructor(dbName?: string, dbVersion?: number, messageCallback?: (message: ExtendableMessageEvent) => void);
|
|
14
16
|
/**
|
|
15
17
|
* Get spendable vtxos for the current wallet address
|
|
16
18
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Transaction } from "@scure/btc-signer
|
|
1
|
+
import { Transaction } from "@scure/btc-signer";
|
|
2
2
|
import { ChainTx, IndexerProvider } from "../providers/indexer";
|
|
3
3
|
import { AnchorBumper } from "../utils/anchor";
|
|
4
4
|
import { OnchainProvider } from "../providers/onchain";
|