@breeztech/breez-sdk-spark 0.19.0 → 0.20.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.
Binary file
@@ -307,6 +307,14 @@ export interface PrfProvider {
307
307
  * device. Hosts gate UX on the result.
308
308
  */
309
309
  isSupported(): Promise<boolean>;
310
+
311
+ /**
312
+ * Optional. Whether the silent single-CTA flow works here (a
313
+ * no-credential sign-in fast-fails with no UI). Omit to be treated as
314
+ * unsupported (`false`); the built-in browser provider returns the
315
+ * WebAuthn immediate-mediation capability.
316
+ */
317
+ supportsImmediateMediation?(): Promise<boolean>;
310
318
  }
311
319
 
312
320
  /**
@@ -322,7 +330,9 @@ export interface DeriveSeedOptions {
322
330
  allowCredentials?: Uint8Array[];
323
331
  /**
324
332
  * Fast-fail when no local credential is available. On the web this maps
325
- * to WebAuthn `mediation: 'immediate'`: `true` opts in where the browser
333
+ * to WebAuthn `uiMode: 'immediate'`, used only on the unpinned probe (a
334
+ * non-empty allowCredentials keeps the standard picker, since a pin means
335
+ * a credential is already known): `true` opts in where the browser
326
336
  * advertises support, `false` uses the standard picker. Unset uses the
327
337
  * provider default.
328
338
  */
@@ -372,6 +382,15 @@ export interface PasskeyProviderOptions {
372
382
  userDisplayName?: string;
373
383
  }
374
384
 
385
+ /**
386
+ * Request shape for `PasskeyClient.connectWithPasskey`.
387
+ */
388
+ export interface ConnectWithPasskeyRequest {
389
+ label?: string;
390
+ allowCredentials?: Uint8Array[];
391
+ excludeCredentials?: Uint8Array[];
392
+ }
393
+
375
394
  /**
376
395
  * Request shape for `PasskeyClient.register`.
377
396
  */
@@ -389,6 +408,15 @@ export interface SignInRequest {
389
408
  preferImmediatelyAvailableCredentials?: boolean;
390
409
  }
391
410
 
411
+ /**
412
+ * Response shape for `PasskeyClient.connectWithPasskey`.
413
+ */
414
+ export interface ConnectWithPasskeyResponse {
415
+ wallet: Wallet;
416
+ credential?: PasskeyCredential;
417
+ labels: string[];
418
+ }
419
+
392
420
  /**
393
421
  * Response shape for `PasskeyClient.register`.
394
422
  */
@@ -483,8 +511,10 @@ export interface BitcoinAddressDetails {
483
511
 
484
512
  export interface BitcoinChainService {
485
513
  getAddressUtxos(address: string): Promise<Utxo[]>;
514
+ getAddressTxos(address: string): Promise<Utxo[]>;
486
515
  getTransactionStatus(txid: string): Promise<TxStatus>;
487
516
  getTransactionHex(txid: string): Promise<string>;
517
+ getOutspend(txid: string, vout: number): Promise<Outspend>;
488
518
  broadcastTransaction(tx: string): Promise<void>;
489
519
  recommendedFees(): Promise<RecommendedFees>;
490
520
  }
@@ -690,6 +720,10 @@ export interface ConversionSide {
690
720
  fee: string;
691
721
  }
692
722
 
723
+ export interface CpfpSigner {
724
+ signPsbt(psbtBytes: Uint8Array): Promise<Uint8Array>;
725
+ }
726
+
693
727
  export interface CreateIssuerTokenRequest {
694
728
  name: string;
695
729
  ticker: string;
@@ -927,6 +961,7 @@ export interface ExternalSparkSigner {
927
961
  getStaticDepositPublicKey(index: number): Promise<PublicKeyBytes>;
928
962
  signAuthenticationChallenge(challenge: Uint8Array): Promise<EcdsaSignatureBytes>;
929
963
  signMessage(message: Uint8Array): Promise<EcdsaSignatureBytes>;
964
+ signLeafRefundSpend(leafId: ExternalTreeNodeId, sighash: Uint8Array): Promise<SchnorrSignatureBytes>;
930
965
  signFrost(jobs: ExternalFrostJob[]): Promise<ExternalFrostShareResult[]>;
931
966
  prepareTransfer(request: ExternalPrepareTransferRequest): Promise<ExternalPreparedTransfer>;
932
967
  prepareClaim(request: ExternalPrepareClaimRequest): Promise<ExternalPreparedClaim>;
@@ -1254,6 +1289,11 @@ export interface PaymentRequestSource {
1254
1289
  bip353Address?: string;
1255
1290
  }
1256
1291
 
1292
+ export interface PerBranchFunding {
1293
+ leafId: string;
1294
+ fundingSat: number;
1295
+ }
1296
+
1257
1297
  export interface PrepareLnurlPayRequest {
1258
1298
  amount: bigint;
1259
1299
  comment?: string;
@@ -1291,6 +1331,24 @@ export interface PrepareSendPaymentResponse {
1291
1331
  feePolicy: FeePolicy;
1292
1332
  }
1293
1333
 
1334
+ export interface PrepareUnilateralExitRequest {
1335
+ feeRateSatPerVbyte: number;
1336
+ fundingKind: CpfpFundingKind;
1337
+ destination: string;
1338
+ selection: ExitLeafSelection;
1339
+ }
1340
+
1341
+ export interface PrepareUnilateralExitResponse {
1342
+ leaves: UnilateralExitLeaf[];
1343
+ recoverableValueSat: number;
1344
+ totalFeeSat: number;
1345
+ fanoutFeeSat: number;
1346
+ singleUtxoFundingSat: number;
1347
+ perBranchFunding: PerBranchFunding[];
1348
+ feeRateSatPerVbyte: number;
1349
+ destination: string;
1350
+ }
1351
+
1294
1352
  export interface ProvisionalPayment {
1295
1353
  paymentId: string;
1296
1354
  amount: bigint;
@@ -1366,6 +1424,12 @@ export interface RefundDepositResponse {
1366
1424
  txHex: string;
1367
1425
  }
1368
1426
 
1427
+ export interface RefundPendingConversionsResponse {
1428
+ refunded: number;
1429
+ skipped: number;
1430
+ failed: number;
1431
+ }
1432
+
1369
1433
  export interface RegisterLightningAddressRequest {
1370
1434
  username: string;
1371
1435
  description?: string;
@@ -1673,6 +1737,34 @@ export interface UnfreezeIssuerTokenResponse {
1673
1737
  impactedTokenAmount: bigint;
1674
1738
  }
1675
1739
 
1740
+ export interface UnilateralExitLeaf {
1741
+ leafId: string;
1742
+ value: number;
1743
+ }
1744
+
1745
+ export interface UnilateralExitRequest {
1746
+ prepared: PrepareUnilateralExitResponse;
1747
+ fundingInputs: CpfpInput[];
1748
+ }
1749
+
1750
+ export interface UnilateralExitResponse {
1751
+ recoverableValueSat: number;
1752
+ totalFeeSat: number;
1753
+ leaves: UnilateralExitLeaf[];
1754
+ transactions: UnilateralExitTransaction[];
1755
+ }
1756
+
1757
+ export interface UnilateralExitTransaction {
1758
+ kind: UnilateralExitTxKind;
1759
+ nodeId?: string;
1760
+ txid: string;
1761
+ txHex: string;
1762
+ cpfpTxHex?: string;
1763
+ csvTimelockBlocks?: number;
1764
+ dependsOn: string[];
1765
+ status: ConfirmationStatus;
1766
+ }
1767
+
1676
1768
  export interface UnregisterWebhookRequest {
1677
1769
  webhookId: string;
1678
1770
  }
@@ -1692,6 +1784,7 @@ export interface UpdateContactRequest {
1692
1784
  export interface UpdateUserSettingsRequest {
1693
1785
  sparkPrivateModeEnabled?: boolean;
1694
1786
  stableBalanceActiveLabel?: StableBalanceActiveLabel;
1787
+ sparkMasterIdentityPublicKey?: SparkMasterIdentityPublicKey;
1695
1788
  }
1696
1789
 
1697
1790
  export interface UrlSuccessActionData {
@@ -1703,6 +1796,7 @@ export interface UrlSuccessActionData {
1703
1796
  export interface UserSettings {
1704
1797
  sparkPrivateModeEnabled: boolean;
1705
1798
  stableBalanceActiveLabel?: string;
1799
+ sparkMasterIdentityPublicKey?: string;
1706
1800
  }
1707
1801
 
1708
1802
  export interface Utxo {
@@ -1736,6 +1830,8 @@ export type BuyBitcoinRequest = { type: "moonpay"; lockedAmountSat?: number; red
1736
1830
 
1737
1831
  export type ChainApiType = "esplora" | "mempoolSpace";
1738
1832
 
1833
+ export type ConfirmationStatus = "confirmed" | "unconfirmed" | "unverified";
1834
+
1739
1835
  export type ConversionChain = { type: "spark" } | { type: "lightning" } | { type: "external"; name: string; chainId?: string };
1740
1836
 
1741
1837
  export type ConversionFilter = "ammRefundNeeded" | "orchestraPending" | "boltzPending";
@@ -1750,6 +1846,10 @@ export type ConversionStatus = "pending" | "completed" | "failed" | "refundNeede
1750
1846
 
1751
1847
  export type ConversionType = { type: "fromBitcoin" } | { type: "toBitcoin"; fromTokenIdentifier: string };
1752
1848
 
1849
+ export type CpfpFundingKind = { type: "p2wpkh" } | { type: "p2tr" } | { type: "custom"; scriptPubkeyHex: string; signedInputWeight: number };
1850
+
1851
+ export type CpfpInput = { type: "p2wpkh"; txid: string; vout: number; value: number; pubkey: string } | { type: "p2tr"; txid: string; vout: number; value: number; pubkey: string } | { type: "custom"; txid: string; vout: number; value: number; scriptPubkeyHex: string; signedInputWeight: number };
1852
+
1753
1853
  export type CrossChainAddressFamily = "evm" | "solana" | "tron";
1754
1854
 
1755
1855
  export type CrossChainFeeMode = "feesExcluded" | "feesIncluded";
@@ -1762,6 +1862,8 @@ export type CrossChainRouteFilter = { type: "send"; addressDetails: CrossChainAd
1762
1862
 
1763
1863
  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 };
1764
1864
 
1865
+ export type ExitLeafSelection = { type: "auto" } | { type: "specific"; leafIds: string[] };
1866
+
1765
1867
  export type ExternalFrostDerivation = { type: "signingLeaf"; leafId: ExternalTreeNodeId } | { type: "staticDeposit"; index: number } | { type: "htlcPreimage" } | { type: "identity" };
1766
1868
 
1767
1869
  export type ExternalSparkInvoiceKind = "sats" | "tokens";
@@ -1786,6 +1888,8 @@ export type OptimizationMode = "full" | "singleRound";
1786
1888
 
1787
1889
  export type OptimizationOutcome = { type: "completed"; roundsExecuted: number } | { type: "inProgress" };
1788
1890
 
1891
+ export type Outspend = { type: "unspent" } | { type: "spent"; txid: string; vin: number; status: TxStatus };
1892
+
1789
1893
  export type PaymentDetails = { type: "spark"; invoiceDetails?: SparkInvoicePaymentDetails; htlcDetails?: SparkHtlcDetails; conversionInfo?: ConversionInfo } | { type: "token"; metadata: TokenMetadata; txHash: string; txType: TokenTransactionType; invoiceDetails?: SparkInvoicePaymentDetails; conversionInfo?: ConversionInfo } | { type: "lightning"; description?: string; invoice: string; destinationPubkey: string; htlcDetails: SparkHtlcDetails; lnurlPayInfo?: LnurlPayInfo; lnurlWithdrawInfo?: LnurlWithdrawInfo; lnurlReceiveMetadata?: LnurlReceiveMetadata; conversionInfo?: ConversionInfo } | { type: "withdraw"; txId: string } | { type: "deposit"; txId: string; vout: number };
1790
1894
 
1791
1895
  export type PaymentDetailsFilter = { type: "spark"; htlcStatus?: SparkHtlcStatus[]; conversionRefundNeeded?: boolean } | { type: "token"; conversionRefundNeeded?: boolean; txHash?: string; txType?: TokenTransactionType } | { type: "lightning"; htlcStatus?: SparkHtlcStatus[] };
@@ -1822,6 +1926,8 @@ export type SourceAsset = { type: "bitcoin" } | { type: "token"; tokenIdentifier
1822
1926
 
1823
1927
  export type SparkHtlcStatus = "waitingForPreimage" | "preimageShared" | "returned";
1824
1928
 
1929
+ export type SparkMasterIdentityPublicKey = { type: "set"; publicKey: string } | { type: "unset" };
1930
+
1825
1931
  export type StableBalanceActiveLabel = { type: "set"; label: string } | { type: "unset" };
1826
1932
 
1827
1933
  export type StoragePaymentDetailsFilter = { type: "spark"; htlcStatus?: SparkHtlcStatus[]; conversionFilter?: ConversionFilter } | { type: "token"; conversionFilter?: ConversionFilter; txHash?: string; txType?: TokenTransactionType } | { type: "lightning"; htlcStatus?: SparkHtlcStatus[]; conversionFilter?: ConversionFilter };
@@ -1836,6 +1942,8 @@ export type TransferSignature = { type: "transfer"; signed: ExternalPreparedTran
1836
1942
 
1837
1943
  export type TransferTarget = { type: "spark"; address: string; sparkInvoice?: string } | { type: "lightning"; bolt11: string; lnurlPay?: LnurlPayContext; feePolicy: FeePolicy; completionTimeoutSecs?: number } | { type: "coopExit"; address: string; feeQuote: SendOnchainFeeQuote; confirmationSpeed: OnchainConfirmationSpeed };
1838
1944
 
1945
+ export type UnilateralExitTxKind = "fanOut" | "node" | "refund" | "sweep";
1946
+
1839
1947
  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 };
1840
1948
 
1841
1949
  export type UpdateDepositPayload = { type: "claimError"; error: DepositClaimError } | { type: "refund"; refundTxid: string; refundTx: string };
@@ -1856,7 +1964,9 @@ export class BitcoinChainServiceHandle {
1856
1964
  free(): void;
1857
1965
  [Symbol.dispose](): void;
1858
1966
  broadcastTransaction(tx: string): Promise<void>;
1967
+ getAddressTxos(address: string): Promise<any>;
1859
1968
  getAddressUtxos(address: string): Promise<any>;
1969
+ getOutspend(txid: string, vout: number): Promise<any>;
1860
1970
  getTransactionHex(txid: string): Promise<any>;
1861
1971
  getTransactionStatus(txid: string): Promise<any>;
1862
1972
  recommendedFees(): Promise<any>;
@@ -1901,23 +2011,35 @@ export class BreezSdk {
1901
2011
  parse(input: string): Promise<InputType>;
1902
2012
  prepareLnurlPay(request: PrepareLnurlPayRequest): Promise<PrepareLnurlPayResponse>;
1903
2013
  prepareSendPayment(request: PrepareSendPaymentRequest): Promise<PrepareSendPaymentResponse>;
2014
+ prepareUnilateralExit(request: PrepareUnilateralExitRequest): Promise<PrepareUnilateralExitResponse>;
1904
2015
  publishSignedLnurlPayPackage(request: PublishSignedLnurlPayPackageRequest): Promise<PublishSignedLnurlPayResponse>;
1905
2016
  publishSignedTransferPackage(request: PublishSignedTransferPackageRequest): Promise<PublishSignedTransferPackageResponse>;
1906
2017
  receivePayment(request: ReceivePaymentRequest): Promise<ReceivePaymentResponse>;
1907
2018
  recommendedFees(): Promise<RecommendedFees>;
1908
2019
  refundDeposit(request: RefundDepositRequest): Promise<RefundDepositResponse>;
1909
- refundPendingConversions(): Promise<void>;
2020
+ refundPendingConversions(): Promise<RefundPendingConversionsResponse>;
1910
2021
  registerLightningAddress(request: RegisterLightningAddressRequest): Promise<LightningAddressInfo>;
1911
2022
  registerWebhook(request: RegisterWebhookRequest): Promise<RegisterWebhookResponse>;
1912
2023
  removeEventListener(id: string): Promise<boolean>;
1913
2024
  sendPayment(request: SendPaymentRequest): Promise<SendPaymentResponse>;
1914
2025
  signMessage(request: SignMessageRequest): Promise<SignMessageResponse>;
1915
2026
  syncWallet(request: SyncWalletRequest): Promise<SyncWalletResponse>;
2027
+ unilateralExit(request: UnilateralExitRequest, signer: CpfpSigner): Promise<UnilateralExitResponse>;
1916
2028
  unregisterWebhook(request: UnregisterWebhookRequest): Promise<void>;
1917
2029
  updateContact(request: UpdateContactRequest): Promise<Contact>;
1918
2030
  updateUserSettings(request: UpdateUserSettingsRequest): Promise<void>;
1919
2031
  }
1920
2032
 
2033
+ /**
2034
+ * A CPFP signer matching the `CpfpSigner` TypeScript interface.
2035
+ */
2036
+ export class DefaultCpfpSigner {
2037
+ private constructor();
2038
+ free(): void;
2039
+ [Symbol.dispose](): void;
2040
+ signPsbt(psbt_bytes: Uint8Array): Promise<Uint8Array>;
2041
+ }
2042
+
1921
2043
  /**
1922
2044
  * A JS handle to a backend's own session store (from `defaultSessionStore`),
1923
2045
  * exposing the same `getSession` / `setSession` interface. Wrap it in a JS
@@ -2013,6 +2135,7 @@ export class ExternalSparkSignerHandle {
2013
2135
  prepareTransfer(request: ExternalPrepareTransferRequest): Promise<ExternalPreparedTransfer>;
2014
2136
  signAuthenticationChallenge(challenge: Uint8Array): Promise<EcdsaSignatureBytes>;
2015
2137
  signFrost(jobs: ExternalFrostJob[]): Promise<ExternalFrostShareResult[]>;
2138
+ signLeafRefundSpend(leaf_id: ExternalTreeNodeId, sighash: Uint8Array): Promise<SchnorrSignatureBytes>;
2016
2139
  signMessage(message: Uint8Array): Promise<EcdsaSignatureBytes>;
2017
2140
  signSparkInvoice(request: ExternalSignSparkInvoiceRequest): Promise<ExternalSignedSparkInvoice>;
2018
2141
  signStaticDepositRefund(request: ExternalSignStaticDepositRefundRequest): Promise<ExternalFrostSignature>;
@@ -2060,6 +2183,18 @@ export class PasskeyClient {
2060
2183
  * hosts can gate UX on.
2061
2184
  */
2062
2185
  checkAvailability(): Promise<PasskeyAvailability>;
2186
+ /**
2187
+ * Single-CTA onboarding: silent sign-in that falls through to
2188
+ * registration when no credential exists on the device. Pins
2189
+ * immediate mediation, so on web only use it where the browser
2190
+ * advertises it (`supportsImmediateMediation`); otherwise the silent
2191
+ * probe degrades to the standard picker and a dismiss does not fall
2192
+ * through to register, so
2193
+ * present an explicit create / sign-in choice instead. Called without
2194
+ * a `label`, the response `labels` lists a returning user's wallets
2195
+ * for a picker.
2196
+ */
2197
+ connectWithPasskey(request: ConnectWithPasskeyRequest): Promise<ConnectWithPasskeyResponse>;
2063
2198
  /**
2064
2199
  * Label sub-object. List / publish labels for this passkey's identity.
2065
2200
  */
@@ -2084,6 +2219,14 @@ export class PasskeyClient {
2084
2219
  * label set in the same ceremony.
2085
2220
  */
2086
2221
  signIn(request: SignInRequest): Promise<SignInResponse>;
2222
+ /**
2223
+ * Whether this browser advertises WebAuthn immediate mediation: the
2224
+ * silent single-CTA probe (a no-credential sign-in fast-fails with no
2225
+ * UI) works here, so a web host can pick single- vs two-button
2226
+ * onboarding. Web-only and WASM-only: native does the silent probe
2227
+ * inherently, so there is nothing to query off-web.
2228
+ */
2229
+ supportsImmediateMediation(): Promise<boolean>;
2087
2230
  }
2088
2231
 
2089
2232
  /**
@@ -2317,6 +2460,11 @@ export function newSharedSdkContext(config: WasmSdkContextConfig): Promise<WasmS
2317
2460
  */
2318
2461
  export function postgresStorage(config: PostgresStorageConfig): WasmStorageConfig;
2319
2462
 
2463
+ /**
2464
+ * Creates a default CPFP signer backed by a single private key.
2465
+ */
2466
+ export function singleKeyCpfpSigner(secret_key_bytes: Uint8Array): DefaultCpfpSigner;
2467
+
2320
2468
  /**
2321
2469
  * Runs automatically when the wasm module is instantiated. Installs the
2322
2470
  * panic hook so Rust panics surface as readable `console.error` output
@@ -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, 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, 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, postgresStorage, singleKeyCpfpSigner, start, task_worker_entry_point
9
9
  } from "./breez_sdk_spark_wasm_bg.js";