@bennyblader/ddk-rn 0.2.7 → 0.3.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.
@@ -1,27 +1,33 @@
1
- #![allow(unused_imports, unused_variables)]
2
1
  #![allow(clippy::too_many_arguments)]
3
- use bitcoin::consensus::{Decodable, Encodable};
2
+ use bip39::{Language, Mnemonic};
3
+ use bitcoin::bip32::{DerivationPath, IntoDerivationPath, Xpriv, Xpub};
4
4
  use bitcoin::hashes::Hash;
5
- use bitcoin::sighash::{EcdsaSighashType, SighashCache};
6
- use bitcoin::transaction::Version;
5
+ use bitcoin::sighash::EcdsaSighashType;
6
+ use bitcoin::WPubkeyHash;
7
7
  use bitcoin::{
8
- Amount, OutPoint, ScriptBuf, Sequence, Transaction as BtcTransaction, TxIn, TxOut as BtcTxOut,
9
- Txid, Witness,
8
+ Amount, Network, OutPoint, ScriptBuf, Sequence, Transaction as BtcTransaction, TxIn,
9
+ TxOut as BtcTxOut, Txid, Witness,
10
10
  };
11
- use bitcoin::{PubkeyHash, WPubkeyHash};
12
11
  use dlc::{
13
12
  self, dlc_input::DlcInputInfo as RustDlcInputInfo, DlcTransactions as RustDlcTransactions,
14
13
  OracleInfo as DlcOracleInfo, PartyParams as DlcPartyParams, Payout as DlcPayout,
15
14
  TxInputInfo as DlcTxInputInfo,
16
15
  };
16
+ use secp256k1_zkp::All;
17
17
  use secp256k1_zkp::{
18
18
  ecdsa::Signature as EcdsaSignature, Message, PublicKey, Secp256k1, SecretKey, XOnlyPublicKey,
19
19
  };
20
- use secp256k1_zkp::{schnorr::Signature as SchnorrSignature, EcdsaAdaptorSignature};
21
20
  use std::str::FromStr;
21
+ use std::sync::OnceLock;
22
22
 
23
23
  uniffi::include_scaffolding!("ddk_ffi");
24
24
 
25
+ static SECP_CONTEXT: OnceLock<Secp256k1<All>> = OnceLock::new();
26
+
27
+ pub fn get_secp_context() -> &'static Secp256k1<All> {
28
+ SECP_CONTEXT.get_or_init(|| Secp256k1::new())
29
+ }
30
+
25
31
  pub fn version() -> String {
26
32
  env!("CARGO_PKG_VERSION").to_string()
27
33
  }
@@ -54,8 +60,22 @@ pub enum DLCError {
54
60
  Secp256k1Error(String),
55
61
  #[error("Miniscript error")]
56
62
  MiniscriptError,
57
- #[error("Network error")]
58
- NetworkError,
63
+ #[error("Invalid network")]
64
+ InvalidNetwork,
65
+ #[error("Extended key error: {0}")]
66
+ KeyError(ExtendedKey),
67
+ }
68
+
69
+ #[derive(Debug, thiserror::Error)]
70
+ pub enum ExtendedKey {
71
+ #[error("Invalid mnemonic")]
72
+ InvalidMnemonic,
73
+ #[error("Invalid xpriv")]
74
+ InvalidXpriv,
75
+ #[error("Invalid xpub")]
76
+ InvalidXpub,
77
+ #[error("Invalid derivation path")]
78
+ InvalidDerivationPath,
59
79
  }
60
80
 
61
81
  impl From<dlc::Error> for DLCError {
@@ -624,12 +644,12 @@ pub fn get_raw_funding_transaction_input_signature(
624
644
  })
625
645
  .ok_or(DLCError::InvalidArgument)?;
626
646
 
647
+ let secp = get_secp_context();
627
648
  // Create P2WPKH script for signing
628
- let pk = PublicKey::from_secret_key(&Secp256k1::new(), &sk);
649
+ let pk = PublicKey::from_secret_key(secp, &sk);
629
650
  let wpkh = WPubkeyHash::hash(&pk.serialize());
630
651
  let script = bitcoin::ScriptBuf::new_p2wpkh(&wpkh);
631
652
 
632
- let secp = Secp256k1::signing_only();
633
653
  let sig = dlc::util::get_raw_sig_for_tx_input(
634
654
  &secp,
635
655
  &btc_tx,
@@ -714,7 +734,7 @@ pub fn create_cet_adaptor_signature_from_oracle_info(
714
734
  let msg_vec = messages.map_err(|_| DLCError::InvalidArgument)?;
715
735
  let nested_msgs = vec![msg_vec]; // Wrap in vector for single oracle
716
736
 
717
- let secp = Secp256k1::new();
737
+ let secp = get_secp_context();
718
738
  let adaptor_sig = dlc::create_cet_adaptor_sig_from_oracle_info(
719
739
  &secp,
720
740
  &btc_tx,
@@ -732,6 +752,57 @@ pub fn create_cet_adaptor_signature_from_oracle_info(
732
752
  })
733
753
  }
734
754
 
755
+ pub fn convert_mnemonic_to_seed(
756
+ mnemonic: String,
757
+ passphrase: Option<String>,
758
+ ) -> Result<Vec<u8>, DLCError> {
759
+ let seed_mnemonic = Mnemonic::parse_in_normalized(Language::English, &mnemonic)
760
+ .map_err(|_| DLCError::KeyError(ExtendedKey::InvalidMnemonic))?;
761
+ let passphrase = passphrase.unwrap_or("".to_string());
762
+ let seed = seed_mnemonic.to_seed(&passphrase);
763
+ Ok(seed.to_vec())
764
+ }
765
+
766
+ pub fn create_xpriv_from_parent_path(
767
+ xpriv: Vec<u8>,
768
+ base_derivation_path: String,
769
+ network: String,
770
+ path: String,
771
+ ) -> Result<Vec<u8>, DLCError> {
772
+ if xpriv.len() != 64 {
773
+ return Err(DLCError::KeyError(ExtendedKey::InvalidXpriv));
774
+ }
775
+ let secp = get_secp_context();
776
+ let network = Network::from_str(&network).map_err(|_| DLCError::InvalidNetwork)?;
777
+ let xpriv = Xpriv::new_master(network, &xpriv)
778
+ .map_err(|_| DLCError::KeyError(ExtendedKey::InvalidXpriv))?;
779
+ // Base path: 84'/0'/0'
780
+ let base_path = DerivationPath::from_str(&base_derivation_path)
781
+ .map_err(|_| DLCError::KeyError(ExtendedKey::InvalidDerivationPath))?;
782
+
783
+ // App path: {0 || 1}/{child_number}
784
+ let app_path = path
785
+ .into_derivation_path()
786
+ .map_err(|_| DLCError::KeyError(ExtendedKey::InvalidDerivationPath))?;
787
+
788
+ let full_path = base_path.extend(app_path);
789
+
790
+ let derived_xpriv = xpriv
791
+ .derive_priv(&secp, &full_path)
792
+ .map_err(|_| DLCError::KeyError(ExtendedKey::InvalidXpriv))?;
793
+
794
+ Ok(derived_xpriv.encode().to_vec())
795
+ }
796
+
797
+ pub fn get_xpub_from_xpriv(xpriv: Vec<u8>, network: String) -> Result<Vec<u8>, DLCError> {
798
+ let secp = get_secp_context();
799
+ let network = Network::from_str(&network).map_err(|_| DLCError::InvalidNetwork)?;
800
+ let xpriv = Xpriv::new_master(network, &xpriv)
801
+ .map_err(|_| DLCError::KeyError(ExtendedKey::InvalidXpriv))?;
802
+ let xpub = Xpub::from_priv(&secp, &xpriv);
803
+ Ok(xpub.encode().to_vec())
804
+ }
805
+
735
806
  #[cfg(test)]
736
807
  mod tests {
737
808
  use super::*;
@@ -760,7 +831,6 @@ mod tests {
760
831
  fund_pubkey: Vec<u8>,
761
832
  serial_id: u64,
762
833
  ) -> PartyParams {
763
- let secp = Secp256k1::new();
764
834
  let mut rng = thread_rng();
765
835
 
766
836
  // Create a realistic P2WPKH script
@@ -793,6 +863,50 @@ mod tests {
793
863
  }
794
864
  }
795
865
 
866
+ #[test]
867
+ fn mnemonic_to_seed_test() {
868
+ let mnemonic = Mnemonic::generate(24).unwrap();
869
+ let rust_seed = mnemonic.to_seed_normalized("").to_vec();
870
+ let ffi_seed = convert_mnemonic_to_seed(mnemonic.to_string(), None).unwrap();
871
+ assert_eq!(rust_seed, ffi_seed);
872
+ }
873
+
874
+ #[test]
875
+ fn xpriv_to_xpub_test() {
876
+ let mnemonic = Mnemonic::generate(24).unwrap();
877
+ let rust_xpriv =
878
+ Xpriv::new_master(Network::Bitcoin, &mnemonic.to_seed_normalized("").to_vec()).unwrap();
879
+ let ffi_xpriv = convert_mnemonic_to_seed(mnemonic.to_string(), None).unwrap();
880
+ let rust_xpub = Xpub::from_priv(get_secp_context(), &rust_xpriv);
881
+ let ffi_xpub = get_xpub_from_xpriv(ffi_xpriv, "bitcoin".to_string()).unwrap();
882
+ assert_eq!(rust_xpub.encode().to_vec(), ffi_xpub);
883
+ }
884
+
885
+ #[test]
886
+ fn xpriv_to_path() {
887
+ let base_derivation_path = "84'/0'/0'";
888
+ let app_path = "0/1";
889
+ let network = "bitcoin";
890
+ let secp = get_secp_context();
891
+
892
+ let mnemonic = Mnemonic::generate(24).unwrap();
893
+ let rust_xpriv =
894
+ Xpriv::new_master(Network::Bitcoin, &mnemonic.to_seed_normalized("")).unwrap();
895
+ let rust_path =
896
+ DerivationPath::from_str(&format!("{}/{}", base_derivation_path, app_path)).unwrap();
897
+ let rust_xpriv = rust_xpriv.derive_priv(&secp, &rust_path).unwrap();
898
+
899
+ let ffi_xpriv_bytes = convert_mnemonic_to_seed(mnemonic.to_string(), None).unwrap();
900
+ let ffi_xpub = create_xpriv_from_parent_path(
901
+ ffi_xpriv_bytes,
902
+ base_derivation_path.to_string(),
903
+ network.to_string(),
904
+ app_path.to_string(),
905
+ )
906
+ .unwrap();
907
+ assert_eq!(rust_xpriv.encode().to_vec(), ffi_xpub);
908
+ }
909
+
796
910
  #[test]
797
911
  fn test_create_fund_tx_locking_script_matches_rust_dlc() {
798
912
  let (_offer_sk, offer_pk, _accept_sk, accept_pk) = create_test_keys();
@@ -997,7 +1111,7 @@ mod tests {
997
1111
 
998
1112
  #[test]
999
1113
  fn test_conversion_functions() {
1000
- let (_offer_sk, offer_pk, _accept_sk, accept_pk) = create_test_keys();
1114
+ let (_offer_sk, offer_pk, _accept_sk, _accept_pk) = create_test_keys();
1001
1115
 
1002
1116
  // Test party params conversion
1003
1117
  let params =
@@ -1 +1 @@
1
- {"version":3,"names":["getter","globalThis","NativeDdkFfi","_default","exports","default","isRustFutureContinuationCallbackTypeCompatible","isUniffiForeignFutureTypeCompatible"],"sourceRoot":"../../src","sources":["ddk_ffi-ffi.ts"],"mappings":";;;;;;AAAA;AACA;;AAyJA;AACA;AACA;AACA;AACA;AACA,MAAMA,MAAmC,GAAGA,CAAA,KACzCC,UAAU,CAASC,YAAY;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACpBL,MAAM,EAErB;AAmHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMM,8CAGL,GAAG,IAAI;AACR,MAAMC,mCAGL,GAAG,IAAI","ignoreList":[]}
1
+ {"version":3,"names":["getter","globalThis","NativeDdkFfi","_default","exports","default","isRustFutureContinuationCallbackTypeCompatible","isUniffiForeignFutureTypeCompatible"],"sourceRoot":"../../src","sources":["ddk_ffi-ffi.ts"],"mappings":";;;;;;AAAA;AACA;;AAyKA;AACA;AACA;AACA;AACA;AACA,MAAMA,MAAmC,GAAGA,CAAA,KACzCC,UAAU,CAASC,YAAY;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACpBL,MAAM,EAErB;AAmHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMM,8CAGL,GAAG,IAAI;AACR,MAAMC,mCAGL,GAAG,IAAI","ignoreList":[]}
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.TxOutput = exports.TxInputInfo = exports.TxInput = exports.Transaction = exports.Payout = exports.PartyParams = exports.OracleInfo = exports.DlcTransactions = exports.DlcOutcome = exports.DlcInputInfo = exports.DlcError_Tags = exports.DlcError = exports.ChangeOutputAndFees = exports.AdaptorSignature = void 0;
6
+ exports.TxOutput = exports.TxInputInfo = exports.TxInput = exports.Transaction = exports.Payout = exports.PartyParams = exports.OracleInfo = exports.ExtendedKey_Tags = exports.ExtendedKey = exports.DlcTransactions = exports.DlcOutcome = exports.DlcInputInfo = exports.DlcError_Tags = exports.DlcError = exports.ChangeOutputAndFees = exports.AdaptorSignature = void 0;
7
+ exports.convertMnemonicToSeed = convertMnemonicToSeed;
7
8
  exports.createCet = createCet;
8
9
  exports.createCetAdaptorSignatureFromOracleInfo = createCetAdaptorSignatureFromOracleInfo;
9
10
  exports.createCets = createCets;
@@ -11,12 +12,13 @@ exports.createDlcTransactions = createDlcTransactions;
11
12
  exports.createFundTxLockingScript = createFundTxLockingScript;
12
13
  exports.createRefundTransaction = createRefundTransaction;
13
14
  exports.createSplicedDlcTransactions = createSplicedDlcTransactions;
15
+ exports.createXprivFromParentPath = createXprivFromParentPath;
14
16
  exports.default = void 0;
15
17
  exports.getChangeOutputAndFees = getChangeOutputAndFees;
16
18
  exports.getRawFundingTransactionInputSignature = getRawFundingTransactionInputSignature;
17
19
  exports.getTotalInputVsize = getTotalInputVsize;
20
+ exports.getXpubFromXpriv = getXpubFromXpriv;
18
21
  exports.isDustOutput = isDustOutput;
19
- exports.plzWork = plzWork;
20
22
  exports.signFundTransactionInput = signFundTransactionInput;
21
23
  exports.verifyFundTxSignature = verifyFundTxSignature;
22
24
  exports.version = version;
@@ -37,6 +39,14 @@ typeof process !== 'object' ||
37
39
  process?.env?.NODE_ENV !== 'production' || true;
38
40
  // Public interface members begin here.
39
41
 
42
+ function convertMnemonicToSeed(mnemonic, passphrase) /*throws*/{
43
+ return FfiConverterArrayUInt8.lift(uniffiCaller.rustCallWithError(/*liftError:*/FfiConverterTypeDLCError.lift.bind(FfiConverterTypeDLCError), /*caller:*/callStatus => {
44
+ return (() => {
45
+ console.debug(`-- uniffi_ddk_ffi_fn_func_convert_mnemonic_to_seed`);
46
+ return (0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_fn_func_convert_mnemonic_to_seed;
47
+ })()(FfiConverterString.lower(mnemonic), FfiConverterOptionalString.lower(passphrase), callStatus);
48
+ }, /*liftString:*/FfiConverterString.lift));
49
+ }
40
50
  function createCet(localOutput, localPayoutSerialId, remoteOutput, remotePayoutSerialId, fundTxId, fundVout, lockTime) /*throws*/{
41
51
  return FfiConverterTypeTransaction.lift(uniffiCaller.rustCallWithError(/*liftError:*/FfiConverterTypeDLCError.lift.bind(FfiConverterTypeDLCError), /*caller:*/callStatus => {
42
52
  return (() => {
@@ -93,6 +103,14 @@ function createSplicedDlcTransactions(outcomes, localParams, remoteParams, refun
93
103
  })()(FfiConverterArrayTypeDlcOutcome.lower(outcomes), FfiConverterTypePartyParams.lower(localParams), FfiConverterTypePartyParams.lower(remoteParams), _uniffiBindgenReactNative.FfiConverterUInt32.lower(refundLocktime), _uniffiBindgenReactNative.FfiConverterUInt64.lower(feeRate), _uniffiBindgenReactNative.FfiConverterUInt32.lower(fundLockTime), _uniffiBindgenReactNative.FfiConverterUInt32.lower(cetLockTime), _uniffiBindgenReactNative.FfiConverterUInt64.lower(fundOutputSerialId), callStatus);
94
104
  }, /*liftString:*/FfiConverterString.lift));
95
105
  }
106
+ function createXprivFromParentPath(xpriv, baseDerivationPath, network, path) /*throws*/{
107
+ return FfiConverterArrayUInt8.lift(uniffiCaller.rustCallWithError(/*liftError:*/FfiConverterTypeDLCError.lift.bind(FfiConverterTypeDLCError), /*caller:*/callStatus => {
108
+ return (() => {
109
+ console.debug(`-- uniffi_ddk_ffi_fn_func_create_xpriv_from_parent_path`);
110
+ return (0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_fn_func_create_xpriv_from_parent_path;
111
+ })()(FfiConverterArrayUInt8.lower(xpriv), FfiConverterString.lower(baseDerivationPath), FfiConverterString.lower(network), FfiConverterString.lower(path), callStatus);
112
+ }, /*liftString:*/FfiConverterString.lift));
113
+ }
96
114
  function getChangeOutputAndFees(params, feeRate) /*throws*/{
97
115
  return FfiConverterTypeChangeOutputAndFees.lift(uniffiCaller.rustCallWithError(/*liftError:*/FfiConverterTypeDLCError.lift.bind(FfiConverterTypeDLCError), /*caller:*/callStatus => {
98
116
  return (() => {
@@ -117,6 +135,14 @@ function getTotalInputVsize(inputs) {
117
135
  })()(FfiConverterArrayTypeTxInputInfo.lower(inputs), callStatus);
118
136
  }, /*liftString:*/FfiConverterString.lift));
119
137
  }
138
+ function getXpubFromXpriv(xpriv, network) /*throws*/{
139
+ return FfiConverterArrayUInt8.lift(uniffiCaller.rustCallWithError(/*liftError:*/FfiConverterTypeDLCError.lift.bind(FfiConverterTypeDLCError), /*caller:*/callStatus => {
140
+ return (() => {
141
+ console.debug(`-- uniffi_ddk_ffi_fn_func_get_xpub_from_xpriv`);
142
+ return (0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_fn_func_get_xpub_from_xpriv;
143
+ })()(FfiConverterArrayUInt8.lower(xpriv), FfiConverterString.lower(network), callStatus);
144
+ }, /*liftString:*/FfiConverterString.lift));
145
+ }
120
146
  function isDustOutput(output) {
121
147
  return _uniffiBindgenReactNative.FfiConverterBool.lift(uniffiCaller.rustCall(/*caller:*/callStatus => {
122
148
  return (() => {
@@ -125,14 +151,6 @@ function isDustOutput(output) {
125
151
  })()(FfiConverterTypeTxOutput.lower(output), callStatus);
126
152
  }, /*liftString:*/FfiConverterString.lift));
127
153
  }
128
- function plzWork() {
129
- return FfiConverterString.lift(uniffiCaller.rustCall(/*caller:*/callStatus => {
130
- return (() => {
131
- console.debug(`-- uniffi_ddk_ffi_fn_func_plz_work`);
132
- return (0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_fn_func_plz_work;
133
- })()(callStatus);
134
- }, /*liftString:*/FfiConverterString.lift));
135
- }
136
154
  function signFundTransactionInput(fundTransaction, privkey, prevTxId, prevTxVout, value) /*throws*/{
137
155
  return FfiConverterTypeTransaction.lift(uniffiCaller.rustCallWithError(/*liftError:*/FfiConverterTypeDLCError.lift.bind(FfiConverterTypeDLCError), /*caller:*/callStatus => {
138
156
  return (() => {
@@ -740,7 +758,8 @@ let DlcError_Tags = exports.DlcError_Tags = /*#__PURE__*/function (DlcError_Tags
740
758
  DlcError_Tags["SerializationError"] = "SerializationError";
741
759
  DlcError_Tags["Secp256k1Error"] = "Secp256k1Error";
742
760
  DlcError_Tags["MiniscriptError"] = "MiniscriptError";
743
- DlcError_Tags["NetworkError"] = "NetworkError";
761
+ DlcError_Tags["InvalidNetwork"] = "InvalidNetwork";
762
+ DlcError_Tags["KeyError"] = "KeyError";
744
763
  return DlcError_Tags;
745
764
  }({});
746
765
  const DlcError = exports.DlcError = (() => {
@@ -896,7 +915,7 @@ const DlcError = exports.DlcError = (() => {
896
915
  return instanceOf(e) && e[_uniffiBindgenReactNative.variantOrdinalSymbol] === 8;
897
916
  }
898
917
  }
899
- class NetworkError extends _uniffiBindgenReactNative.UniffiError {
918
+ class InvalidNetwork extends _uniffiBindgenReactNative.UniffiError {
900
919
  /**
901
920
  * @private
902
921
  * This field is private and should not be used.
@@ -907,14 +926,33 @@ const DlcError = exports.DlcError = (() => {
907
926
  * This field is private and should not be used.
908
927
  */
909
928
  [_uniffiBindgenReactNative.variantOrdinalSymbol] = 9;
910
- tag = DlcError_Tags.NetworkError;
929
+ tag = DlcError_Tags.InvalidNetwork;
911
930
  constructor(message) {
912
- super('DlcError', 'NetworkError', message);
931
+ super('DlcError', 'InvalidNetwork', message);
913
932
  }
914
933
  static instanceOf(e) {
915
934
  return instanceOf(e) && e[_uniffiBindgenReactNative.variantOrdinalSymbol] === 9;
916
935
  }
917
936
  }
937
+ class KeyError extends _uniffiBindgenReactNative.UniffiError {
938
+ /**
939
+ * @private
940
+ * This field is private and should not be used.
941
+ */
942
+ [_uniffiBindgenReactNative.uniffiTypeNameSymbol] = 'DlcError';
943
+ /**
944
+ * @private
945
+ * This field is private and should not be used.
946
+ */
947
+ [_uniffiBindgenReactNative.variantOrdinalSymbol] = 10;
948
+ tag = DlcError_Tags.KeyError;
949
+ constructor(message) {
950
+ super('DlcError', 'KeyError', message);
951
+ }
952
+ static instanceOf(e) {
953
+ return instanceOf(e) && e[_uniffiBindgenReactNative.variantOrdinalSymbol] === 10;
954
+ }
955
+ }
918
956
 
919
957
  // Utility function which does not rely on instanceof.
920
958
  function instanceOf(e) {
@@ -929,7 +967,8 @@ const DlcError = exports.DlcError = (() => {
929
967
  SerializationError,
930
968
  Secp256k1Error,
931
969
  MiniscriptError,
932
- NetworkError,
970
+ InvalidNetwork,
971
+ KeyError,
933
972
  instanceOf
934
973
  };
935
974
  })();
@@ -958,7 +997,9 @@ const FfiConverterTypeDLCError = (() => {
958
997
  case 8:
959
998
  return new DlcError.MiniscriptError(FfiConverterString.read(from));
960
999
  case 9:
961
- return new DlcError.NetworkError(FfiConverterString.read(from));
1000
+ return new DlcError.InvalidNetwork(FfiConverterString.read(from));
1001
+ case 10:
1002
+ return new DlcError.KeyError(FfiConverterString.read(from));
962
1003
  default:
963
1004
  throw new _uniffiBindgenReactNative.UniffiInternalError.UnexpectedEnumCase();
964
1005
  }
@@ -975,6 +1016,139 @@ const FfiConverterTypeDLCError = (() => {
975
1016
  return new FfiConverter();
976
1017
  })();
977
1018
 
1019
+ // Flat error type: ExtendedKey
1020
+ let ExtendedKey_Tags = exports.ExtendedKey_Tags = /*#__PURE__*/function (ExtendedKey_Tags) {
1021
+ ExtendedKey_Tags["InvalidMnemonic"] = "InvalidMnemonic";
1022
+ ExtendedKey_Tags["InvalidXpriv"] = "InvalidXpriv";
1023
+ ExtendedKey_Tags["InvalidXpub"] = "InvalidXpub";
1024
+ ExtendedKey_Tags["InvalidDerivationPath"] = "InvalidDerivationPath";
1025
+ return ExtendedKey_Tags;
1026
+ }({});
1027
+ const ExtendedKey = exports.ExtendedKey = (() => {
1028
+ class InvalidMnemonic extends _uniffiBindgenReactNative.UniffiError {
1029
+ /**
1030
+ * @private
1031
+ * This field is private and should not be used.
1032
+ */
1033
+ [_uniffiBindgenReactNative.uniffiTypeNameSymbol] = 'ExtendedKey';
1034
+ /**
1035
+ * @private
1036
+ * This field is private and should not be used.
1037
+ */
1038
+ [_uniffiBindgenReactNative.variantOrdinalSymbol] = 1;
1039
+ tag = ExtendedKey_Tags.InvalidMnemonic;
1040
+ constructor(message) {
1041
+ super('ExtendedKey', 'InvalidMnemonic', message);
1042
+ }
1043
+ static instanceOf(e) {
1044
+ return instanceOf(e) && e[_uniffiBindgenReactNative.variantOrdinalSymbol] === 1;
1045
+ }
1046
+ }
1047
+ class InvalidXpriv extends _uniffiBindgenReactNative.UniffiError {
1048
+ /**
1049
+ * @private
1050
+ * This field is private and should not be used.
1051
+ */
1052
+ [_uniffiBindgenReactNative.uniffiTypeNameSymbol] = 'ExtendedKey';
1053
+ /**
1054
+ * @private
1055
+ * This field is private and should not be used.
1056
+ */
1057
+ [_uniffiBindgenReactNative.variantOrdinalSymbol] = 2;
1058
+ tag = ExtendedKey_Tags.InvalidXpriv;
1059
+ constructor(message) {
1060
+ super('ExtendedKey', 'InvalidXpriv', message);
1061
+ }
1062
+ static instanceOf(e) {
1063
+ return instanceOf(e) && e[_uniffiBindgenReactNative.variantOrdinalSymbol] === 2;
1064
+ }
1065
+ }
1066
+ class InvalidXpub extends _uniffiBindgenReactNative.UniffiError {
1067
+ /**
1068
+ * @private
1069
+ * This field is private and should not be used.
1070
+ */
1071
+ [_uniffiBindgenReactNative.uniffiTypeNameSymbol] = 'ExtendedKey';
1072
+ /**
1073
+ * @private
1074
+ * This field is private and should not be used.
1075
+ */
1076
+ [_uniffiBindgenReactNative.variantOrdinalSymbol] = 3;
1077
+ tag = ExtendedKey_Tags.InvalidXpub;
1078
+ constructor(message) {
1079
+ super('ExtendedKey', 'InvalidXpub', message);
1080
+ }
1081
+ static instanceOf(e) {
1082
+ return instanceOf(e) && e[_uniffiBindgenReactNative.variantOrdinalSymbol] === 3;
1083
+ }
1084
+ }
1085
+ class InvalidDerivationPath extends _uniffiBindgenReactNative.UniffiError {
1086
+ /**
1087
+ * @private
1088
+ * This field is private and should not be used.
1089
+ */
1090
+ [_uniffiBindgenReactNative.uniffiTypeNameSymbol] = 'ExtendedKey';
1091
+ /**
1092
+ * @private
1093
+ * This field is private and should not be used.
1094
+ */
1095
+ [_uniffiBindgenReactNative.variantOrdinalSymbol] = 4;
1096
+ tag = ExtendedKey_Tags.InvalidDerivationPath;
1097
+ constructor(message) {
1098
+ super('ExtendedKey', 'InvalidDerivationPath', message);
1099
+ }
1100
+ static instanceOf(e) {
1101
+ return instanceOf(e) && e[_uniffiBindgenReactNative.variantOrdinalSymbol] === 4;
1102
+ }
1103
+ }
1104
+
1105
+ // Utility function which does not rely on instanceof.
1106
+ function instanceOf(e) {
1107
+ return e[_uniffiBindgenReactNative.uniffiTypeNameSymbol] === 'ExtendedKey';
1108
+ }
1109
+ return {
1110
+ InvalidMnemonic,
1111
+ InvalidXpriv,
1112
+ InvalidXpub,
1113
+ InvalidDerivationPath,
1114
+ instanceOf
1115
+ };
1116
+ })();
1117
+
1118
+ // Union type for ExtendedKey error type.
1119
+
1120
+ const FfiConverterTypeExtendedKey = (() => {
1121
+ const intConverter = _uniffiBindgenReactNative.FfiConverterInt32;
1122
+ class FfiConverter extends _uniffiBindgenReactNative.AbstractFfiConverterByteArray {
1123
+ read(from) {
1124
+ switch (intConverter.read(from)) {
1125
+ case 1:
1126
+ return new ExtendedKey.InvalidMnemonic(FfiConverterString.read(from));
1127
+ case 2:
1128
+ return new ExtendedKey.InvalidXpriv(FfiConverterString.read(from));
1129
+ case 3:
1130
+ return new ExtendedKey.InvalidXpub(FfiConverterString.read(from));
1131
+ case 4:
1132
+ return new ExtendedKey.InvalidDerivationPath(FfiConverterString.read(from));
1133
+ default:
1134
+ throw new _uniffiBindgenReactNative.UniffiInternalError.UnexpectedEnumCase();
1135
+ }
1136
+ }
1137
+ write(value, into) {
1138
+ const obj = value;
1139
+ const index = obj[_uniffiBindgenReactNative.variantOrdinalSymbol];
1140
+ intConverter.write(index, into);
1141
+ }
1142
+ allocationSize(value) {
1143
+ return intConverter.allocationSize(0);
1144
+ }
1145
+ }
1146
+ return new FfiConverter();
1147
+ })();
1148
+
1149
+ // FfiConverter for string | undefined
1150
+ const FfiConverterOptionalString = new _uniffiBindgenReactNative.FfiConverterOptional(FfiConverterString);
1151
+
978
1152
  // FfiConverter for Array<DlcInputInfo>
979
1153
  const FfiConverterArrayTypeDlcInputInfo = new _uniffiBindgenReactNative.FfiConverterArray(FfiConverterTypeDlcInputInfo);
980
1154
 
@@ -1017,6 +1191,9 @@ function uniffiEnsureInitialized() {
1017
1191
  if (bindingsContractVersion !== scaffoldingContractVersion) {
1018
1192
  throw new _uniffiBindgenReactNative.UniffiInternalError.ContractVersionMismatch(scaffoldingContractVersion, bindingsContractVersion);
1019
1193
  }
1194
+ if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_convert_mnemonic_to_seed() !== 65049) {
1195
+ throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_convert_mnemonic_to_seed');
1196
+ }
1020
1197
  if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_create_cet() !== 23081) {
1021
1198
  throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_create_cet');
1022
1199
  }
@@ -1038,6 +1215,9 @@ function uniffiEnsureInitialized() {
1038
1215
  if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_create_spliced_dlc_transactions() !== 51059) {
1039
1216
  throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_create_spliced_dlc_transactions');
1040
1217
  }
1218
+ if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_create_xpriv_from_parent_path() !== 50010) {
1219
+ throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_create_xpriv_from_parent_path');
1220
+ }
1041
1221
  if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_get_change_output_and_fees() !== 44150) {
1042
1222
  throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_get_change_output_and_fees');
1043
1223
  }
@@ -1047,12 +1227,12 @@ function uniffiEnsureInitialized() {
1047
1227
  if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_get_total_input_vsize() !== 38213) {
1048
1228
  throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_get_total_input_vsize');
1049
1229
  }
1230
+ if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_get_xpub_from_xpriv() !== 44344) {
1231
+ throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_get_xpub_from_xpriv');
1232
+ }
1050
1233
  if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_is_dust_output() !== 64174) {
1051
1234
  throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_is_dust_output');
1052
1235
  }
1053
- if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_plz_work() !== 32972) {
1054
- throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_plz_work');
1055
- }
1056
1236
  if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_sign_fund_transaction_input() !== 50531) {
1057
1237
  throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_sign_fund_transaction_input');
1058
1238
  }
@@ -1072,6 +1252,7 @@ var _default = exports.default = Object.freeze({
1072
1252
  FfiConverterTypeDlcInputInfo,
1073
1253
  FfiConverterTypeDlcOutcome,
1074
1254
  FfiConverterTypeDlcTransactions,
1255
+ FfiConverterTypeExtendedKey,
1075
1256
  FfiConverterTypeOracleInfo,
1076
1257
  FfiConverterTypePartyParams,
1077
1258
  FfiConverterTypePayout,