beignet 0.2.0 → 0.4.0
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 +306 -1
- package/dist/cli/auth.js +238 -0
- package/dist/cli/auth.js.map +1 -0
- package/dist/cli/beignet-node.js +1034 -57
- package/dist/cli/beignet-node.js.map +1 -1
- package/dist/cli/cli.js +1257 -18
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/config.js +45 -1
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/daemon.js +398 -38
- package/dist/cli/daemon.js.map +1 -1
- package/dist/cli/errors.js +2 -0
- package/dist/cli/errors.js.map +1 -1
- package/dist/cli/index.js +6 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/openapi.js +1343 -89
- package/dist/cli/openapi.js.map +1 -1
- package/dist/cli/restore.js +89 -0
- package/dist/cli/restore.js.map +1 -0
- package/dist/cli/wallet-storage.js +34 -0
- package/dist/cli/wallet-storage.js.map +1 -0
- package/dist/electrum/index.js +107 -12
- package/dist/electrum/index.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lightning/advisor/fee-tuner.js +42 -0
- package/dist/lightning/advisor/fee-tuner.js.map +1 -0
- package/dist/lightning/advisor/index.js +9 -1
- package/dist/lightning/advisor/index.js.map +1 -1
- package/dist/lightning/advisor/rebalance-planner.js +55 -0
- package/dist/lightning/advisor/rebalance-planner.js.map +1 -0
- package/dist/lightning/backup/index.js +18 -0
- package/dist/lightning/backup/index.js.map +1 -0
- package/dist/lightning/backup/scb.js +42 -0
- package/dist/lightning/backup/scb.js.map +1 -0
- package/dist/lightning/chain/chain-monitor.js +27 -0
- package/dist/lightning/chain/chain-monitor.js.map +1 -1
- package/dist/lightning/chain/output-resolver.js +66 -15
- package/dist/lightning/chain/output-resolver.js.map +1 -1
- package/dist/lightning/chain/types.js +1 -0
- package/dist/lightning/chain/types.js.map +1 -1
- package/dist/lightning/channel/channel-manager.js +91 -24
- package/dist/lightning/channel/channel-manager.js.map +1 -1
- package/dist/lightning/channel/channel-state.js.map +1 -1
- package/dist/lightning/channel/channel.js +122 -4
- package/dist/lightning/channel/channel.js.map +1 -1
- package/dist/lightning/channel/commitment-builder.js +4 -7
- package/dist/lightning/channel/commitment-builder.js.map +1 -1
- package/dist/lightning/channel/dual-funding.js +6 -5
- package/dist/lightning/channel/dual-funding.js.map +1 -1
- package/dist/lightning/channel/splice-tx.js.map +1 -1
- package/dist/lightning/channel/types.js +3 -1
- package/dist/lightning/channel/types.js.map +1 -1
- package/dist/lightning/channel/validation.js +3 -3
- package/dist/lightning/channel/validation.js.map +1 -1
- package/dist/lightning/crypto/index.js +1 -0
- package/dist/lightning/crypto/index.js.map +1 -1
- package/dist/lightning/crypto/message-signing.js +116 -0
- package/dist/lightning/crypto/message-signing.js.map +1 -0
- package/dist/lightning/crypto/xchacha20poly1305.js +77 -0
- package/dist/lightning/crypto/xchacha20poly1305.js.map +1 -0
- package/dist/lightning/features/flags.js +1 -0
- package/dist/lightning/features/flags.js.map +1 -1
- package/dist/lightning/gossip/messages.js +37 -1
- package/dist/lightning/gossip/messages.js.map +1 -1
- package/dist/lightning/index.js +2 -1
- package/dist/lightning/index.js.map +1 -1
- package/dist/lightning/keys/signer.js +24 -3
- package/dist/lightning/keys/signer.js.map +1 -1
- package/dist/lightning/keys/wallet-keys.js +1 -0
- package/dist/lightning/keys/wallet-keys.js.map +1 -1
- package/dist/lightning/message/index.js +1 -0
- package/dist/lightning/message/index.js.map +1 -1
- package/dist/lightning/message/peer-storage.js +43 -0
- package/dist/lightning/message/peer-storage.js.map +1 -0
- package/dist/lightning/message/types.js +2 -0
- package/dist/lightning/message/types.js.map +1 -1
- package/dist/lightning/node/lightning-node.js +1593 -236
- package/dist/lightning/node/lightning-node.js.map +1 -1
- package/dist/lightning/node/types.js +18 -1
- package/dist/lightning/node/types.js.map +1 -1
- package/dist/lightning/offer/offer-manager.js +2 -5
- package/dist/lightning/offer/offer-manager.js.map +1 -1
- package/dist/lightning/offer/tlv.js +3 -1
- package/dist/lightning/offer/tlv.js.map +1 -1
- package/dist/lightning/storage/encryption.js +67 -0
- package/dist/lightning/storage/encryption.js.map +1 -0
- package/dist/lightning/storage/index.js +1 -0
- package/dist/lightning/storage/index.js.map +1 -1
- package/dist/lightning/storage/serialization.js +6 -2
- package/dist/lightning/storage/serialization.js.map +1 -1
- package/dist/lightning/storage/sqlite-storage.js +405 -33
- package/dist/lightning/storage/sqlite-storage.js.map +1 -1
- package/dist/lightning/watchtower/blob.js +221 -0
- package/dist/lightning/watchtower/blob.js.map +1 -0
- package/dist/lightning/watchtower/index.js +55 -0
- package/dist/lightning/watchtower/index.js.map +1 -0
- package/dist/lightning/watchtower/justice.js +272 -0
- package/dist/lightning/watchtower/justice.js.map +1 -0
- package/dist/lightning/watchtower/tower-connection.js +208 -0
- package/dist/lightning/watchtower/tower-connection.js.map +1 -0
- package/dist/lightning/watchtower/types.js +3 -0
- package/dist/lightning/watchtower/types.js.map +1 -0
- package/dist/lightning/watchtower/watchtower-client.js +472 -0
- package/dist/lightning/watchtower/watchtower-client.js.map +1 -0
- package/dist/lightning/watchtower/wtwire.js +201 -0
- package/dist/lightning/watchtower/wtwire.js.map +1 -0
- package/dist/logger.js +41 -0
- package/dist/logger.js.map +1 -0
- package/dist/shapes/electrum.js +32 -1
- package/dist/shapes/electrum.js.map +1 -1
- package/dist/shapes/wallet.js +11 -1
- package/dist/shapes/wallet.js.map +1 -1
- package/dist/transaction/index.js +163 -15
- package/dist/transaction/index.js.map +1 -1
- package/dist/types/cli/auth.d.ts +34 -0
- package/dist/types/cli/beignet-node.d.ts +148 -4
- package/dist/types/cli/daemon.d.ts +5 -0
- package/dist/types/cli/errors.d.ts +2 -0
- package/dist/types/cli/index.d.ts +1 -0
- package/dist/types/cli/restore.d.ts +10 -0
- package/dist/types/cli/types.d.ts +235 -1
- package/dist/types/cli/wallet-storage.d.ts +3 -0
- package/dist/types/electrum/index.d.ts +12 -0
- package/dist/types/electrum.js +1 -0
- package/dist/types/electrum.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/lightning/advisor/fee-tuner.d.ts +20 -0
- package/dist/types/lightning/advisor/index.d.ts +4 -0
- package/dist/types/lightning/advisor/rebalance-planner.d.ts +12 -0
- package/dist/types/lightning/backup/index.d.ts +1 -0
- package/dist/types/lightning/backup/scb.d.ts +24 -0
- package/dist/types/lightning/chain/chain-monitor.d.ts +1 -0
- package/dist/types/lightning/chain/types.d.ts +1 -0
- package/dist/types/lightning/channel/channel-manager.d.ts +11 -0
- package/dist/types/lightning/channel/channel-state.d.ts +2 -0
- package/dist/types/lightning/channel/channel.d.ts +11 -5
- package/dist/types/lightning/channel/commitment-builder.d.ts +7 -7
- package/dist/types/lightning/channel/dual-funding.d.ts +2 -1
- package/dist/types/lightning/channel/splice-tx.d.ts +2 -2
- package/dist/types/lightning/channel/types.d.ts +2 -0
- package/dist/types/lightning/channel/validation.d.ts +1 -1
- package/dist/types/lightning/crypto/index.d.ts +1 -0
- package/dist/types/lightning/crypto/message-signing.d.ts +9 -0
- package/dist/types/lightning/crypto/xchacha20poly1305.d.ts +3 -0
- package/dist/types/lightning/features/flags.d.ts +1 -0
- package/dist/types/lightning/gossip/messages.d.ts +4 -0
- package/dist/types/lightning/index.d.ts +1 -0
- package/dist/types/lightning/keys/signer.d.ts +18 -1
- package/dist/types/lightning/keys/wallet-keys.d.ts +2 -1
- package/dist/types/lightning/message/index.d.ts +1 -0
- package/dist/types/lightning/message/peer-storage.d.ts +9 -0
- package/dist/types/lightning/message/types.d.ts +2 -0
- package/dist/types/lightning/node/lightning-node.d.ts +120 -4
- package/dist/types/lightning/node/types.d.ts +66 -1
- package/dist/types/lightning/storage/encryption.d.ts +11 -0
- package/dist/types/lightning/storage/index.d.ts +1 -0
- package/dist/types/lightning/storage/serialization.d.ts +2 -0
- package/dist/types/lightning/storage/sqlite-storage.d.ts +43 -3
- package/dist/types/lightning/storage/types.d.ts +62 -0
- package/dist/types/lightning/watchtower/blob.d.ts +46 -0
- package/dist/types/lightning/watchtower/index.d.ts +9 -0
- package/dist/types/lightning/watchtower/justice.d.ts +30 -0
- package/dist/types/lightning/watchtower/tower-connection.d.ts +34 -0
- package/dist/types/lightning/watchtower/types.d.ts +46 -0
- package/dist/types/lightning/watchtower/watchtower-client.d.ts +68 -0
- package/dist/types/lightning/watchtower/wtwire.d.ts +90 -0
- package/dist/types/logger.d.ts +17 -0
- package/dist/types/shapes/electrum.d.ts +3 -1
- package/dist/types/transaction/index.d.ts +6 -0
- package/dist/types/transaction.js.map +1 -1
- package/dist/types/types/electrum.d.ts +3 -2
- package/dist/types/types/transaction.d.ts +1 -1
- package/dist/types/types/wallet.d.ts +80 -4
- package/dist/types/utils/descriptors.d.ts +2 -0
- package/dist/types/utils/fees.d.ts +3 -0
- package/dist/types/utils/helpers.d.ts +3 -1
- package/dist/types/utils/index.d.ts +5 -0
- package/dist/types/utils/multisig.d.ts +29 -0
- package/dist/types/utils/transaction.d.ts +7 -0
- package/dist/types/utils/wallet-storage-encryption.d.ts +3 -0
- package/dist/types/utils/wallet.d.ts +1 -1
- package/dist/types/utils/watch-only.d.ts +12 -0
- package/dist/types/wallet/constants.d.ts +1 -0
- package/dist/types/wallet/index.d.ts +63 -4
- package/dist/types/wallet.js +3 -0
- package/dist/types/wallet.js.map +1 -1
- package/dist/utils/derivation-path.js +8 -7
- package/dist/utils/derivation-path.js.map +1 -1
- package/dist/utils/descriptors.js +56 -0
- package/dist/utils/descriptors.js.map +1 -0
- package/dist/utils/electrum.js +14 -4
- package/dist/utils/electrum.js.map +1 -1
- package/dist/utils/fees.js +19 -0
- package/dist/utils/fees.js.map +1 -0
- package/dist/utils/helpers.js +22 -5
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/multisig.js +90 -0
- package/dist/utils/multisig.js.map +1 -0
- package/dist/utils/transaction.js +30 -3
- package/dist/utils/transaction.js.map +1 -1
- package/dist/utils/wallet-storage-encryption.js +45 -0
- package/dist/utils/wallet-storage-encryption.js.map +1 -0
- package/dist/utils/wallet.js +3 -1
- package/dist/utils/wallet.js.map +1 -1
- package/dist/utils/watch-only.js +102 -0
- package/dist/utils/watch-only.js.map +1 -0
- package/dist/wallet/constants.js +2 -1
- package/dist/wallet/constants.js.map +1 -1
- package/dist/wallet/index.js +810 -51
- package/dist/wallet/index.js.map +1 -1
- package/docs/ROADMAP.md +365 -0
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import { IChannelState } from '../channel/channel-state';
|
|
|
3
3
|
import { IPaymentInfo } from '../node/types';
|
|
4
4
|
import { IChainMonitorState } from '../chain/chain-monitor';
|
|
5
5
|
import { IGraphChannel, IGraphNode } from '../gossip/types';
|
|
6
|
+
import { IWatchtowerSession, IWatchtowerUpdate } from '../watchtower/types';
|
|
6
7
|
export interface IStorageBackend {
|
|
7
8
|
open(): void;
|
|
8
9
|
close(): void;
|
|
@@ -84,6 +85,8 @@ export interface IStorageBackend {
|
|
|
84
85
|
loadNextChannelIndex(): number;
|
|
85
86
|
saveMetadata(key: string, value: string): void;
|
|
86
87
|
loadMetadata(key: string): string | null;
|
|
88
|
+
saveWalletData?(key: string, value: string): void;
|
|
89
|
+
loadWalletData?(key: string): string | null;
|
|
87
90
|
transaction<T>(fn: () => T): T;
|
|
88
91
|
checkpoint?(): void;
|
|
89
92
|
saveHtlcSharedSecret(key: string, secret: Buffer): void;
|
|
@@ -93,6 +96,23 @@ export interface IStorageBackend {
|
|
|
93
96
|
secret: Buffer;
|
|
94
97
|
}>;
|
|
95
98
|
deleteGossipChannel?(scidHex: string): void;
|
|
99
|
+
saveChannelPolicy?(channelId: string, policy: IPersistedChannelPolicy): void;
|
|
100
|
+
loadAllChannelPolicies?(): Array<{
|
|
101
|
+
channelId: string;
|
|
102
|
+
policy: IPersistedChannelPolicy;
|
|
103
|
+
}>;
|
|
104
|
+
deleteChannelPolicy?(channelId: string): void;
|
|
105
|
+
savePeerStorageBlob?(peerPubkey: string, blob: Buffer, receivedAt: number): void;
|
|
106
|
+
loadPeerStorageBlob?(peerPubkey: string): {
|
|
107
|
+
blob: Buffer;
|
|
108
|
+
receivedAt: number;
|
|
109
|
+
} | null;
|
|
110
|
+
deletePeerStorageBlob?(peerPubkey: string): void;
|
|
111
|
+
saveForwardingEvent?(event: Omit<IForwardingEvent, 'id'>): void;
|
|
112
|
+
listForwardingEvents?(filter?: IForwardingEventFilter): IForwardingEvent[];
|
|
113
|
+
getForwardingSummary?(options?: {
|
|
114
|
+
since?: number;
|
|
115
|
+
}): IForwardingSummary;
|
|
96
116
|
saveActionLog?(entry: {
|
|
97
117
|
category: string;
|
|
98
118
|
action: string;
|
|
@@ -109,6 +129,47 @@ export interface IStorageBackend {
|
|
|
109
129
|
timestamp: number;
|
|
110
130
|
data: string;
|
|
111
131
|
}>;
|
|
132
|
+
saveWatchtowerSession?(session: IWatchtowerSession, sessionKey: Buffer): void;
|
|
133
|
+
loadWatchtowerSessions?(): Array<IWatchtowerSession & {
|
|
134
|
+
sessionKey: Buffer;
|
|
135
|
+
}>;
|
|
136
|
+
setWatchtowerSessionProgress?(sessionId: string, seqNum: number, lastApplied: number): void;
|
|
137
|
+
deleteWatchtowerTower?(towerUri: string): void;
|
|
138
|
+
addWatchtowerUpdate?(update: IWatchtowerUpdate): number;
|
|
139
|
+
loadPendingWatchtowerUpdates?(): Array<IWatchtowerUpdate & {
|
|
140
|
+
id: number;
|
|
141
|
+
}>;
|
|
142
|
+
markWatchtowerUpdateAcked?(id: number, seqNum: number): void;
|
|
143
|
+
}
|
|
144
|
+
export interface IPersistedChannelPolicy {
|
|
145
|
+
feeBaseMsat?: number;
|
|
146
|
+
feeProportionalMillionths?: number;
|
|
147
|
+
cltvExpiryDelta?: number;
|
|
148
|
+
htlcMinimumMsat?: string;
|
|
149
|
+
htlcMaximumMsat?: string;
|
|
150
|
+
}
|
|
151
|
+
export interface IForwardingEvent {
|
|
152
|
+
id: number;
|
|
153
|
+
settledAt: number;
|
|
154
|
+
inChannelId: string;
|
|
155
|
+
outChannelId: string;
|
|
156
|
+
inScid?: string;
|
|
157
|
+
outScid?: string;
|
|
158
|
+
amountInMsat: bigint;
|
|
159
|
+
amountOutMsat: bigint;
|
|
160
|
+
feeMsat: bigint;
|
|
161
|
+
}
|
|
162
|
+
export interface IForwardingEventFilter {
|
|
163
|
+
since?: number;
|
|
164
|
+
until?: number;
|
|
165
|
+
limit?: number;
|
|
166
|
+
offset?: number;
|
|
167
|
+
channelId?: string;
|
|
168
|
+
}
|
|
169
|
+
export interface IForwardingSummary {
|
|
170
|
+
count: number;
|
|
171
|
+
volumeOutMsat: bigint;
|
|
172
|
+
feesEarnedMsat: bigint;
|
|
112
173
|
}
|
|
113
174
|
export interface IInvoiceInfo {
|
|
114
175
|
paymentHash: string;
|
|
@@ -118,4 +179,5 @@ export interface IInvoiceInfo {
|
|
|
118
179
|
expiry: number;
|
|
119
180
|
createdAt: number;
|
|
120
181
|
hold?: boolean;
|
|
182
|
+
cancelledAt?: number;
|
|
121
183
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare enum BlobFlag {
|
|
3
|
+
REWARD = 1,
|
|
4
|
+
COMMIT_OUTPUTS = 2,
|
|
5
|
+
ANCHOR_CHANNEL = 4,
|
|
6
|
+
TAPROOT_CHANNEL = 8
|
|
7
|
+
}
|
|
8
|
+
export declare enum BlobType {
|
|
9
|
+
ALTRUIST_COMMIT = 2,
|
|
10
|
+
ALTRUIST_ANCHOR_COMMIT = 6,
|
|
11
|
+
ALTRUIST_TAPROOT_COMMIT = 10
|
|
12
|
+
}
|
|
13
|
+
export declare const BREACH_HINT_SIZE = 16;
|
|
14
|
+
export declare const NONCE_SIZE = 24;
|
|
15
|
+
export declare const CIPHERTEXT_EXPANSION = 16;
|
|
16
|
+
export declare const MAX_SWEEP_ADDR_SIZE = 42;
|
|
17
|
+
export declare const V0_PLAINTEXT_SIZE = 274;
|
|
18
|
+
export declare const V1_PLAINTEXT_SIZE = 300;
|
|
19
|
+
export declare function breachHintFromTxid(txidInternal: Buffer): Buffer;
|
|
20
|
+
export declare function breachKeyFromTxid(txidInternal: Buffer): Buffer;
|
|
21
|
+
export interface IJusticeKitV0 {
|
|
22
|
+
sweepAddress: Buffer;
|
|
23
|
+
revocationPubKey: Buffer;
|
|
24
|
+
localDelayPubKey: Buffer;
|
|
25
|
+
csvDelay: number;
|
|
26
|
+
commitToLocalSig: Buffer;
|
|
27
|
+
commitToRemotePubKey?: Buffer;
|
|
28
|
+
commitToRemoteSig?: Buffer;
|
|
29
|
+
}
|
|
30
|
+
export declare function encodeJusticeKitV0(kit: IJusticeKitV0): Buffer;
|
|
31
|
+
export declare function decodeJusticeKitV0(pt: Buffer): IJusticeKitV0;
|
|
32
|
+
export interface IJusticeKitV1 {
|
|
33
|
+
sweepAddress: Buffer;
|
|
34
|
+
revocationPubKey: Buffer;
|
|
35
|
+
localDelayPubKey: Buffer;
|
|
36
|
+
commitToLocalSig: Buffer;
|
|
37
|
+
delayScriptHash: Buffer;
|
|
38
|
+
commitToRemotePubKey?: Buffer;
|
|
39
|
+
commitToRemoteSig?: Buffer;
|
|
40
|
+
}
|
|
41
|
+
export declare function encodeJusticeKitV1(kit: IJusticeKitV1): Buffer;
|
|
42
|
+
export declare function decodeJusticeKitV1(pt: Buffer): IJusticeKitV1;
|
|
43
|
+
export declare function encryptJusticeKitV0(kit: IJusticeKitV0, key: Buffer): Buffer;
|
|
44
|
+
export declare function decryptJusticeKitV0(blob: Buffer, key: Buffer): IJusticeKitV0;
|
|
45
|
+
export declare function encryptJusticeKitV1(kit: IJusticeKitV1, key: Buffer): Buffer;
|
|
46
|
+
export declare function decryptJusticeKitV1(blob: Buffer, key: Buffer): IJusticeKitV1;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export * from './types';
|
|
3
|
+
export * from './wtwire';
|
|
4
|
+
export * from './blob';
|
|
5
|
+
export * from './justice';
|
|
6
|
+
export { TowerConnection, parseTowerUri } from './tower-connection';
|
|
7
|
+
export { WatchtowerClient, IWatchtowerClientOptions, IWatchtowerStore } from './watchtower-client';
|
|
8
|
+
import * as bitcoin from 'bitcoinjs-lib';
|
|
9
|
+
export declare function chainHashForNetwork(network: bitcoin.Network): Buffer;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as bitcoin from 'bitcoinjs-lib';
|
|
3
|
+
import { BlobType } from './blob';
|
|
4
|
+
export interface IJusticeContext {
|
|
5
|
+
channelId: string;
|
|
6
|
+
revokedTx: bitcoin.Transaction;
|
|
7
|
+
perCommitmentSecret: Buffer;
|
|
8
|
+
revocationBasepoint: Buffer;
|
|
9
|
+
revocationBasepointSecret: Buffer;
|
|
10
|
+
remoteDelayedBasepoint: Buffer;
|
|
11
|
+
toSelfDelay: number;
|
|
12
|
+
isAnchor: boolean;
|
|
13
|
+
isTaproot?: boolean;
|
|
14
|
+
localPaymentPubkey?: Buffer;
|
|
15
|
+
paymentBasepointSecret?: Buffer;
|
|
16
|
+
sweepScript: Buffer;
|
|
17
|
+
network: bitcoin.Network;
|
|
18
|
+
}
|
|
19
|
+
export interface ISessionPolicy {
|
|
20
|
+
blobType: number;
|
|
21
|
+
sweepFeeRate: bigint;
|
|
22
|
+
}
|
|
23
|
+
export interface IJusticeBackup {
|
|
24
|
+
hint: Buffer;
|
|
25
|
+
encryptedBlob: Buffer;
|
|
26
|
+
revokedTxid: Buffer;
|
|
27
|
+
sweptSats: bigint;
|
|
28
|
+
}
|
|
29
|
+
export declare function buildJusticeBackup(ctx: IJusticeContext, policy: ISessionPolicy): IJusticeBackup;
|
|
30
|
+
export declare function blobTypeForChannel(isAnchor: boolean, isTaproot?: boolean): BlobType;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
4
|
+
import { ITowerAddress, ITowerTransport } from './types';
|
|
5
|
+
export interface ITowerConnectionOptions {
|
|
6
|
+
localPrivateKey: Buffer;
|
|
7
|
+
address: ITowerAddress;
|
|
8
|
+
connectTimeoutMs?: number;
|
|
9
|
+
socks5Proxy?: {
|
|
10
|
+
host: string;
|
|
11
|
+
port: number;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare class TowerConnection extends EventEmitter implements ITowerTransport {
|
|
15
|
+
private readonly localPrivateKey;
|
|
16
|
+
private readonly address;
|
|
17
|
+
private readonly connectTimeoutMs;
|
|
18
|
+
private readonly socks5Proxy?;
|
|
19
|
+
private socket;
|
|
20
|
+
private transport;
|
|
21
|
+
private readBuffer;
|
|
22
|
+
private pendingBodyLength;
|
|
23
|
+
private connected;
|
|
24
|
+
constructor(opts: ITowerConnectionOptions);
|
|
25
|
+
isConnected(): boolean;
|
|
26
|
+
connect(): Promise<void>;
|
|
27
|
+
send(type: number, payload: Buffer): void;
|
|
28
|
+
close(): void;
|
|
29
|
+
private onData;
|
|
30
|
+
private processReadBuffer;
|
|
31
|
+
private openSocket;
|
|
32
|
+
private readExact;
|
|
33
|
+
}
|
|
34
|
+
export declare function parseTowerUri(uri: string): ITowerAddress;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
4
|
+
export interface ITowerAddress {
|
|
5
|
+
pubkey: string;
|
|
6
|
+
host: string;
|
|
7
|
+
port: number;
|
|
8
|
+
uri: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ITowerTransport extends EventEmitter {
|
|
11
|
+
connect(): Promise<void>;
|
|
12
|
+
send(type: number, payload: Buffer): void;
|
|
13
|
+
close(): void;
|
|
14
|
+
isConnected(): boolean;
|
|
15
|
+
}
|
|
16
|
+
export type TowerTransportFactory = (addr: ITowerAddress, transportKey?: Buffer) => ITowerTransport;
|
|
17
|
+
export interface IWatchtowerSession {
|
|
18
|
+
towerUri: string;
|
|
19
|
+
towerPubkey: string;
|
|
20
|
+
sessionId: string;
|
|
21
|
+
blobType: number;
|
|
22
|
+
maxUpdates: number;
|
|
23
|
+
sweepFeeRate: string;
|
|
24
|
+
seqNum: number;
|
|
25
|
+
lastApplied: number;
|
|
26
|
+
createdAt: number;
|
|
27
|
+
dialsWithSessionKey?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface IWatchtowerUpdate {
|
|
30
|
+
towerUri: string;
|
|
31
|
+
channelId: string;
|
|
32
|
+
blobType: number;
|
|
33
|
+
hint: string;
|
|
34
|
+
encryptedBlob: string;
|
|
35
|
+
seqNum: number;
|
|
36
|
+
acked: boolean;
|
|
37
|
+
createdAt: number;
|
|
38
|
+
}
|
|
39
|
+
export interface ITowerHealth {
|
|
40
|
+
uri: string;
|
|
41
|
+
pubkey: string;
|
|
42
|
+
connected: boolean;
|
|
43
|
+
sessions: number;
|
|
44
|
+
pendingBacklog: number;
|
|
45
|
+
lastAck: number | null;
|
|
46
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
4
|
+
import * as bitcoin from 'bitcoinjs-lib';
|
|
5
|
+
import { IJusticeContext } from './justice';
|
|
6
|
+
import { TowerTransportFactory, IWatchtowerSession, IWatchtowerUpdate, ITowerHealth } from './types';
|
|
7
|
+
export interface IWatchtowerStore {
|
|
8
|
+
saveWatchtowerSession(session: IWatchtowerSession, sessionKey: Buffer): void;
|
|
9
|
+
loadWatchtowerSessions(): Array<IWatchtowerSession & {
|
|
10
|
+
sessionKey: Buffer;
|
|
11
|
+
}>;
|
|
12
|
+
setWatchtowerSessionProgress(sessionId: string, seqNum: number, lastApplied: number): void;
|
|
13
|
+
deleteWatchtowerTower(towerUri: string): void;
|
|
14
|
+
addWatchtowerUpdate(update: IWatchtowerUpdate): number;
|
|
15
|
+
loadPendingWatchtowerUpdates(): Array<IWatchtowerUpdate & {
|
|
16
|
+
id: number;
|
|
17
|
+
}>;
|
|
18
|
+
markWatchtowerUpdateAcked(id: number, seqNum: number): void;
|
|
19
|
+
}
|
|
20
|
+
export interface IWatchtowerClientOptions {
|
|
21
|
+
localPrivateKey: Buffer;
|
|
22
|
+
chainHash: Buffer;
|
|
23
|
+
network: bitcoin.Network;
|
|
24
|
+
towers?: string[];
|
|
25
|
+
store?: IWatchtowerStore;
|
|
26
|
+
transportFactory?: TowerTransportFactory;
|
|
27
|
+
socks5Proxy?: {
|
|
28
|
+
host: string;
|
|
29
|
+
port: number;
|
|
30
|
+
};
|
|
31
|
+
maxUpdates?: number;
|
|
32
|
+
sweepFeeRateSatPerKw?: bigint;
|
|
33
|
+
connectTimeoutMs?: number;
|
|
34
|
+
}
|
|
35
|
+
export declare class WatchtowerClient extends EventEmitter {
|
|
36
|
+
private readonly localPrivateKey;
|
|
37
|
+
private readonly chainHash;
|
|
38
|
+
private readonly store?;
|
|
39
|
+
private readonly transportFactory;
|
|
40
|
+
private readonly socks5Proxy?;
|
|
41
|
+
private readonly maxUpdates;
|
|
42
|
+
private readonly sweepFeeRate;
|
|
43
|
+
private readonly connectTimeoutMs;
|
|
44
|
+
private readonly towers;
|
|
45
|
+
private started;
|
|
46
|
+
constructor(opts: IWatchtowerClientOptions);
|
|
47
|
+
get enabled(): boolean;
|
|
48
|
+
start(): Promise<void>;
|
|
49
|
+
stop(): void;
|
|
50
|
+
listTowers(): string[];
|
|
51
|
+
addTower(uri: string): void;
|
|
52
|
+
removeTower(uri: string): void;
|
|
53
|
+
getHealth(): ITowerHealth[];
|
|
54
|
+
backupRevokedState(ctx: IJusticeContext): void;
|
|
55
|
+
private registerTower;
|
|
56
|
+
private ensureSlot;
|
|
57
|
+
private connectSlot;
|
|
58
|
+
private onConnected;
|
|
59
|
+
private onMessage;
|
|
60
|
+
private onClose;
|
|
61
|
+
private ensureSessionAndDrain;
|
|
62
|
+
private negotiateSession;
|
|
63
|
+
private drainSlot;
|
|
64
|
+
private shipUpdate;
|
|
65
|
+
private awaitReply;
|
|
66
|
+
private lastAckFor;
|
|
67
|
+
private emitLog;
|
|
68
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare enum WtMessageType {
|
|
3
|
+
INIT = 600,
|
|
4
|
+
ERROR = 601,
|
|
5
|
+
CREATE_SESSION = 602,
|
|
6
|
+
CREATE_SESSION_REPLY = 603,
|
|
7
|
+
STATE_UPDATE = 604,
|
|
8
|
+
STATE_UPDATE_REPLY = 605,
|
|
9
|
+
DELETE_SESSION = 606,
|
|
10
|
+
DELETE_SESSION_REPLY = 607
|
|
11
|
+
}
|
|
12
|
+
export declare enum WtFeatureBit {
|
|
13
|
+
ALTRUIST_SESSIONS_REQUIRED = 0,
|
|
14
|
+
ALTRUIST_SESSIONS_OPTIONAL = 1,
|
|
15
|
+
ANCHOR_COMMIT_REQUIRED = 2,
|
|
16
|
+
ANCHOR_COMMIT_OPTIONAL = 3,
|
|
17
|
+
TAPROOT_COMMIT_REQUIRED = 4,
|
|
18
|
+
TAPROOT_COMMIT_OPTIONAL = 5
|
|
19
|
+
}
|
|
20
|
+
export declare enum WtErrorCode {
|
|
21
|
+
OK = 0,
|
|
22
|
+
TEMPORARY_FAILURE = 40,
|
|
23
|
+
PERMANENT_FAILURE = 50
|
|
24
|
+
}
|
|
25
|
+
export declare enum CreateSessionCode {
|
|
26
|
+
OK = 0,
|
|
27
|
+
REJECT_ALREADY_EXISTS = 60,
|
|
28
|
+
REJECT_MAX_UPDATES = 61,
|
|
29
|
+
REJECT_REWARD_RATE = 62,
|
|
30
|
+
REJECT_SWEEP_FEE_RATE = 63,
|
|
31
|
+
REJECT_BLOB_TYPE = 64
|
|
32
|
+
}
|
|
33
|
+
export declare enum StateUpdateCode {
|
|
34
|
+
OK = 0,
|
|
35
|
+
CLIENT_BEHIND = 40,
|
|
36
|
+
MAX_UPDATES_EXCEEDED = 41,
|
|
37
|
+
SEQ_NUM_OUT_OF_ORDER = 42
|
|
38
|
+
}
|
|
39
|
+
export interface IWtInit {
|
|
40
|
+
connFeatures: Buffer;
|
|
41
|
+
chainHash: Buffer;
|
|
42
|
+
}
|
|
43
|
+
export interface IWtError {
|
|
44
|
+
code: number;
|
|
45
|
+
data: Buffer;
|
|
46
|
+
}
|
|
47
|
+
export interface IWtCreateSession {
|
|
48
|
+
blobType: number;
|
|
49
|
+
maxUpdates: number;
|
|
50
|
+
rewardBase: number;
|
|
51
|
+
rewardRate: number;
|
|
52
|
+
sweepFeeRate: bigint;
|
|
53
|
+
}
|
|
54
|
+
export interface IWtCreateSessionReply {
|
|
55
|
+
code: number;
|
|
56
|
+
lastApplied: number;
|
|
57
|
+
data: Buffer;
|
|
58
|
+
}
|
|
59
|
+
export interface IWtStateUpdate {
|
|
60
|
+
seqNum: number;
|
|
61
|
+
lastApplied: number;
|
|
62
|
+
isComplete: number;
|
|
63
|
+
hint: Buffer;
|
|
64
|
+
encryptedBlob: Buffer;
|
|
65
|
+
}
|
|
66
|
+
export interface IWtStateUpdateReply {
|
|
67
|
+
code: number;
|
|
68
|
+
lastApplied: number;
|
|
69
|
+
}
|
|
70
|
+
export interface IWtDeleteSession {
|
|
71
|
+
_?: never;
|
|
72
|
+
}
|
|
73
|
+
export interface IWtDeleteSessionReply {
|
|
74
|
+
code: number;
|
|
75
|
+
}
|
|
76
|
+
export declare function encodeInit(msg: IWtInit): Buffer;
|
|
77
|
+
export declare function decodeInit(payload: Buffer): IWtInit;
|
|
78
|
+
export declare function encodeError(msg: IWtError): Buffer;
|
|
79
|
+
export declare function decodeError(payload: Buffer): IWtError;
|
|
80
|
+
export declare function encodeCreateSession(msg: IWtCreateSession): Buffer;
|
|
81
|
+
export declare function decodeCreateSession(payload: Buffer): IWtCreateSession;
|
|
82
|
+
export declare function encodeCreateSessionReply(msg: IWtCreateSessionReply): Buffer;
|
|
83
|
+
export declare function decodeCreateSessionReply(payload: Buffer): IWtCreateSessionReply;
|
|
84
|
+
export declare function encodeStateUpdate(msg: IWtStateUpdate): Buffer;
|
|
85
|
+
export declare function decodeStateUpdate(payload: Buffer): IWtStateUpdate;
|
|
86
|
+
export declare function encodeStateUpdateReply(msg: IWtStateUpdateReply): Buffer;
|
|
87
|
+
export declare function decodeStateUpdateReply(payload: Buffer): IWtStateUpdateReply;
|
|
88
|
+
export declare function encodeDeleteSession(): Buffer;
|
|
89
|
+
export declare function encodeDeleteSessionReply(msg: IWtDeleteSessionReply): Buffer;
|
|
90
|
+
export declare function decodeDeleteSessionReply(payload: Buffer): IWtDeleteSessionReply;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type TLogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
|
|
2
|
+
export interface ILogger {
|
|
3
|
+
debug(message: string, meta?: unknown): void;
|
|
4
|
+
info(message: string, meta?: unknown): void;
|
|
5
|
+
warn(message: string, meta?: unknown): void;
|
|
6
|
+
error(message: string, meta?: unknown): void;
|
|
7
|
+
}
|
|
8
|
+
export declare const LOG_LEVEL_PRIORITY: Record<TLogLevel, number>;
|
|
9
|
+
export declare function shouldLog(level: Exclude<TLogLevel, 'silent'>, threshold: TLogLevel): boolean;
|
|
10
|
+
export interface IConsoleSink {
|
|
11
|
+
debug(message?: unknown, ...optionalParams: unknown[]): void;
|
|
12
|
+
info(message?: unknown, ...optionalParams: unknown[]): void;
|
|
13
|
+
warn(message?: unknown, ...optionalParams: unknown[]): void;
|
|
14
|
+
error(message?: unknown, ...optionalParams: unknown[]): void;
|
|
15
|
+
}
|
|
16
|
+
export declare function createConsoleLogger(level?: TLogLevel, sink?: IConsoleSink): ILogger;
|
|
17
|
+
export declare const noopLogger: ILogger;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { TMessageKeys } from '../types';
|
|
1
|
+
import { EElectrumNetworks, TMessageKeys, TServer } from '../types';
|
|
2
2
|
export declare const onMessageKeys: {
|
|
3
3
|
[K in TMessageKeys]: K;
|
|
4
4
|
};
|
|
5
5
|
export declare const POLLING_INTERVAL: number;
|
|
6
|
+
export declare const ELECTRUM_SERVER_COOLDOWN_MS: number;
|
|
7
|
+
export declare const defaultElectrumPeers: Partial<Record<EElectrumNetworks, TServer[]>>;
|
|
@@ -18,6 +18,7 @@ export declare class Transaction {
|
|
|
18
18
|
}): Promise<Result<ISendTransaction>>;
|
|
19
19
|
resetSendTransaction(): Promise<Result<string>>;
|
|
20
20
|
removeBlackListedUtxos(utxos?: IUtxo[]): IUtxo[];
|
|
21
|
+
private applyMultisigInputWeights;
|
|
21
22
|
getTotalFee: ({ satsPerByte, message, transaction, fundingLightning, coinSelectPreference }: {
|
|
22
23
|
satsPerByte: number;
|
|
23
24
|
message?: string | undefined;
|
|
@@ -52,6 +53,11 @@ export declare class Transaction {
|
|
|
52
53
|
bip32Interface?: BIP32Interface | undefined;
|
|
53
54
|
shuffleTargets?: boolean | undefined;
|
|
54
55
|
}) => Promise<Result<Psbt>>;
|
|
56
|
+
createUnsignedPsbt: ({ transactionData, shuffleOutputs }?: {
|
|
57
|
+
transactionData?: ISendTransaction | undefined;
|
|
58
|
+
shuffleOutputs?: boolean | undefined;
|
|
59
|
+
}) => Promise<Result<Psbt>>;
|
|
60
|
+
private addSignerMetadata;
|
|
55
61
|
addInput: ({ psbt, keyPair, input }: IAddInput) => Promise<Result<string>>;
|
|
56
62
|
addExternalInputs({ inputs, keyPair }: {
|
|
57
63
|
inputs: IUtxo[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/types/transaction.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/types/transaction.ts"],"names":[],"mappings":";;;AA0CA,IAAY,MAMX;AAND,WAAY,MAAM;IACjB,uBAAa,CAAA;IACb,2BAAiB,CAAA;IACjB,uBAAa,CAAA;IACb,2BAAiB,CAAA;IACjB,uBAAa,CAAA;AACd,CAAC,EANW,MAAM,GAAN,cAAM,KAAN,cAAM,QAMjB;AA8BD,IAAY,qBAMX;AAND,WAAY,qBAAqB;IAChC,wCAAe,CAAA;IACf,wCAAe,CAAA;IACf,oDAA2B,CAAA;IAC3B,4DAAmC,CAAA;IACnC,0DAAiC,CAAA;AAClC,CAAC,EANW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAMhC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { EAvailableNetworks, IAddress, IGetAddressBalanceRes, ITransaction, IUtxo } from './wallet';
|
|
2
2
|
export type Net = typeof import('net');
|
|
3
3
|
export type Tls = typeof import('tls');
|
|
4
|
-
export type TElectrumNetworks = 'bitcoin' | 'bitcoinTestnet' | 'bitcoinRegtest';
|
|
4
|
+
export type TElectrumNetworks = 'bitcoin' | 'bitcoinTestnet' | 'bitcoinRegtest' | 'bitcoinSignet';
|
|
5
5
|
export declare enum EElectrumNetworks {
|
|
6
6
|
bitcoin = "bitcoin",
|
|
7
7
|
bitcoinTestnet = "bitcoinTestnet",
|
|
8
|
-
bitcoinRegtest = "bitcoinRegtest"
|
|
8
|
+
bitcoinRegtest = "bitcoinRegtest",
|
|
9
|
+
bitcoinSignet = "bitcoinSignet"
|
|
9
10
|
}
|
|
10
11
|
export type TConnectToElectrumRes = string;
|
|
11
12
|
export interface IElectrumGetAddressBalanceRes extends IGetAddressBalanceRes {
|
|
@@ -3,7 +3,8 @@ import { EElectrumNetworks, IHeader, INewBlock, Net, TServer, TTxResult, Tls } f
|
|
|
3
3
|
import { ECoinSelectPreference, EFeeId, TGapLimitOptions } from './transaction';
|
|
4
4
|
import { ECPairInterface } from 'ecpair';
|
|
5
5
|
import { BIP32Interface } from 'bip32';
|
|
6
|
-
|
|
6
|
+
import { ILogger } from '../logger';
|
|
7
|
+
export type TAvailableNetworks = 'bitcoin' | 'testnet' | 'regtest' | 'signet';
|
|
7
8
|
export type TAddressType = 'p2wpkh' | 'p2sh' | 'p2pkh';
|
|
8
9
|
export type TAddressLabel = 'bech32' | 'segwit' | 'legacy';
|
|
9
10
|
export type TKeyDerivationPurpose = '84' | '49' | '44' | string;
|
|
@@ -21,13 +22,17 @@ export declare enum EAvailableNetworks {
|
|
|
21
22
|
testnet = "testnet",
|
|
22
23
|
bitcoinTestnet = "testnet",
|
|
23
24
|
regtest = "regtest",
|
|
24
|
-
bitcoinRegtest = "regtest"
|
|
25
|
+
bitcoinRegtest = "regtest",
|
|
26
|
+
signet = "signet",
|
|
27
|
+
bitcoinSignet = "signet"
|
|
25
28
|
}
|
|
29
|
+
export type TFeeEstimationSource = 'electrum' | 'http' | 'auto';
|
|
26
30
|
export declare enum EAddressType {
|
|
27
31
|
p2wpkh = "p2wpkh",
|
|
28
32
|
p2sh = "p2sh",
|
|
29
33
|
p2pkh = "p2pkh",
|
|
30
|
-
p2tr = "p2tr"
|
|
34
|
+
p2tr = "p2tr",
|
|
35
|
+
p2wsh = "p2wsh"
|
|
31
36
|
}
|
|
32
37
|
export declare enum EPaymentType {
|
|
33
38
|
sent = "sent",
|
|
@@ -147,17 +152,25 @@ export interface IWalletData {
|
|
|
147
152
|
balance: number;
|
|
148
153
|
selectedFeeId: EFeeId;
|
|
149
154
|
feeEstimates: IOnchainFees;
|
|
155
|
+
addressLabels: TAddressLabels;
|
|
156
|
+
birthdayHeight: number;
|
|
150
157
|
}
|
|
158
|
+
export type TAddressLabels = {
|
|
159
|
+
[address: string]: string;
|
|
160
|
+
};
|
|
151
161
|
export type TWalletDataKeys = keyof IWalletData;
|
|
152
162
|
export type TGetData = <K extends keyof IWalletData>(key: string) => Promise<Result<IWalletData[K]>>;
|
|
153
163
|
export type TSetData = <K extends keyof IWalletData>(key: string, value: IWalletData[K]) => Promise<Result<boolean>>;
|
|
154
164
|
export interface IWallet {
|
|
155
|
-
mnemonic
|
|
165
|
+
mnemonic?: string;
|
|
166
|
+
xpub?: string;
|
|
156
167
|
id?: string;
|
|
157
168
|
name?: string;
|
|
158
169
|
passphrase?: string;
|
|
159
170
|
network?: EAvailableNetworks;
|
|
160
171
|
addressType?: EAddressType;
|
|
172
|
+
account?: number;
|
|
173
|
+
birthdayHeight?: number;
|
|
161
174
|
coinSelectPreference?: ECoinSelectPreference;
|
|
162
175
|
data?: IWalletData;
|
|
163
176
|
storage?: TStorage;
|
|
@@ -174,12 +187,15 @@ export interface IWallet {
|
|
|
174
187
|
customGetScriptHash?: (data: ICustomGetScriptHash) => Promise<string>;
|
|
175
188
|
rbf?: boolean;
|
|
176
189
|
selectedFeeId?: EFeeId;
|
|
190
|
+
feeEstimationSource?: TFeeEstimationSource;
|
|
177
191
|
disableMessages?: boolean;
|
|
178
192
|
disableMessagesOnCreate?: boolean;
|
|
193
|
+
logger?: ILogger;
|
|
179
194
|
addressTypesToMonitor?: EAddressType[];
|
|
180
195
|
gapLimitOptions?: TGapLimitOptions;
|
|
181
196
|
addressLookBehind?: number;
|
|
182
197
|
addressLookAhead?: number;
|
|
198
|
+
multisig?: IMultisigOptions;
|
|
183
199
|
}
|
|
184
200
|
export interface IAddressData {
|
|
185
201
|
path: string;
|
|
@@ -376,6 +392,48 @@ export interface ISend {
|
|
|
376
392
|
txs: ISendTx | ISendTx[];
|
|
377
393
|
satsPerByte?: number;
|
|
378
394
|
}
|
|
395
|
+
export type IWatchOnlyWallet = Omit<IWallet, 'mnemonic' | 'passphrase' | 'xpub'> & {
|
|
396
|
+
xpub: string;
|
|
397
|
+
};
|
|
398
|
+
export interface IMultisigOptions {
|
|
399
|
+
threshold: number;
|
|
400
|
+
cosigners: string[];
|
|
401
|
+
ourXpub?: string;
|
|
402
|
+
}
|
|
403
|
+
export type IMultisigWallet = Omit<IWallet, 'xpub' | 'addressType'> & IMultisigOptions;
|
|
404
|
+
export interface IBuildPsbtArgs {
|
|
405
|
+
txs?: ISendTx[];
|
|
406
|
+
address?: string;
|
|
407
|
+
amount?: number;
|
|
408
|
+
message?: string;
|
|
409
|
+
satsPerByte?: number;
|
|
410
|
+
rbf?: boolean;
|
|
411
|
+
shuffleOutputs?: boolean;
|
|
412
|
+
}
|
|
413
|
+
export interface IBuildPsbtInputSummary {
|
|
414
|
+
tx_hash: string;
|
|
415
|
+
tx_pos: number;
|
|
416
|
+
address: string;
|
|
417
|
+
value: number;
|
|
418
|
+
path: string;
|
|
419
|
+
}
|
|
420
|
+
export interface IBuildPsbtOutputSummary {
|
|
421
|
+
address?: string;
|
|
422
|
+
value: number;
|
|
423
|
+
index: number;
|
|
424
|
+
}
|
|
425
|
+
export interface IBuildPsbtResponse {
|
|
426
|
+
psbtBase64: string;
|
|
427
|
+
fee: number;
|
|
428
|
+
vsizeEstimate: number;
|
|
429
|
+
satsPerByte: number;
|
|
430
|
+
inputs: IBuildPsbtInputSummary[];
|
|
431
|
+
outputs: IBuildPsbtOutputSummary[];
|
|
432
|
+
}
|
|
433
|
+
export interface IImportSignedPsbtResponse {
|
|
434
|
+
txHex: string;
|
|
435
|
+
txid: string;
|
|
436
|
+
}
|
|
379
437
|
export type TAddressIndexInfo = {
|
|
380
438
|
addressIndex: IAddress;
|
|
381
439
|
changeAddressIndex: IAddress;
|
|
@@ -459,4 +517,22 @@ export interface ICanBoostResponse {
|
|
|
459
517
|
rbf: boolean;
|
|
460
518
|
cpfp: boolean;
|
|
461
519
|
}
|
|
520
|
+
export interface IBalanceBreakdown {
|
|
521
|
+
total: number;
|
|
522
|
+
spendable: number;
|
|
523
|
+
frozen: number;
|
|
524
|
+
}
|
|
525
|
+
export interface IExportedDescriptor {
|
|
526
|
+
addressType: EAddressType;
|
|
527
|
+
external: string;
|
|
528
|
+
internal: string;
|
|
529
|
+
}
|
|
530
|
+
export interface IExportDescriptorsResponse {
|
|
531
|
+
fingerprint: string;
|
|
532
|
+
network: EAvailableNetworks;
|
|
533
|
+
account: number;
|
|
534
|
+
birthdayHeight?: number;
|
|
535
|
+
watchOnly: boolean;
|
|
536
|
+
descriptors: IExportedDescriptor[];
|
|
537
|
+
}
|
|
462
538
|
export {};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { EAddressType, EAvailableNetworks, IGetAddressesFromKeyPair, IGetAddressesFromPrivateKey, IKeyDerivationPath } from '../types';
|
|
2
|
+
import { EAddressType, EAvailableNetworks, IGetAddressesFromKeyPair, IGetAddressesFromPrivateKey, IKeyDerivationPath, TAvailableNetworks } from '../types';
|
|
3
3
|
import { Network } from 'bitcoinjs-lib';
|
|
4
4
|
import { Result } from './result';
|
|
5
5
|
import { ECPairInterface } from 'ecpair';
|
|
6
6
|
import { BIP32Interface } from 'bip32';
|
|
7
|
+
export declare const validatePsbtSignature: (pubkey: Buffer, msghash: Buffer, signature: Buffer) => boolean;
|
|
8
|
+
export declare const getBitcoinJsNetwork: (network: EAvailableNetworks | TAvailableNetworks) => Network;
|
|
7
9
|
export declare const getAddressFromScriptPubKey: (scriptPubKey: string, selectedNetwork: EAvailableNetworks) => string;
|
|
8
10
|
export declare const getSha256: (str: string) => string;
|
|
9
11
|
export declare const validateAddress: ({ address, network }: {
|