@breeztech/breez-sdk-spark 0.25.0 → 0.27.0-dev1
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/breez-sdk-spark.tgz +0 -0
- package/bundler/breez_sdk_spark_wasm.d.ts +54 -11
- package/bundler/breez_sdk_spark_wasm.js +1 -1
- package/bundler/breez_sdk_spark_wasm_bg.js +57 -24
- package/bundler/breez_sdk_spark_wasm_bg.wasm +0 -0
- package/bundler/breez_sdk_spark_wasm_bg.wasm.d.ts +6 -5
- package/bundler/storage/index.js +145 -1
- package/deno/breez_sdk_spark_wasm.d.ts +54 -11
- package/deno/breez_sdk_spark_wasm.js +57 -24
- package/deno/breez_sdk_spark_wasm_bg.wasm +0 -0
- package/deno/breez_sdk_spark_wasm_bg.wasm.d.ts +6 -5
- package/nodejs/breez_sdk_spark_wasm.d.ts +54 -11
- package/nodejs/breez_sdk_spark_wasm.js +58 -24
- package/nodejs/breez_sdk_spark_wasm_bg.wasm +0 -0
- package/nodejs/breez_sdk_spark_wasm_bg.wasm.d.ts +6 -5
- package/nodejs/index.mjs +1 -0
- package/nodejs/mysql-storage/index.cjs +67 -1
- package/nodejs/mysql-storage/migrations.cjs +23 -0
- package/nodejs/postgres-storage/index.cjs +67 -1
- package/nodejs/postgres-storage/migrations.cjs +23 -0
- package/nodejs/storage/index.cjs +81 -1
- package/nodejs/storage/migrations.cjs +21 -0
- package/package.json +1 -1
- package/ssr/index.js +5 -0
- package/web/breez_sdk_spark_wasm.d.ts +60 -16
- package/web/breez_sdk_spark_wasm.js +57 -24
- package/web/breez_sdk_spark_wasm_bg.wasm +0 -0
- package/web/breez_sdk_spark_wasm_bg.wasm.d.ts +6 -5
- package/web/storage/index.js +145 -1
package/breez-sdk-spark.tgz
CHANGED
|
Binary file
|
|
@@ -545,7 +545,7 @@ export interface BatchRecipient {
|
|
|
545
545
|
|
|
546
546
|
export interface BatchTotal {
|
|
547
547
|
tokenIdentifier?: string;
|
|
548
|
-
amount:
|
|
548
|
+
amount: string;
|
|
549
549
|
}
|
|
550
550
|
|
|
551
551
|
export interface Bip21Details {
|
|
@@ -705,7 +705,7 @@ export interface ClaimDepositRequest {
|
|
|
705
705
|
}
|
|
706
706
|
|
|
707
707
|
export interface ClaimDepositResponse {
|
|
708
|
-
|
|
708
|
+
outcome: ClaimDepositOutcome;
|
|
709
709
|
}
|
|
710
710
|
|
|
711
711
|
export interface ClaimHtlcPaymentRequest {
|
|
@@ -832,12 +832,17 @@ export interface Credentials {
|
|
|
832
832
|
password: string;
|
|
833
833
|
}
|
|
834
834
|
|
|
835
|
+
export interface CrossChainAcceptedAsset {
|
|
836
|
+
asset: SparkAsset;
|
|
837
|
+
limits?: CrossChainRouteLimits;
|
|
838
|
+
}
|
|
839
|
+
|
|
835
840
|
export interface CrossChainAddressDetails {
|
|
836
841
|
address: string;
|
|
837
842
|
addressFamily: CrossChainAddressFamily;
|
|
838
843
|
contractAddress?: string;
|
|
839
844
|
chainId?: number;
|
|
840
|
-
amount?:
|
|
845
|
+
amount?: string;
|
|
841
846
|
}
|
|
842
847
|
|
|
843
848
|
export interface CrossChainConfig {
|
|
@@ -853,9 +858,17 @@ export interface CrossChainReceiveInfo {
|
|
|
853
858
|
tokenIdentifier?: string;
|
|
854
859
|
serviceFeeAmount: string;
|
|
855
860
|
serviceFeeAsset?: string;
|
|
861
|
+
serviceFeeAssetDecimals?: number;
|
|
856
862
|
expiresAt: number;
|
|
857
863
|
}
|
|
858
864
|
|
|
865
|
+
export interface CrossChainRouteLimits {
|
|
866
|
+
minAmount?: string;
|
|
867
|
+
maxAmount?: string;
|
|
868
|
+
minUsdCents?: number;
|
|
869
|
+
maxUsdCents?: number;
|
|
870
|
+
}
|
|
871
|
+
|
|
859
872
|
export interface CrossChainRoutePair {
|
|
860
873
|
provider: CrossChainProvider;
|
|
861
874
|
chain: string;
|
|
@@ -864,7 +877,7 @@ export interface CrossChainRoutePair {
|
|
|
864
877
|
contractAddress?: string;
|
|
865
878
|
decimals: number;
|
|
866
879
|
exactOutEligible: boolean;
|
|
867
|
-
acceptedAssets:
|
|
880
|
+
acceptedAssets: CrossChainAcceptedAsset[];
|
|
868
881
|
deliveryMethods: DeliveryMethod[];
|
|
869
882
|
}
|
|
870
883
|
|
|
@@ -888,6 +901,7 @@ export interface DepositInfo {
|
|
|
888
901
|
claimError?: DepositClaimError;
|
|
889
902
|
instantClaimStatus?: InstantClaimStatus;
|
|
890
903
|
refundState?: RefundState;
|
|
904
|
+
maxClaimFee?: MaxFee;
|
|
891
905
|
}
|
|
892
906
|
|
|
893
907
|
export interface EcdsaSignatureBytes {
|
|
@@ -968,6 +982,10 @@ export interface ExternalInputParser {
|
|
|
968
982
|
parserUrl: string;
|
|
969
983
|
}
|
|
970
984
|
|
|
985
|
+
export interface ExternalLeafSigningKey {
|
|
986
|
+
derivedFrom: ExternalTreeNodeId;
|
|
987
|
+
}
|
|
988
|
+
|
|
971
989
|
export interface ExternalNewLeafKey {
|
|
972
990
|
nodeId: ExternalTreeNodeId;
|
|
973
991
|
newSigningPublicKey: number[];
|
|
@@ -1114,6 +1132,7 @@ export interface ExternalStartedStaticDepositRefund {
|
|
|
1114
1132
|
export interface ExternalTransferLeafInput {
|
|
1115
1133
|
nodeId: ExternalTreeNodeId;
|
|
1116
1134
|
newLeafId: ExternalTreeNodeId;
|
|
1135
|
+
signingKey: ExternalLeafSigningKey;
|
|
1117
1136
|
}
|
|
1118
1137
|
|
|
1119
1138
|
export interface ExternalTreeNodeId {
|
|
@@ -1486,6 +1505,7 @@ export interface PreparePaymentLinkResponse {
|
|
|
1486
1505
|
asset: string;
|
|
1487
1506
|
serviceFeeAmount: bigint;
|
|
1488
1507
|
serviceFeeAsset?: string;
|
|
1508
|
+
serviceFeeAssetDecimals?: number;
|
|
1489
1509
|
expiresAt: string;
|
|
1490
1510
|
}
|
|
1491
1511
|
|
|
@@ -1831,6 +1851,8 @@ export interface Storage {
|
|
|
1831
1851
|
deleteDeposit: (txid: string, vout: number) => Promise<void>;
|
|
1832
1852
|
listDeposits: () => Promise<DepositInfo[]>;
|
|
1833
1853
|
updateDeposit: (txid: string, vout: number, payload: UpdateDepositPayload) => Promise<void>;
|
|
1854
|
+
listWatchedDepositAddresses: () => Promise<WatchedDepositAddress[]>;
|
|
1855
|
+
updateWatchedDepositAddress: (address: string, payload: UpdateWatchedAddressPayload) => Promise<void>;
|
|
1834
1856
|
setLnurlMetadata: (metadata: SetLnurlMetadataItem[]) => Promise<void>;
|
|
1835
1857
|
getPaymentsByParentIds: (parentPaymentIds: string[]) => Promise<{ [parentId: string]: RelatedPayment[] }>;
|
|
1836
1858
|
listContacts: (request: ListContactsRequest) => Promise<Contact[]>;
|
|
@@ -2025,6 +2047,12 @@ export interface Utxo {
|
|
|
2025
2047
|
status: TxStatus;
|
|
2026
2048
|
}
|
|
2027
2049
|
|
|
2050
|
+
export interface WatchedDepositAddress {
|
|
2051
|
+
address: string;
|
|
2052
|
+
issuedAt: number;
|
|
2053
|
+
seen: boolean;
|
|
2054
|
+
}
|
|
2055
|
+
|
|
2028
2056
|
export interface Webhook {
|
|
2029
2057
|
id: string;
|
|
2030
2058
|
url: string;
|
|
@@ -2051,11 +2079,15 @@ export type BuyBitcoinRequest = { type: "moonpay"; lockedAmountSat?: number; red
|
|
|
2051
2079
|
|
|
2052
2080
|
export type ChainApiType = "esplora" | "mempoolSpace";
|
|
2053
2081
|
|
|
2082
|
+
export type ClaimDeferredReason = { type: "maxFeeExceeded"; requiredFeeSats: number; maxFeeSats: number } | { type: "noEarlyClaimAvailable" } | { type: "providerDeclined"; message: string };
|
|
2083
|
+
|
|
2084
|
+
export type ClaimDepositOutcome = { type: "settled"; payment: Payment } | { type: "submitted" } | { type: "deferred"; reason: ClaimDeferredReason };
|
|
2085
|
+
|
|
2054
2086
|
export type ConversionChain = { type: "spark" } | { type: "lightning" } | { type: "external"; name: string; chainId?: string };
|
|
2055
2087
|
|
|
2056
2088
|
export type ConversionFilter = "ammRefundNeeded" | "orchestraPending" | "boltzPending";
|
|
2057
2089
|
|
|
2058
|
-
export type ConversionInfo = { type: "amm"; poolId: string; conversionId: string; status: ConversionStatus; fee?: string; purpose?: ConversionPurpose; amountAdjustment?: AmountAdjustmentReason; degradation?: SwapDegradation } | { type: "orchestra"; chain: string; chainId?: string; asset?: string; assetContract?: string; recipientAddress: string; assetAmountIn?: string; estimatedOut: string; deliveredAmount?: string; externalTxHash?: string; status: ConversionStatus; feeAmount?: string; serviceFeeAmount?: string; serviceFeeAsset?: string; assetDecimals: number; orderId: string; quoteId: string; readToken?: string } | { type: "boltz"; chain: string; chainId?: string; asset?: string; assetContract?: string; recipientAddress: string; assetAmountIn?: string; estimatedOut: string; deliveredAmount?: string; status: ConversionStatus; feeAmount?: string; serviceFeeAmount?: string; serviceFeeAsset?: string; assetDecimals: number; swapId: string; invoice: string; invoiceAmountSats: number; bridgeRef?: string; maxSlippageBps: number; quoteDegraded?: boolean };
|
|
2090
|
+
export type ConversionInfo = { type: "amm"; poolId: string; conversionId: string; status: ConversionStatus; fee?: string; purpose?: ConversionPurpose; amountAdjustment?: AmountAdjustmentReason; degradation?: SwapDegradation } | { type: "orchestra"; chain: string; chainId?: string; asset?: string; assetContract?: string; recipientAddress: string; assetAmountIn?: string; estimatedOut: string; deliveredAmount?: string; externalTxHash?: string; status: ConversionStatus; feeAmount?: string; serviceFeeAmount?: string; serviceFeeAsset?: string; serviceFeeAssetDecimals?: number; assetDecimals: number; orderId: string; quoteId: string; readToken?: string } | { type: "boltz"; chain: string; chainId?: string; asset?: string; assetContract?: string; recipientAddress: string; assetAmountIn?: string; estimatedOut: string; deliveredAmount?: string; status: ConversionStatus; feeAmount?: string; serviceFeeAmount?: string; serviceFeeAsset?: string; assetDecimals: number; swapId: string; invoice: string; invoiceAmountSats: number; bridgeRef?: string; maxSlippageBps: number; quoteDegraded?: boolean };
|
|
2059
2091
|
|
|
2060
2092
|
export type ConversionProvider = "amm" | "orchestra" | "boltz";
|
|
2061
2093
|
|
|
@@ -2081,7 +2113,7 @@ export type CrossChainRouteFilter = { type: "send"; addressDetails: CrossChainAd
|
|
|
2081
2113
|
|
|
2082
2114
|
export type DeliveryMethod = "spark" | "lightning" | "bitcoin";
|
|
2083
2115
|
|
|
2084
|
-
export type DepositClaimError = { type: "maxDepositClaimFeeExceeded"; tx: string; vout: number; maxFee?: Fee; requiredFeeSats: number; requiredFeeRateSatPerVbyte: number } | { type: "missingUtxo"; tx: string; vout: number } | { type: "generic"; message: string };
|
|
2116
|
+
export type DepositClaimError = { type: "maxDepositClaimFeeExceeded"; tx: string; vout: number; maxFee?: Fee; requiredFeeSats: number; requiredFeeRateSatPerVbyte: number } | { type: "missingUtxo"; tx: string; vout: number } | { type: "depositTooSmall"; tx: string; vout: number } | { type: "generic"; message: string };
|
|
2085
2117
|
|
|
2086
2118
|
export type ExitLeafSelection = { type: "auto" } | { type: "specific"; leafIds: string[] };
|
|
2087
2119
|
|
|
@@ -2103,13 +2135,13 @@ export type FeePolicy = "feesExcluded" | "feesIncluded";
|
|
|
2103
2135
|
|
|
2104
2136
|
export type InputType = ({ type: "bitcoinAddress" } & BitcoinAddressDetails) | ({ type: "bolt11Invoice" } & Bolt11InvoiceDetails) | ({ type: "bolt12Invoice" } & Bolt12InvoiceDetails) | ({ type: "bolt12Offer" } & Bolt12OfferDetails) | ({ type: "lightningAddress" } & LightningAddressDetails) | ({ type: "lnurlPay" } & LnurlPayRequestDetails) | ({ type: "silentPaymentAddress" } & SilentPaymentAddressDetails) | ({ type: "lnurlAuth" } & LnurlAuthRequestDetails) | ({ type: "url" } & string) | ({ type: "bip21" } & Bip21Details) | ({ type: "bolt12InvoiceRequest" } & Bolt12InvoiceRequestDetails) | ({ type: "lnurlWithdraw" } & LnurlWithdrawRequestDetails) | ({ type: "sparkAddress" } & SparkAddressDetails) | ({ type: "sparkInvoice" } & SparkInvoiceDetails) | ({ type: "crossChainAddress" } & CrossChainAddressDetails);
|
|
2105
2137
|
|
|
2106
|
-
export type InstantClaimStatus = { type: "declined"; maxFeeSats?: number; confirmations?: number } | { type: "submitted"; claimId: string };
|
|
2138
|
+
export type InstantClaimStatus = { type: "declined"; maxFeeSats?: number; confirmations?: number } | { type: "submitted"; claimId: string } | { type: "claimed" };
|
|
2107
2139
|
|
|
2108
2140
|
export type LnurlCallbackStatus = { type: "ok" } | { type: "errorStatus"; errorDetails: LnurlErrorDetails };
|
|
2109
2141
|
|
|
2110
2142
|
export type MaxFee = { type: "fixed"; amount: number } | { type: "rate"; satPerVbyte: number } | { type: "networkRecommended"; leewaySatPerVbyte: number };
|
|
2111
2143
|
|
|
2112
|
-
export type Network = "mainnet" | "regtest";
|
|
2144
|
+
export type Network = "mainnet" | "regtest" | "signet";
|
|
2113
2145
|
|
|
2114
2146
|
export type OnchainConfirmationSpeed = "fast" | "medium" | "slow";
|
|
2115
2147
|
|
|
@@ -2141,11 +2173,11 @@ export type ReceivePaymentMethod = { type: "sparkAddress" } | { type: "sparkInvo
|
|
|
2141
2173
|
|
|
2142
2174
|
export type RefundState = { type: "broadcastPending"; lastError?: string } | { type: "broadcast" };
|
|
2143
2175
|
|
|
2144
|
-
export type SdkEvent = { type: "synced" } | { type: "unclaimedDeposits"; unclaimedDeposits: DepositInfo[] } | { type: "claimedDeposits"; claimedDeposits: DepositInfo[] } | { type: "paymentSucceeded"; payment: Payment } | { type: "paymentPending"; payment: Payment } | { type: "paymentFailed"; payment: Payment } | { type: "autoOptimization"; optimizationEvent: AutoOptimizationEvent } | { type: "lightningAddressChanged"; lightningAddress?: LightningAddressInfo } | { type: "newDeposits"; newDeposits: DepositInfo[] } | { type: "unilateralExitStateChanged" };
|
|
2176
|
+
export type SdkEvent = { type: "synced" } | { type: "unclaimedDeposits"; unclaimedDeposits: DepositInfo[] } | { type: "claimedDeposits"; claimedDeposits: DepositInfo[] } | { type: "paymentSucceeded"; payment: Payment } | { type: "paymentPending"; payment: Payment } | { type: "paymentFailed"; payment: Payment } | { type: "paymentMetadataUpdated"; payment: Payment } | { type: "autoOptimization"; optimizationEvent: AutoOptimizationEvent } | { type: "lightningAddressChanged"; lightningAddress?: LightningAddressInfo } | { type: "newDeposits"; newDeposits: DepositInfo[] } | { type: "unilateralExitStateChanged" } | { type: "stableBalanceConversionFailed"; conversion: StableBalanceConversionKind; error: string; retryInSecs?: number };
|
|
2145
2177
|
|
|
2146
2178
|
export type Seed = { type: "mnemonic"; mnemonic: string; passphrase?: string } | ({ type: "entropy" } & number[]);
|
|
2147
2179
|
|
|
2148
|
-
export type SendPaymentMethod = { type: "bitcoinAddress"; address: BitcoinAddressDetails; feeQuote: SendOnchainFeeQuote } | { type: "bolt11Invoice"; invoiceDetails: Bolt11InvoiceDetails; sparkTransferFeeSats?: number; lightningFeeSats: number } | { type: "sparkAddress"; address: string; fee: string; tokenIdentifier?: string } | { type: "sparkInvoice"; sparkInvoiceDetails: SparkInvoiceDetails; fee: string; tokenIdentifier?: string } | { type: "crossChainAddress"; route: CrossChainRoutePair; recipientAddress: string; amountIn: string; assetAmountIn: string; estimatedOut: string; feeAmount: string; serviceFeeAmount: string; serviceFeeAsset?: string; sourceTransferFeeSats: number; feeMode: CrossChainFeeMode; expiresAt: string; providerContext: CrossChainProviderContext };
|
|
2180
|
+
export type SendPaymentMethod = { type: "bitcoinAddress"; address: BitcoinAddressDetails; feeQuote: SendOnchainFeeQuote } | { type: "bolt11Invoice"; invoiceDetails: Bolt11InvoiceDetails; sparkTransferFeeSats?: number; lightningFeeSats: number } | { type: "sparkAddress"; address: string; fee: string; tokenIdentifier?: string } | { type: "sparkInvoice"; sparkInvoiceDetails: SparkInvoiceDetails; fee: string; tokenIdentifier?: string } | { type: "crossChainAddress"; route: CrossChainRoutePair; recipientAddress: string; amountIn: string; assetAmountIn: string; estimatedOut: string; feeAmount: string; serviceFeeAmount: string; serviceFeeAsset?: string; serviceFeeAssetDecimals?: number; sourceTransferFeeSats: number; feeMode: CrossChainFeeMode; expiresAt: string; providerContext: CrossChainProviderContext };
|
|
2149
2181
|
|
|
2150
2182
|
export type SendPaymentOptions = { type: "bitcoinAddress"; confirmationSpeed: OnchainConfirmationSpeed } | { type: "bolt11Invoice"; preferSpark: boolean; completionTimeoutSecs?: number } | { type: "sparkAddress"; htlcOptions?: SparkHtlcOptions };
|
|
2151
2183
|
|
|
@@ -2161,6 +2193,8 @@ export type SparkMasterIdentityPublicKey = { type: "set"; publicKey: string } |
|
|
|
2161
2193
|
|
|
2162
2194
|
export type StableBalanceActiveLabel = { type: "set"; label: string } | { type: "unset" };
|
|
2163
2195
|
|
|
2196
|
+
export type StableBalanceConversionKind = "perReceive" | "autoConvert" | "deactivation";
|
|
2197
|
+
|
|
2164
2198
|
export type StoragePaymentDetailsFilter = { type: "spark"; htlcStatus?: SparkHtlcStatus[]; conversionFilter?: ConversionFilter } | { type: "token"; conversionFilter?: ConversionFilter; txHash?: string; txType?: TokenTransactionType } | { type: "lightning"; htlcStatus?: SparkHtlcStatus[]; conversionFilter?: ConversionFilter };
|
|
2165
2199
|
|
|
2166
2200
|
export type SuccessAction = { type: "aes"; data: AesSuccessActionData } | { type: "message"; data: MessageSuccessActionData } | { type: "url"; data: UrlSuccessActionData };
|
|
@@ -2183,7 +2217,9 @@ export type UnilateralExitVerdict = { type: "valid" } | { type: "done" } | { typ
|
|
|
2183
2217
|
|
|
2184
2218
|
export type UnsignedTransferPackage = { type: "swap"; prepareTransfer: ExternalPrepareTransferRequest; targetAmounts: number[]; amountSat: number; feeSat: number } | { type: "transfer"; prepareTransfer: ExternalPrepareTransferRequest; amountSat: number; feeSat: number; target: TransferTarget } | { type: "token"; prepareTokenTransaction: ExternalPrepareTokenTransactionRequest; tokenContext: number[]; tokenIdentifier: string; amount: string; fee: string; isSwap: boolean } | { type: "tokenBatch"; prepareTokenTransaction: ExternalPrepareTokenTransactionRequest; tokenContext: number[]; totals: BatchTotal[]; isSwap: boolean };
|
|
2185
2219
|
|
|
2186
|
-
export type UpdateDepositPayload = { type: "claimError"; error: DepositClaimError } | { type: "refund"; refundTxid: string; refundTx: string; state: RefundState } | { type: "instantClaim"; status: InstantClaimStatus } | { type: "refundBroadcastState"; refundTxid: string; state: RefundState };
|
|
2220
|
+
export type UpdateDepositPayload = { type: "claimError"; error: DepositClaimError } | { type: "refund"; refundTxid: string; refundTx: string; state: RefundState } | { type: "instantClaim"; status: InstantClaimStatus } | { type: "refundBroadcastState"; refundTxid: string; state: RefundState } | { type: "maxClaimFee"; maxFee?: MaxFee };
|
|
2221
|
+
|
|
2222
|
+
export type UpdateWatchedAddressPayload = { type: "watch"; issuedAt: number } | { type: "seen" } | { type: "unwatch"; issuedAt: number };
|
|
2187
2223
|
|
|
2188
2224
|
export type WebhookEventType = { type: "lightningReceiveFinished" } | { type: "lightningSendFinished" } | { type: "coopExitFinished" } | { type: "staticDepositFinished" } | ({ type: "unknown" } & string);
|
|
2189
2225
|
|
|
@@ -2701,6 +2737,13 @@ export function newRestChainService(url: string, network: Network, api_type: Cha
|
|
|
2701
2737
|
*/
|
|
2702
2738
|
export function newSharedSdkContext(config: WasmSdkContextConfig): Promise<WasmSdkContext>;
|
|
2703
2739
|
|
|
2740
|
+
/**
|
|
2741
|
+
* Reads a `SparkConfig` from JSON, for a deployment that publishes its
|
|
2742
|
+
* operators, service provider and certificates as a file. Set it on
|
|
2743
|
+
* `Config.sparkConfig` to connect a wallet to that deployment.
|
|
2744
|
+
*/
|
|
2745
|
+
export function parseSparkConfig(json: string): SparkConfig;
|
|
2746
|
+
|
|
2704
2747
|
/**
|
|
2705
2748
|
* `PostgreSQL`-backed storage built from `config`.
|
|
2706
2749
|
*/
|
|
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./breez_sdk_spark_wasm_bg.js";
|
|
|
5
5
|
__wbg_set_wasm(wasm);
|
|
6
6
|
wasm.__wbindgen_start();
|
|
7
7
|
export {
|
|
8
|
-
BitcoinChainServiceHandle, BreezSdk, DefaultCpfpSigner, DefaultSessionStore, ExternalBreezSignerHandle, ExternalSigners, ExternalSigningSignerHandle, ExternalSparkSignerHandle, IntoUnderlyingByteSource, IntoUnderlyingSink, IntoUnderlyingSource, PasskeyClient, PasskeyLabels, SdkBuilder, SigningOnlyExternalSigners, TokenIssuer, WasmSdkContext, WasmStorageConfig, connect, connectWithSigner, connectWithSigningOnlySigner, createTurnkeySigner, createTurnkeySigningOnlySigner, defaultConfig, defaultExternalSigners, defaultMysqlStorageConfig, defaultPostgresStorageConfig, defaultServerConfig, defaultSessionStore, defaultStorage, getSparkStatus, initLogging, mysqlStorage, newRestChainService, newSharedSdkContext, postgresStorage, singleKeyCpfpSigner, start, task_worker_entry_point
|
|
8
|
+
BitcoinChainServiceHandle, BreezSdk, DefaultCpfpSigner, DefaultSessionStore, ExternalBreezSignerHandle, ExternalSigners, ExternalSigningSignerHandle, ExternalSparkSignerHandle, IntoUnderlyingByteSource, IntoUnderlyingSink, IntoUnderlyingSource, PasskeyClient, PasskeyLabels, SdkBuilder, SigningOnlyExternalSigners, TokenIssuer, WasmSdkContext, WasmStorageConfig, connect, connectWithSigner, connectWithSigningOnlySigner, createTurnkeySigner, createTurnkeySigningOnlySigner, defaultConfig, defaultExternalSigners, defaultMysqlStorageConfig, defaultPostgresStorageConfig, defaultServerConfig, defaultSessionStore, defaultStorage, getSparkStatus, initLogging, mysqlStorage, newRestChainService, newSharedSdkContext, parseSparkConfig, postgresStorage, singleKeyCpfpSigner, start, task_worker_entry_point
|
|
9
9
|
} from "./breez_sdk_spark_wasm_bg.js";
|
|
@@ -1937,6 +1937,23 @@ export function newSharedSdkContext(config) {
|
|
|
1937
1937
|
return ret;
|
|
1938
1938
|
}
|
|
1939
1939
|
|
|
1940
|
+
/**
|
|
1941
|
+
* Reads a `SparkConfig` from JSON, for a deployment that publishes its
|
|
1942
|
+
* operators, service provider and certificates as a file. Set it on
|
|
1943
|
+
* `Config.sparkConfig` to connect a wallet to that deployment.
|
|
1944
|
+
* @param {string} json
|
|
1945
|
+
* @returns {SparkConfig}
|
|
1946
|
+
*/
|
|
1947
|
+
export function parseSparkConfig(json) {
|
|
1948
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1949
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1950
|
+
const ret = wasm.parseSparkConfig(ptr0, len0);
|
|
1951
|
+
if (ret[2]) {
|
|
1952
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1953
|
+
}
|
|
1954
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1955
|
+
}
|
|
1956
|
+
|
|
1940
1957
|
/**
|
|
1941
1958
|
* `PostgreSQL`-backed storage built from `config`.
|
|
1942
1959
|
* @param {PostgresStorageConfig} config
|
|
@@ -2891,6 +2908,10 @@ export function __wbg_listTokensOutputs_3fecc3251ae7b71c() { return handleError(
|
|
|
2891
2908
|
const ret = arg0.listTokensOutputs();
|
|
2892
2909
|
return ret;
|
|
2893
2910
|
}, arguments); }
|
|
2911
|
+
export function __wbg_listWatchedDepositAddresses_55fe8af0643e3ea9() { return handleError(function (arg0) {
|
|
2912
|
+
const ret = arg0.listWatchedDepositAddresses();
|
|
2913
|
+
return ret;
|
|
2914
|
+
}, arguments); }
|
|
2894
2915
|
export function __wbg_log_cf86719f8acabfda(arg0, arg1) {
|
|
2895
2916
|
arg0.log(arg1);
|
|
2896
2917
|
}
|
|
@@ -3590,6 +3611,18 @@ export function __wbg_updateTokenOutputs_d978e01c817e8230() { return handleError
|
|
|
3590
3611
|
const ret = arg0.updateTokenOutputs(arg1, arg2);
|
|
3591
3612
|
return ret;
|
|
3592
3613
|
}, arguments); }
|
|
3614
|
+
export function __wbg_updateWatchedDepositAddress_260322f77dee1443() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
3615
|
+
let deferred0_0;
|
|
3616
|
+
let deferred0_1;
|
|
3617
|
+
try {
|
|
3618
|
+
deferred0_0 = arg1;
|
|
3619
|
+
deferred0_1 = arg2;
|
|
3620
|
+
const ret = arg0.updateWatchedDepositAddress(getStringFromWasm0(arg1, arg2), arg3);
|
|
3621
|
+
return ret;
|
|
3622
|
+
} finally {
|
|
3623
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
3624
|
+
}
|
|
3625
|
+
}, arguments); }
|
|
3593
3626
|
export function __wbg_url_68fd9a221360e0db(arg0, arg1) {
|
|
3594
3627
|
const ret = arg1.url;
|
|
3595
3628
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -3625,47 +3658,47 @@ export function __wbg_wasmsdkcontext_new(arg0) {
|
|
|
3625
3658
|
return ret;
|
|
3626
3659
|
}
|
|
3627
3660
|
export function __wbindgen_cast_0000000000000001(arg0, arg1) {
|
|
3628
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
3629
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
3661
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 21, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
3662
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h0a7e586e9273e375);
|
|
3630
3663
|
return ret;
|
|
3631
3664
|
}
|
|
3632
3665
|
export function __wbindgen_cast_0000000000000002(arg0, arg1) {
|
|
3633
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
3666
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 384, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3634
3667
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h3b28fbbc8b451a25);
|
|
3635
3668
|
return ret;
|
|
3636
3669
|
}
|
|
3637
3670
|
export function __wbindgen_cast_0000000000000003(arg0, arg1) {
|
|
3638
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("CloseEvent")], shim_idx:
|
|
3671
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("CloseEvent")], shim_idx: 384, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3639
3672
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h3b28fbbc8b451a25_2);
|
|
3640
3673
|
return ret;
|
|
3641
3674
|
}
|
|
3642
3675
|
export function __wbindgen_cast_0000000000000004(arg0, arg1) {
|
|
3643
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx:
|
|
3676
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 384, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3644
3677
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h3b28fbbc8b451a25_3);
|
|
3645
3678
|
return ret;
|
|
3646
3679
|
}
|
|
3647
3680
|
export function __wbindgen_cast_0000000000000005(arg0, arg1) {
|
|
3648
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("SessionStore")], shim_idx:
|
|
3649
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
3681
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("SessionStore")], shim_idx: 21, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
3682
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h0a7e586e9273e375_4);
|
|
3650
3683
|
return ret;
|
|
3651
3684
|
}
|
|
3652
3685
|
export function __wbindgen_cast_0000000000000006(arg0, arg1) {
|
|
3653
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Storage")], shim_idx:
|
|
3654
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
3686
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Storage")], shim_idx: 21, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
3687
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h0a7e586e9273e375_5);
|
|
3655
3688
|
return ret;
|
|
3656
3689
|
}
|
|
3657
3690
|
export function __wbindgen_cast_0000000000000007(arg0, arg1) {
|
|
3658
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("TokenStore")], shim_idx:
|
|
3659
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
3691
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("TokenStore")], shim_idx: 21, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
3692
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h0a7e586e9273e375_6);
|
|
3660
3693
|
return ret;
|
|
3661
3694
|
}
|
|
3662
3695
|
export function __wbindgen_cast_0000000000000008(arg0, arg1) {
|
|
3663
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("TreeStore")], shim_idx:
|
|
3664
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
3696
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("TreeStore")], shim_idx: 21, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
3697
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h0a7e586e9273e375_7);
|
|
3665
3698
|
return ret;
|
|
3666
3699
|
}
|
|
3667
3700
|
export function __wbindgen_cast_0000000000000009(arg0, arg1) {
|
|
3668
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx:
|
|
3701
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 388, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3669
3702
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h484cd36e13f37bd7);
|
|
3670
3703
|
return ret;
|
|
3671
3704
|
}
|
|
@@ -3766,36 +3799,36 @@ function wasm_bindgen__convert__closures_____invoke__h3b28fbbc8b451a25_3(arg0, a
|
|
|
3766
3799
|
wasm.wasm_bindgen__convert__closures_____invoke__h3b28fbbc8b451a25_3(arg0, arg1, arg2);
|
|
3767
3800
|
}
|
|
3768
3801
|
|
|
3769
|
-
function
|
|
3770
|
-
const ret = wasm.
|
|
3802
|
+
function wasm_bindgen__convert__closures_____invoke__h0a7e586e9273e375(arg0, arg1, arg2) {
|
|
3803
|
+
const ret = wasm.wasm_bindgen__convert__closures_____invoke__h0a7e586e9273e375(arg0, arg1, arg2);
|
|
3771
3804
|
if (ret[1]) {
|
|
3772
3805
|
throw takeFromExternrefTable0(ret[0]);
|
|
3773
3806
|
}
|
|
3774
3807
|
}
|
|
3775
3808
|
|
|
3776
|
-
function
|
|
3777
|
-
const ret = wasm.
|
|
3809
|
+
function wasm_bindgen__convert__closures_____invoke__h0a7e586e9273e375_4(arg0, arg1, arg2) {
|
|
3810
|
+
const ret = wasm.wasm_bindgen__convert__closures_____invoke__h0a7e586e9273e375_4(arg0, arg1, arg2);
|
|
3778
3811
|
if (ret[1]) {
|
|
3779
3812
|
throw takeFromExternrefTable0(ret[0]);
|
|
3780
3813
|
}
|
|
3781
3814
|
}
|
|
3782
3815
|
|
|
3783
|
-
function
|
|
3784
|
-
const ret = wasm.
|
|
3816
|
+
function wasm_bindgen__convert__closures_____invoke__h0a7e586e9273e375_5(arg0, arg1, arg2) {
|
|
3817
|
+
const ret = wasm.wasm_bindgen__convert__closures_____invoke__h0a7e586e9273e375_5(arg0, arg1, arg2);
|
|
3785
3818
|
if (ret[1]) {
|
|
3786
3819
|
throw takeFromExternrefTable0(ret[0]);
|
|
3787
3820
|
}
|
|
3788
3821
|
}
|
|
3789
3822
|
|
|
3790
|
-
function
|
|
3791
|
-
const ret = wasm.
|
|
3823
|
+
function wasm_bindgen__convert__closures_____invoke__h0a7e586e9273e375_6(arg0, arg1, arg2) {
|
|
3824
|
+
const ret = wasm.wasm_bindgen__convert__closures_____invoke__h0a7e586e9273e375_6(arg0, arg1, arg2);
|
|
3792
3825
|
if (ret[1]) {
|
|
3793
3826
|
throw takeFromExternrefTable0(ret[0]);
|
|
3794
3827
|
}
|
|
3795
3828
|
}
|
|
3796
3829
|
|
|
3797
|
-
function
|
|
3798
|
-
const ret = wasm.
|
|
3830
|
+
function wasm_bindgen__convert__closures_____invoke__h0a7e586e9273e375_7(arg0, arg1, arg2) {
|
|
3831
|
+
const ret = wasm.wasm_bindgen__convert__closures_____invoke__h0a7e586e9273e375_7(arg0, arg1, arg2);
|
|
3799
3832
|
if (ret[1]) {
|
|
3800
3833
|
throw takeFromExternrefTable0(ret[0]);
|
|
3801
3834
|
}
|
|
Binary file
|
|
@@ -128,6 +128,7 @@ export const initLogging: (a: any, b: number, c: number) => any;
|
|
|
128
128
|
export const mysqlStorage: (a: any) => number;
|
|
129
129
|
export const newRestChainService: (a: number, b: number, c: any, d: any, e: number) => any;
|
|
130
130
|
export const newSharedSdkContext: (a: any) => any;
|
|
131
|
+
export const parseSparkConfig: (a: number, b: number) => [number, number, number];
|
|
131
132
|
export const passkeyclient_checkAvailability: (a: number) => any;
|
|
132
133
|
export const passkeyclient_connectWithPasskey: (a: number, b: any) => any;
|
|
133
134
|
export const passkeyclient_labels: (a: number) => number;
|
|
@@ -189,11 +190,11 @@ export const __wbg_externalsparksignerhandle_free: (a: number, b: number) => voi
|
|
|
189
190
|
export const __wbg_signingonlyexternalsigners_free: (a: number, b: number) => void;
|
|
190
191
|
export const signingonlyexternalsigners_breezSigner: (a: number) => number;
|
|
191
192
|
export const signingonlyexternalsigners_sparkSigner: (a: number) => number;
|
|
192
|
-
export const
|
|
193
|
-
export const
|
|
194
|
-
export const
|
|
195
|
-
export const
|
|
196
|
-
export const
|
|
193
|
+
export const wasm_bindgen__convert__closures_____invoke__h0a7e586e9273e375: (a: number, b: number, c: any) => [number, number];
|
|
194
|
+
export const wasm_bindgen__convert__closures_____invoke__h0a7e586e9273e375_4: (a: number, b: number, c: any) => [number, number];
|
|
195
|
+
export const wasm_bindgen__convert__closures_____invoke__h0a7e586e9273e375_5: (a: number, b: number, c: any) => [number, number];
|
|
196
|
+
export const wasm_bindgen__convert__closures_____invoke__h0a7e586e9273e375_6: (a: number, b: number, c: any) => [number, number];
|
|
197
|
+
export const wasm_bindgen__convert__closures_____invoke__h0a7e586e9273e375_7: (a: number, b: number, c: any) => [number, number];
|
|
197
198
|
export const wasm_bindgen__convert__closures_____invoke__h41057d61edf43a32: (a: number, b: number, c: any, d: any) => void;
|
|
198
199
|
export const wasm_bindgen__convert__closures_____invoke__h3b28fbbc8b451a25: (a: number, b: number, c: any) => void;
|
|
199
200
|
export const wasm_bindgen__convert__closures_____invoke__h3b28fbbc8b451a25_2: (a: number, b: number, c: any) => void;
|
package/bundler/storage/index.js
CHANGED
|
@@ -611,6 +611,19 @@ class MigrationManager {
|
|
|
611
611
|
};
|
|
612
612
|
},
|
|
613
613
|
},
|
|
614
|
+
{
|
|
615
|
+
// Deposit addresses polled on-chain for deposits still in the mempool.
|
|
616
|
+
// Entries are removed once watching them can no longer lead to an early
|
|
617
|
+
// claim, so the store holds only the live watch set.
|
|
618
|
+
name: "Create watched_deposit_addresses store",
|
|
619
|
+
upgrade: (db) => {
|
|
620
|
+
if (!db.objectStoreNames.contains("watched_deposit_addresses")) {
|
|
621
|
+
db.createObjectStore("watched_deposit_addresses", {
|
|
622
|
+
keyPath: "address",
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
},
|
|
626
|
+
},
|
|
614
627
|
];
|
|
615
628
|
}
|
|
616
629
|
}
|
|
@@ -639,7 +652,7 @@ class IndexedDBStorage {
|
|
|
639
652
|
// so existing databases depend on indices never shifting. Never insert,
|
|
640
653
|
// reorder, or delete a migration — only append. dbVersion MUST equal the
|
|
641
654
|
// number of migrations (enforced by the guard in initialize()).
|
|
642
|
-
this.dbVersion =
|
|
655
|
+
this.dbVersion = 22; // Current schema version (= migration count)
|
|
643
656
|
}
|
|
644
657
|
|
|
645
658
|
/**
|
|
@@ -1445,6 +1458,7 @@ class IndexedDBStorage {
|
|
|
1445
1458
|
refundTxId: existing?.refundTxId ?? null,
|
|
1446
1459
|
instantClaimStatus: existing?.instantClaimStatus ?? null,
|
|
1447
1460
|
refundState: existing?.refundState ?? null,
|
|
1461
|
+
maxClaimFee: existing?.maxClaimFee ?? null,
|
|
1448
1462
|
};
|
|
1449
1463
|
|
|
1450
1464
|
const putRequest = store.put(depositToStore);
|
|
@@ -1521,6 +1535,7 @@ class IndexedDBStorage {
|
|
|
1521
1535
|
? JSON.parse(row.instantClaimStatus)
|
|
1522
1536
|
: null,
|
|
1523
1537
|
refundState: row.refundState ? JSON.parse(row.refundState) : null,
|
|
1538
|
+
maxClaimFee: row.maxClaimFee ? JSON.parse(row.maxClaimFee) : null,
|
|
1524
1539
|
}));
|
|
1525
1540
|
resolve(deposits);
|
|
1526
1541
|
};
|
|
@@ -1576,6 +1591,10 @@ class IndexedDBStorage {
|
|
|
1576
1591
|
if (existingDeposit.refundTxId === payload.refundTxid) {
|
|
1577
1592
|
updatedDeposit.refundState = JSON.stringify(payload.state);
|
|
1578
1593
|
}
|
|
1594
|
+
} else if (payload.type === "maxClaimFee") {
|
|
1595
|
+
updatedDeposit.maxClaimFee = payload.maxFee
|
|
1596
|
+
? JSON.stringify(payload.maxFee)
|
|
1597
|
+
: null;
|
|
1579
1598
|
} else {
|
|
1580
1599
|
reject(new StorageError(`Unknown payload type: ${payload.type}`));
|
|
1581
1600
|
return;
|
|
@@ -1606,6 +1625,131 @@ class IndexedDBStorage {
|
|
|
1606
1625
|
});
|
|
1607
1626
|
}
|
|
1608
1627
|
|
|
1628
|
+
async listWatchedDepositAddresses() {
|
|
1629
|
+
if (!this.db) {
|
|
1630
|
+
throw new StorageError("Database not initialized");
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
return new Promise((resolve, reject) => {
|
|
1634
|
+
const transaction = this.db.transaction(
|
|
1635
|
+
"watched_deposit_addresses",
|
|
1636
|
+
"readonly"
|
|
1637
|
+
);
|
|
1638
|
+
const store = transaction.objectStore("watched_deposit_addresses");
|
|
1639
|
+
const request = store.getAll();
|
|
1640
|
+
|
|
1641
|
+
request.onsuccess = () => {
|
|
1642
|
+
const watched = (request.result || []).map((entry) => ({
|
|
1643
|
+
address: entry.address,
|
|
1644
|
+
issuedAt: entry.issuedAt,
|
|
1645
|
+
seen: Boolean(entry.seen),
|
|
1646
|
+
}));
|
|
1647
|
+
// The store is keyed by address, so ordering is applied here rather
|
|
1648
|
+
// than by an index.
|
|
1649
|
+
watched.sort((a, b) => Number(b.issuedAt) - Number(a.issuedAt));
|
|
1650
|
+
resolve(watched);
|
|
1651
|
+
};
|
|
1652
|
+
request.onerror = () =>
|
|
1653
|
+
reject(
|
|
1654
|
+
new StorageError(
|
|
1655
|
+
`Failed to list watched deposit addresses: ${request.error}`
|
|
1656
|
+
)
|
|
1657
|
+
);
|
|
1658
|
+
});
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
async updateWatchedDepositAddress(address, payload) {
|
|
1662
|
+
if (!this.db) {
|
|
1663
|
+
throw new StorageError("Database not initialized");
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
return new Promise((resolve, reject) => {
|
|
1667
|
+
const transaction = this.db.transaction(
|
|
1668
|
+
"watched_deposit_addresses",
|
|
1669
|
+
"readwrite"
|
|
1670
|
+
);
|
|
1671
|
+
const store = transaction.objectStore("watched_deposit_addresses");
|
|
1672
|
+
|
|
1673
|
+
if (payload.type === "watch") {
|
|
1674
|
+
const request = store.put({
|
|
1675
|
+
address,
|
|
1676
|
+
issuedAt: payload.issuedAt,
|
|
1677
|
+
seen: false,
|
|
1678
|
+
});
|
|
1679
|
+
request.onsuccess = () => resolve();
|
|
1680
|
+
request.onerror = () =>
|
|
1681
|
+
reject(
|
|
1682
|
+
new StorageError(
|
|
1683
|
+
`Failed to watch deposit address '${address}': ${request.error}`
|
|
1684
|
+
)
|
|
1685
|
+
);
|
|
1686
|
+
return;
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
if (payload.type === "unwatch") {
|
|
1690
|
+
// Conditional on issuedAt, so an address handed out again since the
|
|
1691
|
+
// caller read it is not retired by a decision taken before that. The
|
|
1692
|
+
// get and the delete share one readwrite transaction, so nothing can
|
|
1693
|
+
// interleave between them.
|
|
1694
|
+
const getRequest = store.get(address);
|
|
1695
|
+
getRequest.onsuccess = () => {
|
|
1696
|
+
const existing = getRequest.result;
|
|
1697
|
+
const stale =
|
|
1698
|
+
!existing || String(existing.issuedAt) !== String(payload.issuedAt);
|
|
1699
|
+
if (stale) {
|
|
1700
|
+
resolve();
|
|
1701
|
+
return;
|
|
1702
|
+
}
|
|
1703
|
+
const request = store.delete(address);
|
|
1704
|
+
request.onsuccess = () => resolve();
|
|
1705
|
+
request.onerror = () =>
|
|
1706
|
+
reject(
|
|
1707
|
+
new StorageError(
|
|
1708
|
+
`Failed to unwatch deposit address '${address}': ${request.error}`
|
|
1709
|
+
)
|
|
1710
|
+
);
|
|
1711
|
+
};
|
|
1712
|
+
getRequest.onerror = () =>
|
|
1713
|
+
reject(
|
|
1714
|
+
new StorageError(
|
|
1715
|
+
`Failed to read watched deposit address '${address}': ${getRequest.error}`
|
|
1716
|
+
)
|
|
1717
|
+
);
|
|
1718
|
+
return;
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
if (payload.type === "seen") {
|
|
1722
|
+
const getRequest = store.get(address);
|
|
1723
|
+
getRequest.onsuccess = () => {
|
|
1724
|
+
const existing = getRequest.result;
|
|
1725
|
+
if (!existing) {
|
|
1726
|
+
// Not watched, so there is nothing to mark (matches the SQL stores,
|
|
1727
|
+
// whose UPDATE affects no rows).
|
|
1728
|
+
resolve();
|
|
1729
|
+
return;
|
|
1730
|
+
}
|
|
1731
|
+
const request = store.put({ ...existing, seen: true });
|
|
1732
|
+
request.onsuccess = () => resolve();
|
|
1733
|
+
request.onerror = () =>
|
|
1734
|
+
reject(
|
|
1735
|
+
new StorageError(
|
|
1736
|
+
`Failed to mark deposit address '${address}' seen: ${request.error}`
|
|
1737
|
+
)
|
|
1738
|
+
);
|
|
1739
|
+
};
|
|
1740
|
+
getRequest.onerror = () =>
|
|
1741
|
+
reject(
|
|
1742
|
+
new StorageError(
|
|
1743
|
+
`Failed to read watched deposit address '${address}': ${getRequest.error}`
|
|
1744
|
+
)
|
|
1745
|
+
);
|
|
1746
|
+
return;
|
|
1747
|
+
}
|
|
1748
|
+
|
|
1749
|
+
reject(new StorageError(`Unknown payload type: ${payload.type}`));
|
|
1750
|
+
});
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1609
1753
|
async setLnurlMetadata(metadata) {
|
|
1610
1754
|
if (!this.db) {
|
|
1611
1755
|
throw new StorageError("Database not initialized");
|