@secondts/bark-react-native 0.20.1 → 0.22.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.
@@ -551,6 +551,63 @@ const FfiConverterTypeBoardFees = (() => {
551
551
  return new FFIConverter();
552
552
  })();
553
553
 
554
+ /**
555
+ * Destination for an externally funded board (e.g. a payjoin receive).
556
+ *
557
+ * The funding script commits to the derived keypair and expiry height, so
558
+ * `keypair_index` and `expiry_height` must be passed back unchanged to
559
+ * `board_psbt` once the funding PSBT is available — including on retries
560
+ * after the sender changes the transaction.
561
+ */
562
+ export type BoardFundingInfo = {
563
+ address: string;
564
+ expiryHeight: /*u32*/ number;
565
+ keypairIndex: /*u32*/ number;
566
+ };
567
+
568
+ /**
569
+ * Generated factory for {@link BoardFundingInfo} record objects.
570
+ */
571
+ export const BoardFundingInfo = (() => {
572
+ const defaults = () => ({});
573
+ const create = (() => {
574
+ return uniffiCreateRecord<BoardFundingInfo, ReturnType<typeof defaults>>(
575
+ defaults
576
+ );
577
+ })();
578
+ return Object.freeze({
579
+ create,
580
+ new: create,
581
+ defaults: () => Object.freeze(defaults()) as Partial<BoardFundingInfo>,
582
+ });
583
+ })();
584
+
585
+ const FfiConverterTypeBoardFundingInfo = (() => {
586
+ type TypeName = BoardFundingInfo;
587
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
588
+ read(from: RustBuffer): TypeName {
589
+ return {
590
+ address: FfiConverterString.read(from),
591
+ expiryHeight: FfiConverterUInt32.read(from),
592
+ keypairIndex: FfiConverterUInt32.read(from),
593
+ };
594
+ }
595
+ write(value: TypeName, into: RustBuffer): void {
596
+ FfiConverterString.write(value.address, into);
597
+ FfiConverterUInt32.write(value.expiryHeight, into);
598
+ FfiConverterUInt32.write(value.keypairIndex, into);
599
+ }
600
+ allocationSize(value: TypeName): number {
601
+ return (
602
+ FfiConverterString.allocationSize(value.address) +
603
+ FfiConverterUInt32.allocationSize(value.expiryHeight) +
604
+ FfiConverterUInt32.allocationSize(value.keypairIndex)
605
+ );
606
+ }
607
+ }
608
+ return new FFIConverter();
609
+ })();
610
+
554
611
  export type Config = {
555
612
  serverAddress: string;
556
613
  serverAccessToken?: string;
@@ -774,6 +831,105 @@ const FfiConverterTypeDestination = (() => {
774
831
  return new FFIConverter();
775
832
  })();
776
833
 
834
+ /**
835
+ * Estimated onchain cost of unilaterally (emergency) exiting a set of VTXOs.
836
+ *
837
+ * Mirrors bark-rest's `GET /exits/fee` response. The two legs are paid from
838
+ * different pockets: `exit_broadcast_fee_sats` is spent now out of confirmed
839
+ * onchain funds to CPFP-bump every not-yet-confirmed exit transaction, while
840
+ * `claim_fee_sats` is deducted later from the recovered value when the
841
+ * matured outputs are drained.
842
+ */
843
+ export type EmergencyExitFeeEstimate = {
844
+ /**
845
+ * CPFP fees to broadcast every not-yet-confirmed exit transaction. Paid
846
+ * now from confirmed onchain funds; this is the minimum onchain balance
847
+ * an emergency exit needs.
848
+ */
849
+ exitBroadcastFeeSats: /*u64*/ bigint;
850
+ /**
851
+ * Fee of the single batched transaction that later drains the matured
852
+ * exit outputs. Subtracted from the exited amount.
853
+ */
854
+ claimFeeSats: /*u64*/ bigint;
855
+ /**
856
+ * `exit_broadcast_fee_sats + claim_fee_sats`.
857
+ */
858
+ totalFeeSats: /*u64*/ bigint;
859
+ /**
860
+ * Fee rate the exit-broadcast leg was priced at (sat/vB, rounded up).
861
+ * Unless an explicit rate was supplied, the claim leg is priced
862
+ * separately at the chain's `regular` rate.
863
+ */
864
+ feeRateSatPerVb: /*u64*/ bigint;
865
+ /**
866
+ * Number of exit transactions that still need to be broadcast and
867
+ * CPFP-bumped. Already-confirmed tree transactions are not counted.
868
+ */
869
+ txsToBroadcast: /*u64*/ bigint;
870
+ /**
871
+ * Whether the wallet's current confirmed onchain balance covers the full
872
+ * serial broadcast walk. Each CPFP child can only spend confirmed coins,
873
+ * so `false` means the exit would stall midway even if a single bump
874
+ * looks affordable.
875
+ */
876
+ fundable: boolean;
877
+ };
878
+
879
+ /**
880
+ * Generated factory for {@link EmergencyExitFeeEstimate} record objects.
881
+ */
882
+ export const EmergencyExitFeeEstimate = (() => {
883
+ const defaults = () => ({});
884
+ const create = (() => {
885
+ return uniffiCreateRecord<
886
+ EmergencyExitFeeEstimate,
887
+ ReturnType<typeof defaults>
888
+ >(defaults);
889
+ })();
890
+ return Object.freeze({
891
+ create,
892
+ new: create,
893
+ defaults: () =>
894
+ Object.freeze(defaults()) as Partial<EmergencyExitFeeEstimate>,
895
+ });
896
+ })();
897
+
898
+ const FfiConverterTypeEmergencyExitFeeEstimate = (() => {
899
+ type TypeName = EmergencyExitFeeEstimate;
900
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
901
+ read(from: RustBuffer): TypeName {
902
+ return {
903
+ exitBroadcastFeeSats: FfiConverterUInt64.read(from),
904
+ claimFeeSats: FfiConverterUInt64.read(from),
905
+ totalFeeSats: FfiConverterUInt64.read(from),
906
+ feeRateSatPerVb: FfiConverterUInt64.read(from),
907
+ txsToBroadcast: FfiConverterUInt64.read(from),
908
+ fundable: FfiConverterBool.read(from),
909
+ };
910
+ }
911
+ write(value: TypeName, into: RustBuffer): void {
912
+ FfiConverterUInt64.write(value.exitBroadcastFeeSats, into);
913
+ FfiConverterUInt64.write(value.claimFeeSats, into);
914
+ FfiConverterUInt64.write(value.totalFeeSats, into);
915
+ FfiConverterUInt64.write(value.feeRateSatPerVb, into);
916
+ FfiConverterUInt64.write(value.txsToBroadcast, into);
917
+ FfiConverterBool.write(value.fundable, into);
918
+ }
919
+ allocationSize(value: TypeName): number {
920
+ return (
921
+ FfiConverterUInt64.allocationSize(value.exitBroadcastFeeSats) +
922
+ FfiConverterUInt64.allocationSize(value.claimFeeSats) +
923
+ FfiConverterUInt64.allocationSize(value.totalFeeSats) +
924
+ FfiConverterUInt64.allocationSize(value.feeRateSatPerVb) +
925
+ FfiConverterUInt64.allocationSize(value.txsToBroadcast) +
926
+ FfiConverterBool.allocationSize(value.fundable)
927
+ );
928
+ }
929
+ }
930
+ return new FFIConverter();
931
+ })();
932
+
777
933
  /**
778
934
  * Outcome of a cancellation request.
779
935
  *
@@ -6740,6 +6896,15 @@ export interface WalletLike {
6740
6896
  amountSats: /*u64*/ bigint,
6741
6897
  asyncOpts_?: { signal: AbortSignal }
6742
6898
  ): /*throws*/ Promise<PendingBoard>;
6899
+ boardFundingAddress(asyncOpts_?: {
6900
+ signal: AbortSignal;
6901
+ }): /*throws*/ Promise<BoardFundingInfo>;
6902
+ boardPsbt(
6903
+ psbtBase64: string,
6904
+ keypairIndex: /*u32*/ number,
6905
+ expiryHeight: /*u32*/ number,
6906
+ asyncOpts_?: { signal: AbortSignal }
6907
+ ): /*throws*/ Promise<PendingBoard>;
6743
6908
  bolt11Invoice(
6744
6909
  amountSats: /*u64*/ bigint,
6745
6910
  description: string | undefined,
@@ -6811,6 +6976,26 @@ export interface WalletLike {
6811
6976
  amountSats: /*u64*/ bigint,
6812
6977
  asyncOpts_?: { signal: AbortSignal }
6813
6978
  ): /*throws*/ Promise<FeeEstimate>;
6979
+ /**
6980
+ * Estimate the onchain cost of unilaterally (emergency) exiting VTXOs.
6981
+ * Mirrors bark-rest `GET /exits/fee`.
6982
+ *
6983
+ * Pass an empty `vtxo_ids` to price exiting the whole wallet (every
6984
+ * spendable VTXO). `fee_rate_sat_per_vb` applies to both legs; omit it to
6985
+ * use the chain's fast rate for the broadcast leg and regular rate for
6986
+ * the claim leg. `destination` only affects the claim transaction's weight.
6987
+ *
6988
+ * The onchain wallet is synced first so `fundable` reflects the current
6989
+ * confirmed balance. Requires a BDK onchain wallet: callback-backed
6990
+ * wallets (`CustomOnchainWalletCallbacks`) cannot simulate the CPFP walk
6991
+ * and return an error.
6992
+ */
6993
+ estimateEmergencyExitFee(
6994
+ vtxoIds: Array<string>,
6995
+ feeRateSatPerVb: /*u64*/ bigint | undefined,
6996
+ destination: string | undefined,
6997
+ asyncOpts_?: { signal: AbortSignal }
6998
+ ): /*throws*/ Promise<EmergencyExitFeeEstimate>;
6814
6999
  estimateLightningReceiveFee(
6815
7000
  amountSats: /*u64*/ bigint,
6816
7001
  asyncOpts_?: { signal: AbortSignal }
@@ -7482,6 +7667,82 @@ export class Wallet extends UniffiAbstractObject implements WalletLike {
7482
7667
  }
7483
7668
  }
7484
7669
 
7670
+ async boardFundingAddress(asyncOpts_?: {
7671
+ signal: AbortSignal;
7672
+ }): Promise<BoardFundingInfo> /*throws*/ {
7673
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
7674
+ try {
7675
+ return await uniffiRustCallAsync(
7676
+ /*rustCaller:*/ uniffiCaller,
7677
+ /*rustFutureFunc:*/ () => {
7678
+ return nativeModule().ubrn_uniffi_bark_ffi_fn_method_wallet_board_funding_address(
7679
+ uniffiTypeWalletObjectFactory.clonePointer(this)
7680
+ );
7681
+ },
7682
+ /*pollFunc:*/ nativeModule()
7683
+ .ubrn_ffi_bark_ffi_rust_future_poll_rust_buffer,
7684
+ /*cancelFunc:*/ nativeModule()
7685
+ .ubrn_ffi_bark_ffi_rust_future_cancel_rust_buffer,
7686
+ /*completeFunc:*/ nativeModule()
7687
+ .ubrn_ffi_bark_ffi_rust_future_complete_rust_buffer,
7688
+ /*freeFunc:*/ nativeModule()
7689
+ .ubrn_ffi_bark_ffi_rust_future_free_rust_buffer,
7690
+ /*liftFunc:*/ FfiConverterTypeBoardFundingInfo.lift.bind(
7691
+ FfiConverterTypeBoardFundingInfo
7692
+ ),
7693
+ /*liftString:*/ FfiConverterString.lift,
7694
+ /*asyncOpts:*/ asyncOpts_,
7695
+ /*errorHandler:*/ FfiConverterTypeError.lift.bind(FfiConverterTypeError)
7696
+ );
7697
+ } catch (__error: any) {
7698
+ if (uniffiIsDebug && __error instanceof Error) {
7699
+ __error.stack = __stack;
7700
+ }
7701
+ throw __error;
7702
+ }
7703
+ }
7704
+
7705
+ async boardPsbt(
7706
+ psbtBase64: string,
7707
+ keypairIndex: /*u32*/ number,
7708
+ expiryHeight: /*u32*/ number,
7709
+ asyncOpts_?: { signal: AbortSignal }
7710
+ ): Promise<PendingBoard> /*throws*/ {
7711
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
7712
+ try {
7713
+ return await uniffiRustCallAsync(
7714
+ /*rustCaller:*/ uniffiCaller,
7715
+ /*rustFutureFunc:*/ () => {
7716
+ return nativeModule().ubrn_uniffi_bark_ffi_fn_method_wallet_board_psbt(
7717
+ uniffiTypeWalletObjectFactory.clonePointer(this),
7718
+ FfiConverterString.lower(psbtBase64),
7719
+ FfiConverterUInt32.lower(keypairIndex),
7720
+ FfiConverterUInt32.lower(expiryHeight)
7721
+ );
7722
+ },
7723
+ /*pollFunc:*/ nativeModule()
7724
+ .ubrn_ffi_bark_ffi_rust_future_poll_rust_buffer,
7725
+ /*cancelFunc:*/ nativeModule()
7726
+ .ubrn_ffi_bark_ffi_rust_future_cancel_rust_buffer,
7727
+ /*completeFunc:*/ nativeModule()
7728
+ .ubrn_ffi_bark_ffi_rust_future_complete_rust_buffer,
7729
+ /*freeFunc:*/ nativeModule()
7730
+ .ubrn_ffi_bark_ffi_rust_future_free_rust_buffer,
7731
+ /*liftFunc:*/ FfiConverterTypePendingBoard.lift.bind(
7732
+ FfiConverterTypePendingBoard
7733
+ ),
7734
+ /*liftString:*/ FfiConverterString.lift,
7735
+ /*asyncOpts:*/ asyncOpts_,
7736
+ /*errorHandler:*/ FfiConverterTypeError.lift.bind(FfiConverterTypeError)
7737
+ );
7738
+ } catch (__error: any) {
7739
+ if (uniffiIsDebug && __error instanceof Error) {
7740
+ __error.stack = __stack;
7741
+ }
7742
+ throw __error;
7743
+ }
7744
+ }
7745
+
7485
7746
  async bolt11Invoice(
7486
7747
  amountSats: /*u64*/ bigint,
7487
7748
  description: string | undefined,
@@ -7965,6 +8226,61 @@ export class Wallet extends UniffiAbstractObject implements WalletLike {
7965
8226
  }
7966
8227
  }
7967
8228
 
8229
+ /**
8230
+ * Estimate the onchain cost of unilaterally (emergency) exiting VTXOs.
8231
+ * Mirrors bark-rest `GET /exits/fee`.
8232
+ *
8233
+ * Pass an empty `vtxo_ids` to price exiting the whole wallet (every
8234
+ * spendable VTXO). `fee_rate_sat_per_vb` applies to both legs; omit it to
8235
+ * use the chain's fast rate for the broadcast leg and regular rate for
8236
+ * the claim leg. `destination` only affects the claim transaction's weight.
8237
+ *
8238
+ * The onchain wallet is synced first so `fundable` reflects the current
8239
+ * confirmed balance. Requires a BDK onchain wallet: callback-backed
8240
+ * wallets (`CustomOnchainWalletCallbacks`) cannot simulate the CPFP walk
8241
+ * and return an error.
8242
+ */
8243
+ async estimateEmergencyExitFee(
8244
+ vtxoIds: Array<string>,
8245
+ feeRateSatPerVb: /*u64*/ bigint | undefined,
8246
+ destination: string | undefined,
8247
+ asyncOpts_?: { signal: AbortSignal }
8248
+ ): Promise<EmergencyExitFeeEstimate> /*throws*/ {
8249
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
8250
+ try {
8251
+ return await uniffiRustCallAsync(
8252
+ /*rustCaller:*/ uniffiCaller,
8253
+ /*rustFutureFunc:*/ () => {
8254
+ return nativeModule().ubrn_uniffi_bark_ffi_fn_method_wallet_estimate_emergency_exit_fee(
8255
+ uniffiTypeWalletObjectFactory.clonePointer(this),
8256
+ FfiConverterArrayString.lower(vtxoIds),
8257
+ FfiConverterOptionalUInt64.lower(feeRateSatPerVb),
8258
+ FfiConverterOptionalString.lower(destination)
8259
+ );
8260
+ },
8261
+ /*pollFunc:*/ nativeModule()
8262
+ .ubrn_ffi_bark_ffi_rust_future_poll_rust_buffer,
8263
+ /*cancelFunc:*/ nativeModule()
8264
+ .ubrn_ffi_bark_ffi_rust_future_cancel_rust_buffer,
8265
+ /*completeFunc:*/ nativeModule()
8266
+ .ubrn_ffi_bark_ffi_rust_future_complete_rust_buffer,
8267
+ /*freeFunc:*/ nativeModule()
8268
+ .ubrn_ffi_bark_ffi_rust_future_free_rust_buffer,
8269
+ /*liftFunc:*/ FfiConverterTypeEmergencyExitFeeEstimate.lift.bind(
8270
+ FfiConverterTypeEmergencyExitFeeEstimate
8271
+ ),
8272
+ /*liftString:*/ FfiConverterString.lift,
8273
+ /*asyncOpts:*/ asyncOpts_,
8274
+ /*errorHandler:*/ FfiConverterTypeError.lift.bind(FfiConverterTypeError)
8275
+ );
8276
+ } catch (__error: any) {
8277
+ if (uniffiIsDebug && __error instanceof Error) {
8278
+ __error.stack = __stack;
8279
+ }
8280
+ throw __error;
8281
+ }
8282
+ }
8283
+
7968
8284
  async estimateLightningReceiveFee(
7969
8285
  amountSats: /*u64*/ bigint,
7970
8286
  asyncOpts_?: { signal: AbortSignal }
@@ -11153,6 +11469,22 @@ function uniffiEnsureInitialized() {
11153
11469
  "uniffi_bark_ffi_checksum_method_wallet_board_amount"
11154
11470
  );
11155
11471
  }
11472
+ if (
11473
+ nativeModule().ubrn_uniffi_bark_ffi_checksum_method_wallet_board_funding_address() !==
11474
+ 8961
11475
+ ) {
11476
+ throw new UniffiInternalError.ApiChecksumMismatch(
11477
+ "uniffi_bark_ffi_checksum_method_wallet_board_funding_address"
11478
+ );
11479
+ }
11480
+ if (
11481
+ nativeModule().ubrn_uniffi_bark_ffi_checksum_method_wallet_board_psbt() !==
11482
+ 28300
11483
+ ) {
11484
+ throw new UniffiInternalError.ApiChecksumMismatch(
11485
+ "uniffi_bark_ffi_checksum_method_wallet_board_psbt"
11486
+ );
11487
+ }
11156
11488
  if (
11157
11489
  nativeModule().ubrn_uniffi_bark_ffi_checksum_method_wallet_bolt11_invoice() !==
11158
11490
  54959
@@ -11257,6 +11589,14 @@ function uniffiEnsureInitialized() {
11257
11589
  "uniffi_bark_ffi_checksum_method_wallet_estimate_board_fee"
11258
11590
  );
11259
11591
  }
11592
+ if (
11593
+ nativeModule().ubrn_uniffi_bark_ffi_checksum_method_wallet_estimate_emergency_exit_fee() !==
11594
+ 44713
11595
+ ) {
11596
+ throw new UniffiInternalError.ApiChecksumMismatch(
11597
+ "uniffi_bark_ffi_checksum_method_wallet_estimate_emergency_exit_fee"
11598
+ );
11599
+ }
11260
11600
  if (
11261
11601
  nativeModule().ubrn_uniffi_bark_ffi_checksum_method_wallet_estimate_lightning_receive_fee() !==
11262
11602
  33637
@@ -11909,10 +12249,12 @@ export default Object.freeze({
11909
12249
  FfiConverterTypeBarkLogger,
11910
12250
  FfiConverterTypeBlockRef,
11911
12251
  FfiConverterTypeBoardFees,
12252
+ FfiConverterTypeBoardFundingInfo,
11912
12253
  FfiConverterTypeConfig,
11913
12254
  FfiConverterTypeCpfpParams,
11914
12255
  FfiConverterTypeCustomOnchainWalletCallbacks,
11915
12256
  FfiConverterTypeDestination,
12257
+ FfiConverterTypeEmergencyExitFeeEstimate,
11916
12258
  FfiConverterTypeError,
11917
12259
  FfiConverterTypeExitCancelFailure,
11918
12260
  FfiConverterTypeExitCancelResult,