@bennyblader/ddk-rn 0.3.21 → 0.3.25

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
@@ -195,6 +195,16 @@ extern "C" {
195
195
  uint64_t fund_output_serial_id,
196
196
  RustCallStatus *uniffi_out_err
197
197
  );
198
+ RustBuffer uniffi_ddk_ffi_fn_func_create_extkey_from_parent_path(
199
+ RustBuffer extkey,
200
+ RustBuffer path,
201
+ RustCallStatus *uniffi_out_err
202
+ );
203
+ RustBuffer uniffi_ddk_ffi_fn_func_create_extkey_from_seed(
204
+ RustBuffer seed,
205
+ RustBuffer network,
206
+ RustCallStatus *uniffi_out_err
207
+ );
198
208
  RustBuffer uniffi_ddk_ffi_fn_func_create_fund_tx_locking_script(
199
209
  RustBuffer local_fund_pubkey,
200
210
  RustBuffer remote_fund_pubkey,
@@ -222,7 +232,7 @@ extern "C" {
222
232
  RustCallStatus *uniffi_out_err
223
233
  );
224
234
  RustBuffer uniffi_ddk_ffi_fn_func_create_xpriv_from_parent_path(
225
- RustBuffer xpriv,
235
+ RustBuffer seed_or_xpriv,
226
236
  RustBuffer base_derivation_path,
227
237
  RustBuffer network,
228
238
  RustBuffer path,
@@ -233,6 +243,11 @@ extern "C" {
233
243
  uint64_t fee_rate,
234
244
  RustCallStatus *uniffi_out_err
235
245
  );
246
+ RustBuffer uniffi_ddk_ffi_fn_func_get_pubkey_from_extkey(
247
+ RustBuffer extkey,
248
+ RustBuffer network,
249
+ RustCallStatus *uniffi_out_err
250
+ );
236
251
  RustBuffer uniffi_ddk_ffi_fn_func_get_raw_funding_transaction_input_signature(
237
252
  RustBuffer funding_transaction,
238
253
  RustBuffer privkey,
@@ -536,6 +551,10 @@ extern "C" {
536
551
  );
537
552
  uint16_t uniffi_ddk_ffi_checksum_func_create_dlc_transactions(
538
553
  );
554
+ uint16_t uniffi_ddk_ffi_checksum_func_create_extkey_from_parent_path(
555
+ );
556
+ uint16_t uniffi_ddk_ffi_checksum_func_create_extkey_from_seed(
557
+ );
539
558
  uint16_t uniffi_ddk_ffi_checksum_func_create_fund_tx_locking_script(
540
559
  );
541
560
  uint16_t uniffi_ddk_ffi_checksum_func_create_refund_transaction(
@@ -546,6 +565,8 @@ extern "C" {
546
565
  );
547
566
  uint16_t uniffi_ddk_ffi_checksum_func_get_change_output_and_fees(
548
567
  );
568
+ uint16_t uniffi_ddk_ffi_checksum_func_get_pubkey_from_extkey(
569
+ );
549
570
  uint16_t uniffi_ddk_ffi_checksum_func_get_raw_funding_transaction_input_signature(
550
571
  );
551
572
  uint16_t uniffi_ddk_ffi_checksum_func_get_total_input_vsize(
@@ -2168,6 +2189,22 @@ NativeDdkFfi::NativeDdkFfi(
2168
2189
  return this->cpp_uniffi_ddk_ffi_fn_func_create_dlc_transactions(rt, thisVal, args, count);
2169
2190
  }
2170
2191
  );
2192
+ props["ubrn_uniffi_ddk_ffi_fn_func_create_extkey_from_parent_path"] = jsi::Function::createFromHostFunction(
2193
+ rt,
2194
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_fn_func_create_extkey_from_parent_path"),
2195
+ 2,
2196
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
2197
+ return this->cpp_uniffi_ddk_ffi_fn_func_create_extkey_from_parent_path(rt, thisVal, args, count);
2198
+ }
2199
+ );
2200
+ props["ubrn_uniffi_ddk_ffi_fn_func_create_extkey_from_seed"] = jsi::Function::createFromHostFunction(
2201
+ rt,
2202
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_fn_func_create_extkey_from_seed"),
2203
+ 2,
2204
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
2205
+ return this->cpp_uniffi_ddk_ffi_fn_func_create_extkey_from_seed(rt, thisVal, args, count);
2206
+ }
2207
+ );
2171
2208
  props["ubrn_uniffi_ddk_ffi_fn_func_create_fund_tx_locking_script"] = jsi::Function::createFromHostFunction(
2172
2209
  rt,
2173
2210
  jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_fn_func_create_fund_tx_locking_script"),
@@ -2208,6 +2245,14 @@ NativeDdkFfi::NativeDdkFfi(
2208
2245
  return this->cpp_uniffi_ddk_ffi_fn_func_get_change_output_and_fees(rt, thisVal, args, count);
2209
2246
  }
2210
2247
  );
2248
+ props["ubrn_uniffi_ddk_ffi_fn_func_get_pubkey_from_extkey"] = jsi::Function::createFromHostFunction(
2249
+ rt,
2250
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_fn_func_get_pubkey_from_extkey"),
2251
+ 2,
2252
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
2253
+ return this->cpp_uniffi_ddk_ffi_fn_func_get_pubkey_from_extkey(rt, thisVal, args, count);
2254
+ }
2255
+ );
2211
2256
  props["ubrn_uniffi_ddk_ffi_fn_func_get_raw_funding_transaction_input_signature"] = jsi::Function::createFromHostFunction(
2212
2257
  rt,
2213
2258
  jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_fn_func_get_raw_funding_transaction_input_signature"),
@@ -2352,6 +2397,22 @@ NativeDdkFfi::NativeDdkFfi(
2352
2397
  return this->cpp_uniffi_ddk_ffi_checksum_func_create_dlc_transactions(rt, thisVal, args, count);
2353
2398
  }
2354
2399
  );
2400
+ props["ubrn_uniffi_ddk_ffi_checksum_func_create_extkey_from_parent_path"] = jsi::Function::createFromHostFunction(
2401
+ rt,
2402
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_checksum_func_create_extkey_from_parent_path"),
2403
+ 0,
2404
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
2405
+ return this->cpp_uniffi_ddk_ffi_checksum_func_create_extkey_from_parent_path(rt, thisVal, args, count);
2406
+ }
2407
+ );
2408
+ props["ubrn_uniffi_ddk_ffi_checksum_func_create_extkey_from_seed"] = jsi::Function::createFromHostFunction(
2409
+ rt,
2410
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_checksum_func_create_extkey_from_seed"),
2411
+ 0,
2412
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
2413
+ return this->cpp_uniffi_ddk_ffi_checksum_func_create_extkey_from_seed(rt, thisVal, args, count);
2414
+ }
2415
+ );
2355
2416
  props["ubrn_uniffi_ddk_ffi_checksum_func_create_fund_tx_locking_script"] = jsi::Function::createFromHostFunction(
2356
2417
  rt,
2357
2418
  jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_checksum_func_create_fund_tx_locking_script"),
@@ -2392,6 +2453,14 @@ NativeDdkFfi::NativeDdkFfi(
2392
2453
  return this->cpp_uniffi_ddk_ffi_checksum_func_get_change_output_and_fees(rt, thisVal, args, count);
2393
2454
  }
2394
2455
  );
2456
+ props["ubrn_uniffi_ddk_ffi_checksum_func_get_pubkey_from_extkey"] = jsi::Function::createFromHostFunction(
2457
+ rt,
2458
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_checksum_func_get_pubkey_from_extkey"),
2459
+ 0,
2460
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
2461
+ return this->cpp_uniffi_ddk_ffi_checksum_func_get_pubkey_from_extkey(rt, thisVal, args, count);
2462
+ }
2463
+ );
2395
2464
  props["ubrn_uniffi_ddk_ffi_checksum_func_get_raw_funding_transaction_input_signature"] = jsi::Function::createFromHostFunction(
2396
2465
  rt,
2397
2466
  jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_checksum_func_get_raw_funding_transaction_input_signature"),
@@ -2611,6 +2680,26 @@ jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_fn_func_create_dlc_transactions(jsi:
2611
2680
  uniffi::ddk_ffi::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
2612
2681
 
2613
2682
 
2683
+ return uniffi::ddk_ffi::Bridging<RustBuffer>::toJs(rt, callInvoker, value);
2684
+ }
2685
+ jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_fn_func_create_extkey_from_parent_path(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2686
+ RustCallStatus status = uniffi::ddk_ffi::Bridging<RustCallStatus>::rustSuccess(rt);
2687
+ auto value = uniffi_ddk_ffi_fn_func_create_extkey_from_parent_path(uniffi::ddk_ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[0]), uniffi::ddk_ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[1]),
2688
+ &status
2689
+ );
2690
+ uniffi::ddk_ffi::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
2691
+
2692
+
2693
+ return uniffi::ddk_ffi::Bridging<RustBuffer>::toJs(rt, callInvoker, value);
2694
+ }
2695
+ jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_fn_func_create_extkey_from_seed(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2696
+ RustCallStatus status = uniffi::ddk_ffi::Bridging<RustCallStatus>::rustSuccess(rt);
2697
+ auto value = uniffi_ddk_ffi_fn_func_create_extkey_from_seed(uniffi::ddk_ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[0]), uniffi::ddk_ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[1]),
2698
+ &status
2699
+ );
2700
+ uniffi::ddk_ffi::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
2701
+
2702
+
2614
2703
  return uniffi::ddk_ffi::Bridging<RustBuffer>::toJs(rt, callInvoker, value);
2615
2704
  }
2616
2705
  jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_fn_func_create_fund_tx_locking_script(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
@@ -2661,6 +2750,16 @@ jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_fn_func_get_change_output_and_fees(j
2661
2750
  uniffi::ddk_ffi::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
2662
2751
 
2663
2752
 
2753
+ return uniffi::ddk_ffi::Bridging<RustBuffer>::toJs(rt, callInvoker, value);
2754
+ }
2755
+ jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_fn_func_get_pubkey_from_extkey(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2756
+ RustCallStatus status = uniffi::ddk_ffi::Bridging<RustCallStatus>::rustSuccess(rt);
2757
+ auto value = uniffi_ddk_ffi_fn_func_get_pubkey_from_extkey(uniffi::ddk_ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[0]), uniffi::ddk_ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[1]),
2758
+ &status
2759
+ );
2760
+ uniffi::ddk_ffi::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
2761
+
2762
+
2664
2763
  return uniffi::ddk_ffi::Bridging<RustBuffer>::toJs(rt, callInvoker, value);
2665
2764
  }
2666
2765
  jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_fn_func_get_raw_funding_transaction_input_signature(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
@@ -2819,6 +2918,20 @@ jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_checksum_func_create_dlc_transaction
2819
2918
  );
2820
2919
 
2821
2920
 
2921
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
2922
+ }
2923
+ jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_checksum_func_create_extkey_from_parent_path(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2924
+ auto value = uniffi_ddk_ffi_checksum_func_create_extkey_from_parent_path(
2925
+ );
2926
+
2927
+
2928
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
2929
+ }
2930
+ jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_checksum_func_create_extkey_from_seed(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2931
+ auto value = uniffi_ddk_ffi_checksum_func_create_extkey_from_seed(
2932
+ );
2933
+
2934
+
2822
2935
  return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
2823
2936
  }
2824
2937
  jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_checksum_func_create_fund_tx_locking_script(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
@@ -2854,6 +2967,13 @@ jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_checksum_func_get_change_output_and_
2854
2967
  );
2855
2968
 
2856
2969
 
2970
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
2971
+ }
2972
+ jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_checksum_func_get_pubkey_from_extkey(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
2973
+ auto value = uniffi_ddk_ffi_checksum_func_get_pubkey_from_extkey(
2974
+ );
2975
+
2976
+
2857
2977
  return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
2858
2978
  }
2859
2979
  jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_checksum_func_get_raw_funding_transaction_input_signature(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
package/cpp/ddk_ffi.hpp CHANGED
@@ -28,11 +28,14 @@ class NativeDdkFfi : public jsi::HostObject {
28
28
  jsi::Value cpp_uniffi_ddk_ffi_fn_func_create_cet_adaptor_sigs_from_oracle_info(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
29
29
  jsi::Value cpp_uniffi_ddk_ffi_fn_func_create_cets(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
30
30
  jsi::Value cpp_uniffi_ddk_ffi_fn_func_create_dlc_transactions(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
31
+ jsi::Value cpp_uniffi_ddk_ffi_fn_func_create_extkey_from_parent_path(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
32
+ jsi::Value cpp_uniffi_ddk_ffi_fn_func_create_extkey_from_seed(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
31
33
  jsi::Value cpp_uniffi_ddk_ffi_fn_func_create_fund_tx_locking_script(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
32
34
  jsi::Value cpp_uniffi_ddk_ffi_fn_func_create_refund_transaction(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
33
35
  jsi::Value cpp_uniffi_ddk_ffi_fn_func_create_spliced_dlc_transactions(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
34
36
  jsi::Value cpp_uniffi_ddk_ffi_fn_func_create_xpriv_from_parent_path(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
35
37
  jsi::Value cpp_uniffi_ddk_ffi_fn_func_get_change_output_and_fees(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
38
+ jsi::Value cpp_uniffi_ddk_ffi_fn_func_get_pubkey_from_extkey(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
36
39
  jsi::Value cpp_uniffi_ddk_ffi_fn_func_get_raw_funding_transaction_input_signature(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
37
40
  jsi::Value cpp_uniffi_ddk_ffi_fn_func_get_total_input_vsize(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
38
41
  jsi::Value cpp_uniffi_ddk_ffi_fn_func_get_xpub_from_xpriv(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
@@ -51,11 +54,14 @@ class NativeDdkFfi : public jsi::HostObject {
51
54
  jsi::Value cpp_uniffi_ddk_ffi_checksum_func_create_cet_adaptor_sigs_from_oracle_info(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
52
55
  jsi::Value cpp_uniffi_ddk_ffi_checksum_func_create_cets(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
53
56
  jsi::Value cpp_uniffi_ddk_ffi_checksum_func_create_dlc_transactions(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
57
+ jsi::Value cpp_uniffi_ddk_ffi_checksum_func_create_extkey_from_parent_path(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
58
+ jsi::Value cpp_uniffi_ddk_ffi_checksum_func_create_extkey_from_seed(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
54
59
  jsi::Value cpp_uniffi_ddk_ffi_checksum_func_create_fund_tx_locking_script(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
55
60
  jsi::Value cpp_uniffi_ddk_ffi_checksum_func_create_refund_transaction(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
56
61
  jsi::Value cpp_uniffi_ddk_ffi_checksum_func_create_spliced_dlc_transactions(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
57
62
  jsi::Value cpp_uniffi_ddk_ffi_checksum_func_create_xpriv_from_parent_path(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
58
63
  jsi::Value cpp_uniffi_ddk_ffi_checksum_func_get_change_output_and_fees(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
64
+ jsi::Value cpp_uniffi_ddk_ffi_checksum_func_get_pubkey_from_extkey(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
59
65
  jsi::Value cpp_uniffi_ddk_ffi_checksum_func_get_raw_funding_transaction_input_signature(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
60
66
  jsi::Value cpp_uniffi_ddk_ffi_checksum_func_get_total_input_vsize(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
61
67
  jsi::Value cpp_uniffi_ddk_ffi_checksum_func_get_xpub_from_xpriv(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
@@ -282,9 +282,9 @@ checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675"
282
282
 
283
283
  [[package]]
284
284
  name = "ddk-dlc"
285
- version = "0.0.21"
285
+ version = "1.0.0"
286
286
  source = "registry+https://github.com/rust-lang/crates.io-index"
287
- checksum = "cd81ea804b1fe6ad44621b79db9261b7a595e0c41e9fb33642ec4798100eeff7"
287
+ checksum = "0079e364d8e7be9dbf6b9fbe0d867e9cf2c92c395a19ffbea50d379bf3fc3e48"
288
288
  dependencies = [
289
289
  "bitcoin",
290
290
  "miniscript",
@@ -295,7 +295,7 @@ dependencies = [
295
295
 
296
296
  [[package]]
297
297
  name = "ddk_ffi"
298
- version = "0.3.21"
298
+ version = "0.3.25"
299
299
  dependencies = [
300
300
  "bip39",
301
301
  "bitcoin",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "ddk_ffi"
3
- version = "0.3.21"
3
+ version = "0.3.25"
4
4
  edition = "2021"
5
5
  license = "MIT"
6
6
  description = "rust-dlc language bindings"
@@ -16,7 +16,7 @@ crate-type = ["cdylib", "staticlib", "rlib"]
16
16
  uniffi = { version = "0.29.4", features = ["cli"] }
17
17
  # ddk-dlc = { path = "../../../ernest/dlcdevkit/dlc", features = ["use-serde"] }
18
18
  # ddk-dlc = { git = "https://github.com/bennyhodl/dlcdevkit.git", branch = "master", features = ["use-serde"] }
19
- ddk-dlc = { version = "0.0.21", features = ["use-serde"] }
19
+ ddk-dlc = { version = "1.0.0", features = ["use-serde"] }
20
20
  bitcoin = "0.32.7"
21
21
  thiserror = "2.0.12"
22
22
  secp256k1-zkp = "0.11.0"
@@ -1,17 +1,31 @@
1
1
  namespace ddk_ffi {
2
2
  string version();
3
+
4
+ // === SEED OPERATIONS ===
3
5
  [Throws=DLCError]
4
6
  sequence<u8> convert_mnemonic_to_seed(string mnemonic, string? passphrase);
7
+
8
+ [Throws=DLCError]
9
+ sequence<u8> create_extkey_from_seed(sequence<u8> seed, string network);
10
+
11
+ // === EXTENDED KEY OPERATIONS ===
12
+ [Throws=DLCError]
13
+ sequence<u8> create_extkey_from_parent_path(sequence<u8> extkey, string path);
14
+
15
+ [Throws=DLCError]
16
+ sequence<u8> get_pubkey_from_extkey(sequence<u8> extkey, string network);
17
+
18
+ [Throws=DLCError]
19
+ sequence<u8> get_xpub_from_xpriv(sequence<u8> xpriv, string network);
20
+
21
+ // === DEPRECATED ===
5
22
  [Throws=DLCError]
6
23
  sequence<u8> create_xpriv_from_parent_path(
7
- sequence<u8> xpriv,
24
+ sequence<u8> seed_or_xpriv,
8
25
  string base_derivation_path,
9
26
  string network,
10
27
  string path
11
28
  );
12
- [Throws=DLCError]
13
- sequence<u8> get_xpub_from_xpriv(sequence<u8> xpriv, string network);
14
-
15
29
 
16
30
  // DLC Transaction Creation Functions
17
31
  [Throws=DLCError]
@@ -1,6 +1,7 @@
1
1
  #![allow(clippy::too_many_arguments)]
2
+ #![allow(deprecated)]
2
3
  use bip39::{Language, Mnemonic};
3
- use bitcoin::bip32::{DerivationPath, IntoDerivationPath, Xpriv, Xpub};
4
+ use bitcoin::bip32::{IntoDerivationPath, Xpriv, Xpub};
4
5
  use bitcoin::hashes::Hash;
5
6
  use bitcoin::sighash::EcdsaSighashType;
6
7
  use bitcoin::{
@@ -1060,42 +1061,106 @@ pub fn convert_mnemonic_to_seed(
1060
1061
  Ok(seed.to_vec())
1061
1062
  }
1062
1063
 
1063
- pub fn create_xpriv_from_parent_path(
1064
- xpriv: Vec<u8>,
1065
- base_derivation_path: String,
1066
- network: String,
1067
- path: String,
1068
- ) -> Result<Vec<u8>, DLCError> {
1069
- if xpriv.len() != 64 {
1064
+ /// Create master extended private key from 64-byte seed
1065
+ /// Returns 78-byte encoded xpriv
1066
+ pub fn create_extkey_from_seed(seed: Vec<u8>, network: String) -> Result<Vec<u8>, DLCError> {
1067
+ if seed.len() != 64 {
1070
1068
  return Err(DLCError::KeyError(ExtendedKey::InvalidXpriv));
1071
1069
  }
1072
- let secp = get_secp_context();
1073
1070
  let network = Network::from_str(&network).map_err(|_| DLCError::InvalidNetwork)?;
1074
- let xpriv = Xpriv::new_master(network, &xpriv)
1071
+ let xpriv = Xpriv::new_master(network, &seed)
1075
1072
  .map_err(|_| DLCError::KeyError(ExtendedKey::InvalidXpriv))?;
1076
- // Base path: 84'/0'/0'
1077
- let base_path = DerivationPath::from_str(&base_derivation_path)
1078
- .map_err(|_| DLCError::KeyError(ExtendedKey::InvalidDerivationPath))?;
1073
+ Ok(xpriv.encode().to_vec())
1074
+ }
1075
+
1076
+ /// Derive child extended private key from parent extended key
1077
+ /// Input: 78-byte encoded xpriv, Output: 78-byte encoded xpriv
1078
+ pub fn create_extkey_from_parent_path(extkey: Vec<u8>, path: String) -> Result<Vec<u8>, DLCError> {
1079
+ if extkey.len() != 78 {
1080
+ return Err(DLCError::KeyError(ExtendedKey::InvalidXpriv));
1081
+ }
1079
1082
 
1080
- // App path: {0 || 1}/{child_number}
1081
- let app_path = path
1083
+ let secp = get_secp_context();
1084
+ let xpriv =
1085
+ Xpriv::decode(&extkey).map_err(|_| DLCError::KeyError(ExtendedKey::InvalidXpriv))?;
1086
+
1087
+ let derivation_path = path
1082
1088
  .into_derivation_path()
1083
1089
  .map_err(|_| DLCError::KeyError(ExtendedKey::InvalidDerivationPath))?;
1084
1090
 
1085
- let full_path = base_path.extend(app_path);
1086
-
1087
1091
  let derived_xpriv = xpriv
1088
- .derive_priv(secp, &full_path)
1092
+ .derive_priv(secp, &derivation_path)
1089
1093
  .map_err(|_| DLCError::KeyError(ExtendedKey::InvalidXpriv))?;
1090
1094
 
1091
1095
  Ok(derived_xpriv.encode().to_vec())
1092
1096
  }
1093
1097
 
1098
+ /// Extract public key from extended key (private or public)
1099
+ /// Input: 78-byte encoded xpriv/xpub, Output: 33-byte compressed public key
1100
+ pub fn get_pubkey_from_extkey(extkey: Vec<u8>, network: String) -> Result<Vec<u8>, DLCError> {
1101
+ if extkey.len() != 78 {
1102
+ return Err(DLCError::KeyError(ExtendedKey::InvalidXpriv));
1103
+ }
1104
+
1105
+ let secp = get_secp_context();
1106
+ let _network = Network::from_str(&network).map_err(|_| DLCError::InvalidNetwork)?;
1107
+
1108
+ // Try as xpriv first
1109
+ if let Ok(xpriv) = Xpriv::decode(&extkey) {
1110
+ let xpub = Xpub::from_priv(secp, &xpriv);
1111
+ return Ok(xpub.public_key.serialize().to_vec());
1112
+ }
1113
+
1114
+ // Try as xpub
1115
+ if let Ok(xpub) = Xpub::decode(&extkey) {
1116
+ return Ok(xpub.public_key.serialize().to_vec());
1117
+ }
1118
+
1119
+ Err(DLCError::KeyError(ExtendedKey::InvalidXpriv))
1120
+ }
1121
+
1122
+ /// DEPRECATED: Use create_extkey_from_seed + create_extkey_from_parent_path instead
1123
+ /// This function handles both seeds (64 bytes) and xprivs (78 bytes) which is confusing
1124
+ #[deprecated(
1125
+ since = "0.4.0",
1126
+ note = "Use create_extkey_from_seed + create_extkey_from_parent_path"
1127
+ )]
1128
+ pub fn create_xpriv_from_parent_path(
1129
+ seed_or_xpriv: Vec<u8>,
1130
+ base_derivation_path: String,
1131
+ network: String,
1132
+ path: String,
1133
+ ) -> Result<Vec<u8>, DLCError> {
1134
+ let master_xpriv = if seed_or_xpriv.len() == 64 {
1135
+ // This is a seed, create master xpriv
1136
+ create_extkey_from_seed(seed_or_xpriv, network.clone())?
1137
+ } else if seed_or_xpriv.len() == 78 {
1138
+ // This is already an xpriv
1139
+ seed_or_xpriv
1140
+ } else {
1141
+ return Err(DLCError::KeyError(ExtendedKey::InvalidXpriv));
1142
+ };
1143
+
1144
+ // Derive base path from master
1145
+ let base_xpriv =
1146
+ create_extkey_from_parent_path(master_xpriv, base_derivation_path.replace("m/", ""))?;
1147
+
1148
+ // Derive final path from base
1149
+ create_extkey_from_parent_path(base_xpriv, path)
1150
+ }
1151
+
1152
+ /// Convert extended private key to extended public key
1153
+ /// Input: 78-byte encoded xpriv, Output: 78-byte encoded xpub
1094
1154
  pub fn get_xpub_from_xpriv(xpriv: Vec<u8>, network: String) -> Result<Vec<u8>, DLCError> {
1155
+ if xpriv.len() != 78 {
1156
+ return Err(DLCError::KeyError(ExtendedKey::InvalidXpriv));
1157
+ }
1158
+
1095
1159
  let secp = get_secp_context();
1096
- let network = Network::from_str(&network).map_err(|_| DLCError::InvalidNetwork)?;
1097
- let xpriv = Xpriv::new_master(network, &xpriv)
1098
- .map_err(|_| DLCError::KeyError(ExtendedKey::InvalidXpriv))?;
1160
+ let _network = Network::from_str(&network).map_err(|_| DLCError::InvalidNetwork)?;
1161
+
1162
+ let xpriv = Xpriv::decode(&xpriv).map_err(|_| DLCError::KeyError(ExtendedKey::InvalidXpriv))?;
1163
+
1099
1164
  let xpub = Xpub::from_priv(secp, &xpriv);
1100
1165
  Ok(xpub.encode().to_vec())
1101
1166
  }
@@ -1103,6 +1168,7 @@ pub fn get_xpub_from_xpriv(xpriv: Vec<u8>, network: String) -> Result<Vec<u8>, D
1103
1168
  #[cfg(test)]
1104
1169
  mod tests {
1105
1170
  use super::*;
1171
+ use bitcoin::bip32::DerivationPath;
1106
1172
  use bitcoin::{hashes::sha256, locktime::absolute::LockTime, Address, CompressedPublicKey};
1107
1173
  use ddk_dlc::secp_utils;
1108
1174
  use secp256k1_zkp::{
@@ -1177,7 +1243,11 @@ mod tests {
1177
1243
  let mnemonic = Mnemonic::generate(24).unwrap();
1178
1244
  let rust_xpriv =
1179
1245
  Xpriv::new_master(Network::Bitcoin, &mnemonic.to_seed_normalized("").to_vec()).unwrap();
1180
- let ffi_xpriv = convert_mnemonic_to_seed(mnemonic.to_string(), None).unwrap();
1246
+ let ffi_xpriv = create_extkey_from_seed(
1247
+ mnemonic.to_seed_normalized("").to_vec(),
1248
+ "bitcoin".to_string(),
1249
+ )
1250
+ .unwrap();
1181
1251
  let rust_xpub = Xpub::from_priv(get_secp_context(), &rust_xpriv);
1182
1252
  let ffi_xpub = get_xpub_from_xpriv(ffi_xpriv, "bitcoin".to_string()).unwrap();
1183
1253
  assert_eq!(rust_xpub.encode().to_vec(), ffi_xpub);
@@ -1 +1 @@
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":[]}
1
+ {"version":3,"names":["getter","globalThis","NativeDdkFfi","_default","exports","default","isRustFutureContinuationCallbackTypeCompatible","isUniffiForeignFutureTypeCompatible"],"sourceRoot":"../../src","sources":["ddk_ffi-ffi.ts"],"mappings":";;;;;;AAAA;AACA;;AAsPA;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":[]}
@@ -11,12 +11,15 @@ exports.createCetAdaptorSignatureFromOracleInfo = createCetAdaptorSignatureFromO
11
11
  exports.createCetAdaptorSigsFromOracleInfo = createCetAdaptorSigsFromOracleInfo;
12
12
  exports.createCets = createCets;
13
13
  exports.createDlcTransactions = createDlcTransactions;
14
+ exports.createExtkeyFromParentPath = createExtkeyFromParentPath;
15
+ exports.createExtkeyFromSeed = createExtkeyFromSeed;
14
16
  exports.createFundTxLockingScript = createFundTxLockingScript;
15
17
  exports.createRefundTransaction = createRefundTransaction;
16
18
  exports.createSplicedDlcTransactions = createSplicedDlcTransactions;
17
19
  exports.createXprivFromParentPath = createXprivFromParentPath;
18
20
  exports.default = void 0;
19
21
  exports.getChangeOutputAndFees = getChangeOutputAndFees;
22
+ exports.getPubkeyFromExtkey = getPubkeyFromExtkey;
20
23
  exports.getRawFundingTransactionInputSignature = getRawFundingTransactionInputSignature;
21
24
  exports.getTotalInputVsize = getTotalInputVsize;
22
25
  exports.getXpubFromXpriv = getXpubFromXpriv;
@@ -101,6 +104,22 @@ function createDlcTransactions(outcomes, localParams, remoteParams, refundLockti
101
104
  })()(FfiConverterArrayTypePayout.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);
102
105
  }, /*liftString:*/FfiConverterString.lift));
103
106
  }
107
+ function createExtkeyFromParentPath(extkey, path) /*throws*/{
108
+ return FfiConverterArrayUInt8.lift(uniffiCaller.rustCallWithError(/*liftError:*/FfiConverterTypeDLCError.lift.bind(FfiConverterTypeDLCError), /*caller:*/callStatus => {
109
+ return (() => {
110
+ console.debug(`-- uniffi_ddk_ffi_fn_func_create_extkey_from_parent_path`);
111
+ return (0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_fn_func_create_extkey_from_parent_path;
112
+ })()(FfiConverterArrayUInt8.lower(extkey), FfiConverterString.lower(path), callStatus);
113
+ }, /*liftString:*/FfiConverterString.lift));
114
+ }
115
+ function createExtkeyFromSeed(seed, network) /*throws*/{
116
+ return FfiConverterArrayUInt8.lift(uniffiCaller.rustCallWithError(/*liftError:*/FfiConverterTypeDLCError.lift.bind(FfiConverterTypeDLCError), /*caller:*/callStatus => {
117
+ return (() => {
118
+ console.debug(`-- uniffi_ddk_ffi_fn_func_create_extkey_from_seed`);
119
+ return (0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_fn_func_create_extkey_from_seed;
120
+ })()(FfiConverterArrayUInt8.lower(seed), FfiConverterString.lower(network), callStatus);
121
+ }, /*liftString:*/FfiConverterString.lift));
122
+ }
104
123
  function createFundTxLockingScript(localFundPubkey, remoteFundPubkey) /*throws*/{
105
124
  return FfiConverterArrayUInt8.lift(uniffiCaller.rustCallWithError(/*liftError:*/FfiConverterTypeDLCError.lift.bind(FfiConverterTypeDLCError), /*caller:*/callStatus => {
106
125
  return (() => {
@@ -125,12 +144,12 @@ function createSplicedDlcTransactions(outcomes, localParams, remoteParams, refun
125
144
  })()(FfiConverterArrayTypePayout.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);
126
145
  }, /*liftString:*/FfiConverterString.lift));
127
146
  }
128
- function createXprivFromParentPath(xpriv, baseDerivationPath, network, path) /*throws*/{
147
+ function createXprivFromParentPath(seedOrXpriv, baseDerivationPath, network, path) /*throws*/{
129
148
  return FfiConverterArrayUInt8.lift(uniffiCaller.rustCallWithError(/*liftError:*/FfiConverterTypeDLCError.lift.bind(FfiConverterTypeDLCError), /*caller:*/callStatus => {
130
149
  return (() => {
131
150
  console.debug(`-- uniffi_ddk_ffi_fn_func_create_xpriv_from_parent_path`);
132
151
  return (0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_fn_func_create_xpriv_from_parent_path;
133
- })()(FfiConverterArrayUInt8.lower(xpriv), FfiConverterString.lower(baseDerivationPath), FfiConverterString.lower(network), FfiConverterString.lower(path), callStatus);
152
+ })()(FfiConverterArrayUInt8.lower(seedOrXpriv), FfiConverterString.lower(baseDerivationPath), FfiConverterString.lower(network), FfiConverterString.lower(path), callStatus);
134
153
  }, /*liftString:*/FfiConverterString.lift));
135
154
  }
136
155
  function getChangeOutputAndFees(params, feeRate) /*throws*/{
@@ -141,6 +160,14 @@ function getChangeOutputAndFees(params, feeRate) /*throws*/{
141
160
  })()(FfiConverterTypePartyParams.lower(params), _uniffiBindgenReactNative.FfiConverterUInt64.lower(feeRate), callStatus);
142
161
  }, /*liftString:*/FfiConverterString.lift));
143
162
  }
163
+ function getPubkeyFromExtkey(extkey, network) /*throws*/{
164
+ return FfiConverterArrayUInt8.lift(uniffiCaller.rustCallWithError(/*liftError:*/FfiConverterTypeDLCError.lift.bind(FfiConverterTypeDLCError), /*caller:*/callStatus => {
165
+ return (() => {
166
+ console.debug(`-- uniffi_ddk_ffi_fn_func_get_pubkey_from_extkey`);
167
+ return (0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_fn_func_get_pubkey_from_extkey;
168
+ })()(FfiConverterArrayUInt8.lower(extkey), FfiConverterString.lower(network), callStatus);
169
+ }, /*liftString:*/FfiConverterString.lift));
170
+ }
144
171
  function getRawFundingTransactionInputSignature(fundingTransaction, privkey, prevTxId, prevTxVout, value) /*throws*/{
145
172
  return FfiConverterArrayUInt8.lift(uniffiCaller.rustCallWithError(/*liftError:*/FfiConverterTypeDLCError.lift.bind(FfiConverterTypeDLCError), /*caller:*/callStatus => {
146
173
  return (() => {
@@ -1235,6 +1262,12 @@ function uniffiEnsureInitialized() {
1235
1262
  if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_create_dlc_transactions() !== 29518) {
1236
1263
  throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_create_dlc_transactions');
1237
1264
  }
1265
+ if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_create_extkey_from_parent_path() !== 26671) {
1266
+ throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_create_extkey_from_parent_path');
1267
+ }
1268
+ if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_create_extkey_from_seed() !== 12526) {
1269
+ throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_create_extkey_from_seed');
1270
+ }
1238
1271
  if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_create_fund_tx_locking_script() !== 2761) {
1239
1272
  throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_create_fund_tx_locking_script');
1240
1273
  }
@@ -1244,12 +1277,15 @@ function uniffiEnsureInitialized() {
1244
1277
  if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_create_spliced_dlc_transactions() !== 19497) {
1245
1278
  throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_create_spliced_dlc_transactions');
1246
1279
  }
1247
- if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_create_xpriv_from_parent_path() !== 50010) {
1280
+ if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_create_xpriv_from_parent_path() !== 34808) {
1248
1281
  throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_create_xpriv_from_parent_path');
1249
1282
  }
1250
1283
  if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_get_change_output_and_fees() !== 44150) {
1251
1284
  throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_get_change_output_and_fees');
1252
1285
  }
1286
+ if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_get_pubkey_from_extkey() !== 64637) {
1287
+ throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_get_pubkey_from_extkey');
1288
+ }
1253
1289
  if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_get_raw_funding_transaction_input_signature() !== 35708) {
1254
1290
  throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_get_raw_funding_transaction_input_signature');
1255
1291
  }