@bennyblader/ddk-rn 0.3.11 → 0.3.13

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/cpp/ddk_ffi.cpp CHANGED
@@ -133,6 +133,13 @@ extern "C" {
133
133
  uint64_t callback_data,
134
134
  UniffiForeignFutureStructVoid result
135
135
  );
136
+ RustBuffer uniffi_ddk_ffi_fn_func_add_signature_to_transaction(
137
+ RustBuffer tx,
138
+ RustBuffer signature,
139
+ RustBuffer pubkey,
140
+ uint32_t input_index,
141
+ RustCallStatus *uniffi_out_err
142
+ );
136
143
  RustBuffer uniffi_ddk_ffi_fn_func_convert_mnemonic_to_seed(
137
144
  RustBuffer mnemonic,
138
145
  RustBuffer passphrase,
@@ -265,6 +272,13 @@ extern "C" {
265
272
  uint64_t value,
266
273
  RustCallStatus *uniffi_out_err
267
274
  );
275
+ RustBuffer uniffi_ddk_ffi_fn_func_sign_multi_sig_input(
276
+ RustBuffer tx,
277
+ RustBuffer dlc_input,
278
+ RustBuffer local_privkey,
279
+ RustBuffer remote_signature,
280
+ RustCallStatus *uniffi_out_err
281
+ );
268
282
  int8_t uniffi_ddk_ffi_fn_func_verify_cet_adaptor_sig_from_oracle_info(
269
283
  RustBuffer adaptor_sig,
270
284
  RustBuffer cet,
@@ -508,6 +522,8 @@ extern "C" {
508
522
  /*handle*/ uint64_t handle,
509
523
  RustCallStatus *uniffi_out_err
510
524
  );
525
+ uint16_t uniffi_ddk_ffi_checksum_func_add_signature_to_transaction(
526
+ );
511
527
  uint16_t uniffi_ddk_ffi_checksum_func_convert_mnemonic_to_seed(
512
528
  );
513
529
  uint16_t uniffi_ddk_ffi_checksum_func_create_cet(
@@ -542,6 +558,8 @@ extern "C" {
542
558
  );
543
559
  uint16_t uniffi_ddk_ffi_checksum_func_sign_fund_transaction_input(
544
560
  );
561
+ uint16_t uniffi_ddk_ffi_checksum_func_sign_multi_sig_input(
562
+ );
545
563
  uint16_t uniffi_ddk_ffi_checksum_func_verify_cet_adaptor_sig_from_oracle_info(
546
564
  );
547
565
  uint16_t uniffi_ddk_ffi_checksum_func_verify_cet_adaptor_sigs_from_oracle_info(
@@ -2094,6 +2112,14 @@ NativeDdkFfi::NativeDdkFfi(
2094
2112
  return this->cpp_uniffi_internal_fn_func_ffi__arraybuffer_to_string(rt, thisVal, args, count);
2095
2113
  }
2096
2114
  );
2115
+ props["ubrn_uniffi_ddk_ffi_fn_func_add_signature_to_transaction"] = jsi::Function::createFromHostFunction(
2116
+ rt,
2117
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_fn_func_add_signature_to_transaction"),
2118
+ 4,
2119
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
2120
+ return this->cpp_uniffi_ddk_ffi_fn_func_add_signature_to_transaction(rt, thisVal, args, count);
2121
+ }
2122
+ );
2097
2123
  props["ubrn_uniffi_ddk_ffi_fn_func_convert_mnemonic_to_seed"] = jsi::Function::createFromHostFunction(
2098
2124
  rt,
2099
2125
  jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_fn_func_convert_mnemonic_to_seed"),
@@ -2230,6 +2256,14 @@ NativeDdkFfi::NativeDdkFfi(
2230
2256
  return this->cpp_uniffi_ddk_ffi_fn_func_sign_fund_transaction_input(rt, thisVal, args, count);
2231
2257
  }
2232
2258
  );
2259
+ props["ubrn_uniffi_ddk_ffi_fn_func_sign_multi_sig_input"] = jsi::Function::createFromHostFunction(
2260
+ rt,
2261
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_fn_func_sign_multi_sig_input"),
2262
+ 4,
2263
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
2264
+ return this->cpp_uniffi_ddk_ffi_fn_func_sign_multi_sig_input(rt, thisVal, args, count);
2265
+ }
2266
+ );
2233
2267
  props["ubrn_uniffi_ddk_ffi_fn_func_verify_cet_adaptor_sig_from_oracle_info"] = jsi::Function::createFromHostFunction(
2234
2268
  rt,
2235
2269
  jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_fn_func_verify_cet_adaptor_sig_from_oracle_info"),
@@ -2262,6 +2296,14 @@ NativeDdkFfi::NativeDdkFfi(
2262
2296
  return this->cpp_uniffi_ddk_ffi_fn_func_version(rt, thisVal, args, count);
2263
2297
  }
2264
2298
  );
2299
+ props["ubrn_uniffi_ddk_ffi_checksum_func_add_signature_to_transaction"] = jsi::Function::createFromHostFunction(
2300
+ rt,
2301
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_checksum_func_add_signature_to_transaction"),
2302
+ 0,
2303
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
2304
+ return this->cpp_uniffi_ddk_ffi_checksum_func_add_signature_to_transaction(rt, thisVal, args, count);
2305
+ }
2306
+ );
2265
2307
  props["ubrn_uniffi_ddk_ffi_checksum_func_convert_mnemonic_to_seed"] = jsi::Function::createFromHostFunction(
2266
2308
  rt,
2267
2309
  jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_checksum_func_convert_mnemonic_to_seed"),
@@ -2398,6 +2440,14 @@ NativeDdkFfi::NativeDdkFfi(
2398
2440
  return this->cpp_uniffi_ddk_ffi_checksum_func_sign_fund_transaction_input(rt, thisVal, args, count);
2399
2441
  }
2400
2442
  );
2443
+ props["ubrn_uniffi_ddk_ffi_checksum_func_sign_multi_sig_input"] = jsi::Function::createFromHostFunction(
2444
+ rt,
2445
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_checksum_func_sign_multi_sig_input"),
2446
+ 0,
2447
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
2448
+ return this->cpp_uniffi_ddk_ffi_checksum_func_sign_multi_sig_input(rt, thisVal, args, count);
2449
+ }
2450
+ );
2401
2451
  props["ubrn_uniffi_ddk_ffi_checksum_func_verify_cet_adaptor_sig_from_oracle_info"] = jsi::Function::createFromHostFunction(
2402
2452
  rt,
2403
2453
  jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_checksum_func_verify_cet_adaptor_sig_from_oracle_info"),
@@ -2493,6 +2543,16 @@ jsi::Value NativeDdkFfi::cpp_uniffi_internal_fn_func_ffi__arraybuffer_to_string(
2493
2543
  }
2494
2544
 
2495
2545
  // Methods calling directly into the uniffi generated C API of the Rust crate.
2546
+ jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_fn_func_add_signature_to_transaction(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2547
+ RustCallStatus status = uniffi::ddk_ffi::Bridging<RustCallStatus>::rustSuccess(rt);
2548
+ auto value = uniffi_ddk_ffi_fn_func_add_signature_to_transaction(uniffi::ddk_ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[0]), uniffi::ddk_ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[1]), uniffi::ddk_ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[2]), uniffi_jsi::Bridging<uint32_t>::fromJs(rt, callInvoker, args[3]),
2549
+ &status
2550
+ );
2551
+ uniffi::ddk_ffi::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
2552
+
2553
+
2554
+ return uniffi::ddk_ffi::Bridging<RustBuffer>::toJs(rt, callInvoker, value);
2555
+ }
2496
2556
  jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_fn_func_convert_mnemonic_to_seed(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2497
2557
  RustCallStatus status = uniffi::ddk_ffi::Bridging<RustCallStatus>::rustSuccess(rt);
2498
2558
  auto value = uniffi_ddk_ffi_fn_func_convert_mnemonic_to_seed(uniffi::ddk_ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[0]), uniffi::ddk_ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[1]),
@@ -2661,6 +2721,16 @@ jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_fn_func_sign_fund_transaction_input(
2661
2721
  uniffi::ddk_ffi::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
2662
2722
 
2663
2723
 
2724
+ return uniffi::ddk_ffi::Bridging<RustBuffer>::toJs(rt, callInvoker, value);
2725
+ }
2726
+ jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_fn_func_sign_multi_sig_input(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2727
+ RustCallStatus status = uniffi::ddk_ffi::Bridging<RustCallStatus>::rustSuccess(rt);
2728
+ auto value = uniffi_ddk_ffi_fn_func_sign_multi_sig_input(uniffi::ddk_ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[0]), uniffi::ddk_ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[1]), uniffi::ddk_ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[2]), uniffi::ddk_ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[3]),
2729
+ &status
2730
+ );
2731
+ uniffi::ddk_ffi::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
2732
+
2733
+
2664
2734
  return uniffi::ddk_ffi::Bridging<RustBuffer>::toJs(rt, callInvoker, value);
2665
2735
  }
2666
2736
  jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_fn_func_verify_cet_adaptor_sig_from_oracle_info(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
@@ -2702,6 +2772,13 @@ jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_fn_func_version(jsi::Runtime& rt, co
2702
2772
 
2703
2773
  return uniffi::ddk_ffi::Bridging<RustBuffer>::toJs(rt, callInvoker, value);
2704
2774
  }
2775
+ jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_checksum_func_add_signature_to_transaction(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2776
+ auto value = uniffi_ddk_ffi_checksum_func_add_signature_to_transaction(
2777
+ );
2778
+
2779
+
2780
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
2781
+ }
2705
2782
  jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_checksum_func_convert_mnemonic_to_seed(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2706
2783
  auto value = uniffi_ddk_ffi_checksum_func_convert_mnemonic_to_seed(
2707
2784
  );
@@ -2819,6 +2896,13 @@ jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_checksum_func_sign_fund_transaction_
2819
2896
  );
2820
2897
 
2821
2898
 
2899
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
2900
+ }
2901
+ jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_checksum_func_sign_multi_sig_input(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2902
+ auto value = uniffi_ddk_ffi_checksum_func_sign_multi_sig_input(
2903
+ );
2904
+
2905
+
2822
2906
  return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
2823
2907
  }
2824
2908
  jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_checksum_func_verify_cet_adaptor_sig_from_oracle_info(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
package/cpp/ddk_ffi.hpp CHANGED
@@ -21,6 +21,7 @@ class NativeDdkFfi : public jsi::HostObject {
21
21
  jsi::Value cpp_uniffi_internal_fn_func_ffi__string_to_byte_length(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
22
22
  jsi::Value cpp_uniffi_internal_fn_func_ffi__string_to_arraybuffer(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
23
23
  jsi::Value cpp_uniffi_internal_fn_func_ffi__arraybuffer_to_string(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
24
+ jsi::Value cpp_uniffi_ddk_ffi_fn_func_add_signature_to_transaction(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
24
25
  jsi::Value cpp_uniffi_ddk_ffi_fn_func_convert_mnemonic_to_seed(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
25
26
  jsi::Value cpp_uniffi_ddk_ffi_fn_func_create_cet(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
26
27
  jsi::Value cpp_uniffi_ddk_ffi_fn_func_create_cet_adaptor_signature_from_oracle_info(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
@@ -38,10 +39,12 @@ class NativeDdkFfi : public jsi::HostObject {
38
39
  jsi::Value cpp_uniffi_ddk_ffi_fn_func_is_dust_output(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
39
40
  jsi::Value cpp_uniffi_ddk_ffi_fn_func_sign_cet(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
40
41
  jsi::Value cpp_uniffi_ddk_ffi_fn_func_sign_fund_transaction_input(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
42
+ jsi::Value cpp_uniffi_ddk_ffi_fn_func_sign_multi_sig_input(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
41
43
  jsi::Value cpp_uniffi_ddk_ffi_fn_func_verify_cet_adaptor_sig_from_oracle_info(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
42
44
  jsi::Value cpp_uniffi_ddk_ffi_fn_func_verify_cet_adaptor_sigs_from_oracle_info(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
43
45
  jsi::Value cpp_uniffi_ddk_ffi_fn_func_verify_fund_tx_signature(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
44
46
  jsi::Value cpp_uniffi_ddk_ffi_fn_func_version(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
47
+ jsi::Value cpp_uniffi_ddk_ffi_checksum_func_add_signature_to_transaction(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
45
48
  jsi::Value cpp_uniffi_ddk_ffi_checksum_func_convert_mnemonic_to_seed(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
46
49
  jsi::Value cpp_uniffi_ddk_ffi_checksum_func_create_cet(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
47
50
  jsi::Value cpp_uniffi_ddk_ffi_checksum_func_create_cet_adaptor_signature_from_oracle_info(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
@@ -59,6 +62,7 @@ class NativeDdkFfi : public jsi::HostObject {
59
62
  jsi::Value cpp_uniffi_ddk_ffi_checksum_func_is_dust_output(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
60
63
  jsi::Value cpp_uniffi_ddk_ffi_checksum_func_sign_cet(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
61
64
  jsi::Value cpp_uniffi_ddk_ffi_checksum_func_sign_fund_transaction_input(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
65
+ jsi::Value cpp_uniffi_ddk_ffi_checksum_func_sign_multi_sig_input(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
62
66
  jsi::Value cpp_uniffi_ddk_ffi_checksum_func_verify_cet_adaptor_sig_from_oracle_info(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
63
67
  jsi::Value cpp_uniffi_ddk_ffi_checksum_func_verify_cet_adaptor_sigs_from_oracle_info(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
64
68
  jsi::Value cpp_uniffi_ddk_ffi_checksum_func_verify_fund_tx_signature(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
@@ -282,7 +282,7 @@ checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675"
282
282
 
283
283
  [[package]]
284
284
  name = "ddk_ffi"
285
- version = "0.3.11"
285
+ version = "0.3.13"
286
286
  dependencies = [
287
287
  "bip39",
288
288
  "bitcoin",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "ddk_ffi"
3
- version = "0.3.11"
3
+ version = "0.3.13"
4
4
  edition = "2021"
5
5
  license = "MIT"
6
6
  description = "rust-dlc language bindings"
@@ -99,6 +99,22 @@ namespace ddk_ffi {
99
99
  u64 input_amount
100
100
  );
101
101
 
102
+ [Throws=DLCError]
103
+ Transaction add_signature_to_transaction(
104
+ Transaction tx,
105
+ sequence<u8> signature,
106
+ sequence<u8> pubkey,
107
+ u32 input_index
108
+ );
109
+
110
+ [Throws=DLCError]
111
+ Transaction sign_multi_sig_input(
112
+ Transaction tx,
113
+ DlcInputInfo dlc_input,
114
+ sequence<u8> local_privkey,
115
+ sequence<u8> remote_signature
116
+ );
117
+
102
118
  [Throws=DLCError]
103
119
  Transaction sign_cet(
104
120
  Transaction cet,
@@ -4,7 +4,7 @@ use bitcoin::bip32::{DerivationPath, IntoDerivationPath, Xpriv, Xpub};
4
4
  use bitcoin::hashes::Hash;
5
5
  use bitcoin::sighash::EcdsaSighashType;
6
6
  use bitcoin::{
7
- Amount, Network, OutPoint, ScriptBuf, Sequence, Transaction as BtcTransaction, TxIn,
7
+ Amount, Network, OutPoint, Psbt, ScriptBuf, Sequence, Transaction as BtcTransaction, TxIn,
8
8
  TxOut as BtcTxOut, Txid, Witness,
9
9
  };
10
10
  use bitcoin::{Script, WPubkeyHash};
@@ -224,6 +224,22 @@ pub fn btc_tx_to_transaction(tx: &BtcTransaction) -> Transaction {
224
224
  }
225
225
  }
226
226
 
227
+ pub fn add_signature_to_transaction(
228
+ tx: Transaction,
229
+ signature: Vec<u8>,
230
+ pubkey: Vec<u8>,
231
+ input_index: u32,
232
+ ) -> Result<Transaction, DLCError> {
233
+ let mut tx = transaction_to_btc_tx(&tx).map_err(|_| DLCError::InvalidTransaction)?;
234
+ let mut witness = Witness::new();
235
+ witness.push(signature);
236
+ witness.push(pubkey);
237
+
238
+ tx.input[input_index as usize].witness = witness;
239
+
240
+ Ok(btc_tx_to_transaction(&tx))
241
+ }
242
+
227
243
  pub fn plz_work() -> String {
228
244
  "heyhowareya".to_string()
229
245
  }
@@ -255,6 +271,19 @@ pub fn dlc_input_info_to_rust(input: &DlcInputInfo) -> Result<RustDlcInputInfo,
255
271
  })
256
272
  }
257
273
 
274
+ pub fn rust_to_dlc_input(input: &RustDlcInputInfo) -> Result<DlcInputInfo, DLCError> {
275
+ Ok(DlcInputInfo {
276
+ fund_tx: btc_tx_to_transaction(&input.fund_tx),
277
+ fund_vout: input.fund_vout,
278
+ local_fund_pubkey: input.local_fund_pubkey.serialize().to_vec(),
279
+ remote_fund_pubkey: input.remote_fund_pubkey.serialize().to_vec(),
280
+ fund_amount: input.fund_amount.to_sat(),
281
+ max_witness_len: input.max_witness_len as u32,
282
+ input_serial_id: input.input_serial_id,
283
+ contract_id: input.contract_id.to_vec(),
284
+ })
285
+ }
286
+
258
287
  /// Convert UniFFI TxInputInfo to rust-dlc TxInputInfo
259
288
  pub fn tx_input_info_to_rust(input: &TxInputInfo) -> Result<DlcTxInputInfo, DLCError> {
260
289
  let txid = Txid::from_str(&input.txid)
@@ -712,6 +741,55 @@ pub fn sign_fund_transaction_input(
712
741
  Ok(btc_tx_to_transaction(&btc_tx))
713
742
  }
714
743
 
744
+ pub fn sign_multi_sig_input(
745
+ txn: Transaction,
746
+ dlc_input: DlcInputInfo,
747
+ local_privkey: Vec<u8>,
748
+ remote_signature: Vec<u8>,
749
+ ) -> Result<Transaction, DLCError> {
750
+ let secp = get_secp_context();
751
+ let btc_tx = transaction_to_btc_tx(&txn)?;
752
+ let sk = SecretKey::from_slice(&local_privkey)
753
+ .map_err(|_| DLCError::InvalidArgument("Invalid private key".to_string()))?;
754
+
755
+ let local_pk = PublicKey::from_slice(&dlc_input.local_fund_pubkey)
756
+ .map_err(|_| DLCError::InvalidPublicKey)?;
757
+ let remote_pk = PublicKey::from_slice(&dlc_input.remote_fund_pubkey)
758
+ .map_err(|_| DLCError::InvalidPublicKey)?;
759
+
760
+ let dlc_input = dlc_input_info_to_rust(&dlc_input)?;
761
+
762
+ let signature = dlc::dlc_input::create_dlc_funding_input_signature(
763
+ secp,
764
+ &btc_tx,
765
+ dlc_input.fund_vout as usize,
766
+ &dlc_input,
767
+ &sk,
768
+ )
769
+ .map_err(|_| DLCError::InvalidSignature)?;
770
+
771
+ let (first, second) = if local_pk < remote_pk {
772
+ (local_pk, remote_pk)
773
+ } else {
774
+ (remote_pk, local_pk)
775
+ };
776
+
777
+ let witness = dlc::dlc_input::combine_dlc_input_signatures(
778
+ &dlc_input,
779
+ &signature,
780
+ &remote_signature,
781
+ &first,
782
+ &second,
783
+ );
784
+
785
+ let mut fund_psbt = Psbt::from_unsigned_tx(btc_tx).map_err(|_| DLCError::InvalidTransaction)?;
786
+ fund_psbt.inputs[dlc_input.fund_vout as usize].final_script_witness = Some(witness);
787
+
788
+ Ok(btc_tx_to_transaction(
789
+ &fund_psbt.extract_tx_unchecked_fee_rate(),
790
+ ))
791
+ }
792
+
715
793
  pub fn sign_cet(
716
794
  cet: Transaction,
717
795
  adaptor_signature: Vec<u8>,
@@ -1 +1 @@
1
- {"version":3,"names":["getter","globalThis","NativeDdkFfi","_default","exports","default","isRustFutureContinuationCallbackTypeCompatible","isUniffiForeignFutureTypeCompatible"],"sourceRoot":"../../src","sources":["ddk_ffi-ffi.ts"],"mappings":";;;;;;AAAA;AACA;;AAoNA;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;;AAoOA;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":[]}
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.TxOutput = exports.TxInputInfo = exports.TxInput = exports.Transaction = exports.Payout = exports.PartyParams = exports.OracleInfo = exports.ExtendedKey_Tags = exports.ExtendedKey = exports.DlcTransactions = exports.DlcInputInfo = exports.DlcError_Tags = exports.DlcError = exports.ChangeOutputAndFees = exports.AdaptorSignature = void 0;
7
+ exports.addSignatureToTransaction = addSignatureToTransaction;
7
8
  exports.convertMnemonicToSeed = convertMnemonicToSeed;
8
9
  exports.createCet = createCet;
9
10
  exports.createCetAdaptorSignatureFromOracleInfo = createCetAdaptorSignatureFromOracleInfo;
@@ -22,6 +23,7 @@ exports.getXpubFromXpriv = getXpubFromXpriv;
22
23
  exports.isDustOutput = isDustOutput;
23
24
  exports.signCet = signCet;
24
25
  exports.signFundTransactionInput = signFundTransactionInput;
26
+ exports.signMultiSigInput = signMultiSigInput;
25
27
  exports.verifyCetAdaptorSigFromOracleInfo = verifyCetAdaptorSigFromOracleInfo;
26
28
  exports.verifyCetAdaptorSigsFromOracleInfo = verifyCetAdaptorSigsFromOracleInfo;
27
29
  exports.verifyFundTxSignature = verifyFundTxSignature;
@@ -43,6 +45,14 @@ typeof process !== 'object' ||
43
45
  process?.env?.NODE_ENV !== 'production' || true;
44
46
  // Public interface members begin here.
45
47
 
48
+ function addSignatureToTransaction(tx, signature, pubkey, inputIndex) /*throws*/{
49
+ return FfiConverterTypeTransaction.lift(uniffiCaller.rustCallWithError(/*liftError:*/FfiConverterTypeDLCError.lift.bind(FfiConverterTypeDLCError), /*caller:*/callStatus => {
50
+ return (() => {
51
+ console.debug(`-- uniffi_ddk_ffi_fn_func_add_signature_to_transaction`);
52
+ return (0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_fn_func_add_signature_to_transaction;
53
+ })()(FfiConverterTypeTransaction.lower(tx), FfiConverterArrayUInt8.lower(signature), FfiConverterArrayUInt8.lower(pubkey), _uniffiBindgenReactNative.FfiConverterUInt32.lower(inputIndex), callStatus);
54
+ }, /*liftString:*/FfiConverterString.lift));
55
+ }
46
56
  function convertMnemonicToSeed(mnemonic, passphrase) /*throws*/{
47
57
  return FfiConverterArrayUInt8.lift(uniffiCaller.rustCallWithError(/*liftError:*/FfiConverterTypeDLCError.lift.bind(FfiConverterTypeDLCError), /*caller:*/callStatus => {
48
58
  return (() => {
@@ -179,6 +189,14 @@ function signFundTransactionInput(fundTransaction, privkey, prevTxId, prevTxVout
179
189
  })()(FfiConverterTypeTransaction.lower(fundTransaction), FfiConverterArrayUInt8.lower(privkey), FfiConverterString.lower(prevTxId), _uniffiBindgenReactNative.FfiConverterUInt32.lower(prevTxVout), _uniffiBindgenReactNative.FfiConverterUInt64.lower(value), callStatus);
180
190
  }, /*liftString:*/FfiConverterString.lift));
181
191
  }
192
+ function signMultiSigInput(tx, dlcInput, localPrivkey, remoteSignature) /*throws*/{
193
+ return FfiConverterTypeTransaction.lift(uniffiCaller.rustCallWithError(/*liftError:*/FfiConverterTypeDLCError.lift.bind(FfiConverterTypeDLCError), /*caller:*/callStatus => {
194
+ return (() => {
195
+ console.debug(`-- uniffi_ddk_ffi_fn_func_sign_multi_sig_input`);
196
+ return (0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_fn_func_sign_multi_sig_input;
197
+ })()(FfiConverterTypeTransaction.lower(tx), FfiConverterTypeDlcInputInfo.lower(dlcInput), FfiConverterArrayUInt8.lower(localPrivkey), FfiConverterArrayUInt8.lower(remoteSignature), callStatus);
198
+ }, /*liftString:*/FfiConverterString.lift));
199
+ }
182
200
  function verifyCetAdaptorSigFromOracleInfo(adaptorSig, cet, oracleInfo, pubkey, fundingScriptPubkey, totalCollateral, msgs) {
183
201
  return _uniffiBindgenReactNative.FfiConverterBool.lift(uniffiCaller.rustCall(/*caller:*/callStatus => {
184
202
  return (() => {
@@ -1196,6 +1214,9 @@ function uniffiEnsureInitialized() {
1196
1214
  if (bindingsContractVersion !== scaffoldingContractVersion) {
1197
1215
  throw new _uniffiBindgenReactNative.UniffiInternalError.ContractVersionMismatch(scaffoldingContractVersion, bindingsContractVersion);
1198
1216
  }
1217
+ if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_add_signature_to_transaction() !== 1337) {
1218
+ throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_add_signature_to_transaction');
1219
+ }
1199
1220
  if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_convert_mnemonic_to_seed() !== 65049) {
1200
1221
  throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_convert_mnemonic_to_seed');
1201
1222
  }
@@ -1247,6 +1268,9 @@ function uniffiEnsureInitialized() {
1247
1268
  if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_sign_fund_transaction_input() !== 50531) {
1248
1269
  throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_sign_fund_transaction_input');
1249
1270
  }
1271
+ if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_sign_multi_sig_input() !== 14569) {
1272
+ throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_sign_multi_sig_input');
1273
+ }
1250
1274
  if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_verify_cet_adaptor_sig_from_oracle_info() !== 52232) {
1251
1275
  throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_verify_cet_adaptor_sig_from_oracle_info');
1252
1276
  }