@bennyblader/ddk-rn 0.3.1 → 0.3.3
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 +89 -0
- package/cpp/ddk_ffi.hpp +4 -0
- package/ddk-ffi/Cargo.lock +1 -1
- package/ddk-ffi/Cargo.toml +1 -1
- package/ddk-ffi/src/ddk_ffi.udl +20 -0
- package/ddk-ffi/src/lib.rs +130 -0
- package/lib/commonjs/ddk_ffi-ffi.js.map +1 -1
- package/lib/commonjs/ddk_ffi.js +33 -0
- package/lib/commonjs/ddk_ffi.js.map +1 -1
- package/lib/module/ddk_ffi-ffi.js.map +1 -1
- package/lib/module/ddk_ffi.js +31 -0
- package/lib/module/ddk_ffi.js.map +1 -1
- package/lib/typescript/commonjs/src/ddk_ffi-ffi.d.ts +4 -0
- package/lib/typescript/commonjs/src/ddk_ffi-ffi.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/ddk_ffi.d.ts +2 -0
- package/lib/typescript/commonjs/src/ddk_ffi.d.ts.map +1 -1
- package/lib/typescript/module/src/ddk_ffi-ffi.d.ts +4 -0
- package/lib/typescript/module/src/ddk_ffi-ffi.d.ts.map +1 -1
- package/lib/typescript/module/src/ddk_ffi.d.ts +2 -0
- package/lib/typescript/module/src/ddk_ffi.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ddk_ffi-ffi.ts +21 -0
- package/src/ddk_ffi.ts +98 -0
package/cpp/ddk_ffi.cpp
CHANGED
|
@@ -157,6 +157,15 @@ extern "C" {
|
|
|
157
157
|
RustBuffer msgs,
|
|
158
158
|
RustCallStatus *uniffi_out_err
|
|
159
159
|
);
|
|
160
|
+
RustBuffer uniffi_ddk_ffi_fn_func_create_cet_adaptor_sigs_from_oracle_info(
|
|
161
|
+
RustBuffer cets,
|
|
162
|
+
RustBuffer oracle_info,
|
|
163
|
+
RustBuffer funding_secret_key,
|
|
164
|
+
RustBuffer funding_script_pubkey,
|
|
165
|
+
uint64_t fund_output_value,
|
|
166
|
+
RustBuffer msgs,
|
|
167
|
+
RustCallStatus *uniffi_out_err
|
|
168
|
+
);
|
|
160
169
|
RustBuffer uniffi_ddk_ffi_fn_func_create_cets(
|
|
161
170
|
RustBuffer fund_tx_id,
|
|
162
171
|
uint32_t fund_vout,
|
|
@@ -256,6 +265,16 @@ extern "C" {
|
|
|
256
265
|
uint64_t value,
|
|
257
266
|
RustCallStatus *uniffi_out_err
|
|
258
267
|
);
|
|
268
|
+
int8_t uniffi_ddk_ffi_fn_func_verify_cet_adaptor_sig_from_oracle_info(
|
|
269
|
+
RustBuffer adaptor_sig,
|
|
270
|
+
RustBuffer cet,
|
|
271
|
+
RustBuffer oracle_info,
|
|
272
|
+
RustBuffer pubkey,
|
|
273
|
+
RustBuffer funding_script_pubkey,
|
|
274
|
+
uint64_t total_collateral,
|
|
275
|
+
RustBuffer msgs,
|
|
276
|
+
RustCallStatus *uniffi_out_err
|
|
277
|
+
);
|
|
259
278
|
int8_t uniffi_ddk_ffi_fn_func_verify_fund_tx_signature(
|
|
260
279
|
RustBuffer fund_tx,
|
|
261
280
|
RustBuffer signature,
|
|
@@ -485,6 +504,8 @@ extern "C" {
|
|
|
485
504
|
);
|
|
486
505
|
uint16_t uniffi_ddk_ffi_checksum_func_create_cet_adaptor_signature_from_oracle_info(
|
|
487
506
|
);
|
|
507
|
+
uint16_t uniffi_ddk_ffi_checksum_func_create_cet_adaptor_sigs_from_oracle_info(
|
|
508
|
+
);
|
|
488
509
|
uint16_t uniffi_ddk_ffi_checksum_func_create_cets(
|
|
489
510
|
);
|
|
490
511
|
uint16_t uniffi_ddk_ffi_checksum_func_create_dlc_transactions(
|
|
@@ -511,6 +532,8 @@ extern "C" {
|
|
|
511
532
|
);
|
|
512
533
|
uint16_t uniffi_ddk_ffi_checksum_func_sign_fund_transaction_input(
|
|
513
534
|
);
|
|
535
|
+
uint16_t uniffi_ddk_ffi_checksum_func_verify_cet_adaptor_sig_from_oracle_info(
|
|
536
|
+
);
|
|
514
537
|
uint16_t uniffi_ddk_ffi_checksum_func_verify_fund_tx_signature(
|
|
515
538
|
);
|
|
516
539
|
uint16_t uniffi_ddk_ffi_checksum_func_version(
|
|
@@ -2083,6 +2106,14 @@ NativeDdkFfi::NativeDdkFfi(
|
|
|
2083
2106
|
return this->cpp_uniffi_ddk_ffi_fn_func_create_cet_adaptor_signature_from_oracle_info(rt, thisVal, args, count);
|
|
2084
2107
|
}
|
|
2085
2108
|
);
|
|
2109
|
+
props["ubrn_uniffi_ddk_ffi_fn_func_create_cet_adaptor_sigs_from_oracle_info"] = jsi::Function::createFromHostFunction(
|
|
2110
|
+
rt,
|
|
2111
|
+
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_fn_func_create_cet_adaptor_sigs_from_oracle_info"),
|
|
2112
|
+
6,
|
|
2113
|
+
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
|
|
2114
|
+
return this->cpp_uniffi_ddk_ffi_fn_func_create_cet_adaptor_sigs_from_oracle_info(rt, thisVal, args, count);
|
|
2115
|
+
}
|
|
2116
|
+
);
|
|
2086
2117
|
props["ubrn_uniffi_ddk_ffi_fn_func_create_cets"] = jsi::Function::createFromHostFunction(
|
|
2087
2118
|
rt,
|
|
2088
2119
|
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_fn_func_create_cets"),
|
|
@@ -2187,6 +2218,14 @@ NativeDdkFfi::NativeDdkFfi(
|
|
|
2187
2218
|
return this->cpp_uniffi_ddk_ffi_fn_func_sign_fund_transaction_input(rt, thisVal, args, count);
|
|
2188
2219
|
}
|
|
2189
2220
|
);
|
|
2221
|
+
props["ubrn_uniffi_ddk_ffi_fn_func_verify_cet_adaptor_sig_from_oracle_info"] = jsi::Function::createFromHostFunction(
|
|
2222
|
+
rt,
|
|
2223
|
+
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_fn_func_verify_cet_adaptor_sig_from_oracle_info"),
|
|
2224
|
+
7,
|
|
2225
|
+
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
|
|
2226
|
+
return this->cpp_uniffi_ddk_ffi_fn_func_verify_cet_adaptor_sig_from_oracle_info(rt, thisVal, args, count);
|
|
2227
|
+
}
|
|
2228
|
+
);
|
|
2190
2229
|
props["ubrn_uniffi_ddk_ffi_fn_func_verify_fund_tx_signature"] = jsi::Function::createFromHostFunction(
|
|
2191
2230
|
rt,
|
|
2192
2231
|
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_fn_func_verify_fund_tx_signature"),
|
|
@@ -2227,6 +2266,14 @@ NativeDdkFfi::NativeDdkFfi(
|
|
|
2227
2266
|
return this->cpp_uniffi_ddk_ffi_checksum_func_create_cet_adaptor_signature_from_oracle_info(rt, thisVal, args, count);
|
|
2228
2267
|
}
|
|
2229
2268
|
);
|
|
2269
|
+
props["ubrn_uniffi_ddk_ffi_checksum_func_create_cet_adaptor_sigs_from_oracle_info"] = jsi::Function::createFromHostFunction(
|
|
2270
|
+
rt,
|
|
2271
|
+
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_checksum_func_create_cet_adaptor_sigs_from_oracle_info"),
|
|
2272
|
+
0,
|
|
2273
|
+
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
|
|
2274
|
+
return this->cpp_uniffi_ddk_ffi_checksum_func_create_cet_adaptor_sigs_from_oracle_info(rt, thisVal, args, count);
|
|
2275
|
+
}
|
|
2276
|
+
);
|
|
2230
2277
|
props["ubrn_uniffi_ddk_ffi_checksum_func_create_cets"] = jsi::Function::createFromHostFunction(
|
|
2231
2278
|
rt,
|
|
2232
2279
|
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_checksum_func_create_cets"),
|
|
@@ -2331,6 +2378,14 @@ NativeDdkFfi::NativeDdkFfi(
|
|
|
2331
2378
|
return this->cpp_uniffi_ddk_ffi_checksum_func_sign_fund_transaction_input(rt, thisVal, args, count);
|
|
2332
2379
|
}
|
|
2333
2380
|
);
|
|
2381
|
+
props["ubrn_uniffi_ddk_ffi_checksum_func_verify_cet_adaptor_sig_from_oracle_info"] = jsi::Function::createFromHostFunction(
|
|
2382
|
+
rt,
|
|
2383
|
+
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_checksum_func_verify_cet_adaptor_sig_from_oracle_info"),
|
|
2384
|
+
0,
|
|
2385
|
+
[this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
|
|
2386
|
+
return this->cpp_uniffi_ddk_ffi_checksum_func_verify_cet_adaptor_sig_from_oracle_info(rt, thisVal, args, count);
|
|
2387
|
+
}
|
|
2388
|
+
);
|
|
2334
2389
|
props["ubrn_uniffi_ddk_ffi_checksum_func_verify_fund_tx_signature"] = jsi::Function::createFromHostFunction(
|
|
2335
2390
|
rt,
|
|
2336
2391
|
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_ddk_ffi_checksum_func_verify_fund_tx_signature"),
|
|
@@ -2438,6 +2493,16 @@ jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_fn_func_create_cet_adaptor_signature
|
|
|
2438
2493
|
uniffi::ddk_ffi::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
|
|
2439
2494
|
|
|
2440
2495
|
|
|
2496
|
+
return uniffi::ddk_ffi::Bridging<RustBuffer>::toJs(rt, callInvoker, value);
|
|
2497
|
+
}
|
|
2498
|
+
jsi::Value NativeDdkFfi::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) {
|
|
2499
|
+
RustCallStatus status = uniffi::ddk_ffi::Bridging<RustCallStatus>::rustSuccess(rt);
|
|
2500
|
+
auto value = uniffi_ddk_ffi_fn_func_create_cet_adaptor_sigs_from_oracle_info(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]), uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[4]), uniffi::ddk_ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[5]),
|
|
2501
|
+
&status
|
|
2502
|
+
);
|
|
2503
|
+
uniffi::ddk_ffi::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
|
|
2504
|
+
|
|
2505
|
+
|
|
2441
2506
|
return uniffi::ddk_ffi::Bridging<RustBuffer>::toJs(rt, callInvoker, value);
|
|
2442
2507
|
}
|
|
2443
2508
|
jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_fn_func_create_cets(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
|
|
@@ -2570,6 +2635,16 @@ jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_fn_func_sign_fund_transaction_input(
|
|
|
2570
2635
|
|
|
2571
2636
|
return uniffi::ddk_ffi::Bridging<RustBuffer>::toJs(rt, callInvoker, value);
|
|
2572
2637
|
}
|
|
2638
|
+
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) {
|
|
2639
|
+
RustCallStatus status = uniffi::ddk_ffi::Bridging<RustCallStatus>::rustSuccess(rt);
|
|
2640
|
+
auto value = uniffi_ddk_ffi_fn_func_verify_cet_adaptor_sig_from_oracle_info(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]), uniffi::ddk_ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[4]), uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[5]), uniffi::ddk_ffi::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[6]),
|
|
2641
|
+
&status
|
|
2642
|
+
);
|
|
2643
|
+
uniffi::ddk_ffi::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
|
|
2644
|
+
|
|
2645
|
+
|
|
2646
|
+
return uniffi_jsi::Bridging<int8_t>::toJs(rt, callInvoker, value);
|
|
2647
|
+
}
|
|
2573
2648
|
jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_fn_func_verify_fund_tx_signature(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
|
|
2574
2649
|
RustCallStatus status = uniffi::ddk_ffi::Bridging<RustCallStatus>::rustSuccess(rt);
|
|
2575
2650
|
auto value = uniffi_ddk_ffi_fn_func_verify_fund_tx_signature(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]), uniffi_jsi::Bridging<uint32_t>::fromJs(rt, callInvoker, args[4]), uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[5]),
|
|
@@ -2608,6 +2683,13 @@ jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_checksum_func_create_cet_adaptor_sig
|
|
|
2608
2683
|
);
|
|
2609
2684
|
|
|
2610
2685
|
|
|
2686
|
+
return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
|
|
2687
|
+
}
|
|
2688
|
+
jsi::Value NativeDdkFfi::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) {
|
|
2689
|
+
auto value = uniffi_ddk_ffi_checksum_func_create_cet_adaptor_sigs_from_oracle_info(
|
|
2690
|
+
);
|
|
2691
|
+
|
|
2692
|
+
|
|
2611
2693
|
return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
|
|
2612
2694
|
}
|
|
2613
2695
|
jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_checksum_func_create_cets(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
|
|
@@ -2699,6 +2781,13 @@ jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_checksum_func_sign_fund_transaction_
|
|
|
2699
2781
|
);
|
|
2700
2782
|
|
|
2701
2783
|
|
|
2784
|
+
return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
|
|
2785
|
+
}
|
|
2786
|
+
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) {
|
|
2787
|
+
auto value = uniffi_ddk_ffi_checksum_func_verify_cet_adaptor_sig_from_oracle_info(
|
|
2788
|
+
);
|
|
2789
|
+
|
|
2790
|
+
|
|
2702
2791
|
return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
|
|
2703
2792
|
}
|
|
2704
2793
|
jsi::Value NativeDdkFfi::cpp_uniffi_ddk_ffi_checksum_func_verify_fund_tx_signature(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
|
package/cpp/ddk_ffi.hpp
CHANGED
|
@@ -24,6 +24,7 @@ class NativeDdkFfi : public jsi::HostObject {
|
|
|
24
24
|
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
25
|
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
26
|
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);
|
|
27
|
+
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);
|
|
27
28
|
jsi::Value cpp_uniffi_ddk_ffi_fn_func_create_cets(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
28
29
|
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);
|
|
29
30
|
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);
|
|
@@ -37,11 +38,13 @@ class NativeDdkFfi : public jsi::HostObject {
|
|
|
37
38
|
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);
|
|
38
39
|
jsi::Value cpp_uniffi_ddk_ffi_fn_func_sign_cet(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_fund_transaction_input(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
41
|
+
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);
|
|
40
42
|
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);
|
|
41
43
|
jsi::Value cpp_uniffi_ddk_ffi_fn_func_version(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
42
44
|
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);
|
|
43
45
|
jsi::Value cpp_uniffi_ddk_ffi_checksum_func_create_cet(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
44
46
|
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);
|
|
47
|
+
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);
|
|
45
48
|
jsi::Value cpp_uniffi_ddk_ffi_checksum_func_create_cets(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_dlc_transactions(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_fund_tx_locking_script(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
@@ -55,6 +58,7 @@ class NativeDdkFfi : public jsi::HostObject {
|
|
|
55
58
|
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);
|
|
56
59
|
jsi::Value cpp_uniffi_ddk_ffi_checksum_func_sign_cet(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
57
60
|
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);
|
|
61
|
+
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);
|
|
58
62
|
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);
|
|
59
63
|
jsi::Value cpp_uniffi_ddk_ffi_checksum_func_version(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
60
64
|
jsi::Value cpp_ffi_ddk_ffi_uniffi_contract_version(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
package/ddk-ffi/Cargo.lock
CHANGED
package/ddk-ffi/Cargo.toml
CHANGED
package/ddk-ffi/src/ddk_ffi.udl
CHANGED
|
@@ -109,6 +109,26 @@ namespace ddk_ffi {
|
|
|
109
109
|
sequence<u8> funding_script_pubkey,
|
|
110
110
|
u64 fund_output_value
|
|
111
111
|
);
|
|
112
|
+
|
|
113
|
+
[Throws=DLCError]
|
|
114
|
+
sequence<AdaptorSignature> create_cet_adaptor_sigs_from_oracle_info(
|
|
115
|
+
sequence<Transaction> cets,
|
|
116
|
+
sequence<OracleInfo> oracle_info,
|
|
117
|
+
sequence<u8> funding_secret_key,
|
|
118
|
+
sequence<u8> funding_script_pubkey,
|
|
119
|
+
u64 fund_output_value,
|
|
120
|
+
sequence<sequence<sequence<u8>>> msgs
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
boolean verify_cet_adaptor_sig_from_oracle_info(
|
|
124
|
+
AdaptorSignature adaptor_sig,
|
|
125
|
+
Transaction cet,
|
|
126
|
+
sequence<OracleInfo> oracle_info,
|
|
127
|
+
sequence<u8> pubkey,
|
|
128
|
+
sequence<u8> funding_script_pubkey,
|
|
129
|
+
u64 total_collateral,
|
|
130
|
+
sequence<sequence<sequence<u8>>> msgs
|
|
131
|
+
);
|
|
112
132
|
|
|
113
133
|
// Signing Functions
|
|
114
134
|
[Throws=DLCError]
|
package/ddk-ffi/src/lib.rs
CHANGED
|
@@ -743,6 +743,136 @@ fn vec_to_ecdsa_adaptor_signature(signature: Vec<u8>) -> Result<EcdsaAdaptorSign
|
|
|
743
743
|
EcdsaAdaptorSignature::from_slice(&signature).map_err(|_| DLCError::InvalidSignature)
|
|
744
744
|
}
|
|
745
745
|
|
|
746
|
+
pub fn create_cet_adaptor_sigs_from_oracle_info(
|
|
747
|
+
cets: Vec<Transaction>,
|
|
748
|
+
oracle_info: Vec<OracleInfo>,
|
|
749
|
+
funding_secret_key: Vec<u8>,
|
|
750
|
+
funding_script_pubkey: Vec<u8>,
|
|
751
|
+
fund_output_value: u64,
|
|
752
|
+
msgs: Vec<Vec<Vec<u8>>>,
|
|
753
|
+
) -> Result<Vec<AdaptorSignature>, DLCError> {
|
|
754
|
+
if msgs.len() != cets.len() {
|
|
755
|
+
return Err(DLCError::InvalidArgument);
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
let cets = cets
|
|
759
|
+
.iter()
|
|
760
|
+
.map(|cet| transaction_to_btc_tx(cet))
|
|
761
|
+
.collect::<Result<Vec<_>, _>>()?;
|
|
762
|
+
let oracle_infos = oracle_info
|
|
763
|
+
.iter()
|
|
764
|
+
.map(|info| {
|
|
765
|
+
let public_key = XOnlyPublicKey::from_slice(&info.public_key)?;
|
|
766
|
+
let nonces = info
|
|
767
|
+
.nonces
|
|
768
|
+
.iter()
|
|
769
|
+
.map(|nonce| XOnlyPublicKey::from_slice(nonce))
|
|
770
|
+
.collect::<Result<Vec<_>, _>>()?;
|
|
771
|
+
Ok(DlcOracleInfo { public_key, nonces })
|
|
772
|
+
})
|
|
773
|
+
.collect::<Result<Vec<_>, dlc::Error>>()
|
|
774
|
+
.map_err(|_| DLCError::InvalidArgument)?;
|
|
775
|
+
|
|
776
|
+
let funding_sk =
|
|
777
|
+
SecretKey::from_slice(&funding_secret_key).map_err(|_| DLCError::InvalidArgument)?;
|
|
778
|
+
let funding_script = Script::from_bytes(&funding_script_pubkey);
|
|
779
|
+
let msgs = msgs
|
|
780
|
+
.iter()
|
|
781
|
+
.map(|msg| {
|
|
782
|
+
msg.iter()
|
|
783
|
+
.map(|m| Message::from_digest_slice(m).map_err(|_| DLCError::InvalidArgument))
|
|
784
|
+
.collect::<Result<Vec<_>, _>>()
|
|
785
|
+
})
|
|
786
|
+
.collect::<Result<Vec<_>, _>>()?;
|
|
787
|
+
let secp = get_secp_context();
|
|
788
|
+
|
|
789
|
+
let adaptor_sigs = dlc::create_cet_adaptor_sigs_from_oracle_info(
|
|
790
|
+
secp,
|
|
791
|
+
&cets,
|
|
792
|
+
&oracle_infos,
|
|
793
|
+
&funding_sk,
|
|
794
|
+
&funding_script,
|
|
795
|
+
Amount::from_sat(fund_output_value),
|
|
796
|
+
&[msgs],
|
|
797
|
+
)
|
|
798
|
+
.map_err(|_| DLCError::InvalidSignature)?;
|
|
799
|
+
|
|
800
|
+
let adaptor_sigs = adaptor_sigs
|
|
801
|
+
.iter()
|
|
802
|
+
.map(|sig| AdaptorSignature {
|
|
803
|
+
signature: sig.as_ref().to_vec(),
|
|
804
|
+
proof: Vec::new(),
|
|
805
|
+
})
|
|
806
|
+
.collect::<Vec<_>>();
|
|
807
|
+
|
|
808
|
+
Ok(adaptor_sigs)
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
pub fn verify_cet_adaptor_sig_from_oracle_info(
|
|
812
|
+
adaptor_sig: AdaptorSignature,
|
|
813
|
+
cet: Transaction,
|
|
814
|
+
oracle_infos: Vec<OracleInfo>,
|
|
815
|
+
pubkey: Vec<u8>,
|
|
816
|
+
funding_script_pubkey: Vec<u8>,
|
|
817
|
+
total_collateral: u64,
|
|
818
|
+
msgs: Vec<Vec<Vec<u8>>>,
|
|
819
|
+
) -> bool {
|
|
820
|
+
let secp = get_secp_context();
|
|
821
|
+
let Ok(btc_tx) = transaction_to_btc_tx(&cet) else {
|
|
822
|
+
return false;
|
|
823
|
+
};
|
|
824
|
+
let Ok(adaptor_sig) = vec_to_ecdsa_adaptor_signature(adaptor_sig.signature) else {
|
|
825
|
+
return false;
|
|
826
|
+
};
|
|
827
|
+
let Ok(oracle_infos) = oracle_infos
|
|
828
|
+
.iter()
|
|
829
|
+
.map(|info| {
|
|
830
|
+
let public_key = XOnlyPublicKey::from_slice(&info.public_key)?;
|
|
831
|
+
let nonces = info
|
|
832
|
+
.nonces
|
|
833
|
+
.iter()
|
|
834
|
+
.map(|nonce| XOnlyPublicKey::from_slice(nonce))
|
|
835
|
+
.collect::<Result<Vec<_>, _>>()?;
|
|
836
|
+
Ok(DlcOracleInfo { public_key, nonces })
|
|
837
|
+
})
|
|
838
|
+
.collect::<Result<Vec<_>, dlc::Error>>()
|
|
839
|
+
else {
|
|
840
|
+
return false;
|
|
841
|
+
};
|
|
842
|
+
let Ok(pubkey) = PublicKey::from_slice(&pubkey) else {
|
|
843
|
+
return false;
|
|
844
|
+
};
|
|
845
|
+
let funding_script = Script::from_bytes(&funding_script_pubkey);
|
|
846
|
+
let Ok(msgs) = msgs
|
|
847
|
+
.into_iter()
|
|
848
|
+
.map(|msg| {
|
|
849
|
+
msg.iter()
|
|
850
|
+
.map(|m| Message::from_digest_slice(m).map_err(|_| DLCError::InvalidArgument))
|
|
851
|
+
.collect::<Result<Vec<_>, _>>()
|
|
852
|
+
})
|
|
853
|
+
.collect::<Result<Vec<_>, _>>()
|
|
854
|
+
else {
|
|
855
|
+
return false;
|
|
856
|
+
};
|
|
857
|
+
let Ok(adaptor_point) = dlc::get_adaptor_point_from_oracle_info(secp, &oracle_infos, &msgs)
|
|
858
|
+
else {
|
|
859
|
+
return false;
|
|
860
|
+
};
|
|
861
|
+
let Ok(_) = dlc::verify_cet_adaptor_sig_from_point(
|
|
862
|
+
secp,
|
|
863
|
+
&adaptor_sig,
|
|
864
|
+
&btc_tx,
|
|
865
|
+
&adaptor_point,
|
|
866
|
+
&pubkey,
|
|
867
|
+
&funding_script,
|
|
868
|
+
Amount::from_sat(total_collateral),
|
|
869
|
+
) else {
|
|
870
|
+
return false;
|
|
871
|
+
};
|
|
872
|
+
|
|
873
|
+
true
|
|
874
|
+
}
|
|
875
|
+
|
|
746
876
|
/// Create CET adaptor signature from oracle info
|
|
747
877
|
pub fn create_cet_adaptor_signature_from_oracle_info(
|
|
748
878
|
cet: Transaction,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getter","globalThis","NativeDdkFfi","_default","exports","default","isRustFutureContinuationCallbackTypeCompatible","isUniffiForeignFutureTypeCompatible"],"sourceRoot":"../../src","sources":["ddk_ffi-ffi.ts"],"mappings":";;;;;;AAAA;AACA;;
|
|
1
|
+
{"version":3,"names":["getter","globalThis","NativeDdkFfi","_default","exports","default","isRustFutureContinuationCallbackTypeCompatible","isUniffiForeignFutureTypeCompatible"],"sourceRoot":"../../src","sources":["ddk_ffi-ffi.ts"],"mappings":";;;;;;AAAA;AACA;;AAyMA;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":[]}
|
package/lib/commonjs/ddk_ffi.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.TxOutput = exports.TxInputInfo = exports.TxInput = exports.Transaction =
|
|
|
7
7
|
exports.convertMnemonicToSeed = convertMnemonicToSeed;
|
|
8
8
|
exports.createCet = createCet;
|
|
9
9
|
exports.createCetAdaptorSignatureFromOracleInfo = createCetAdaptorSignatureFromOracleInfo;
|
|
10
|
+
exports.createCetAdaptorSigsFromOracleInfo = createCetAdaptorSigsFromOracleInfo;
|
|
10
11
|
exports.createCets = createCets;
|
|
11
12
|
exports.createDlcTransactions = createDlcTransactions;
|
|
12
13
|
exports.createFundTxLockingScript = createFundTxLockingScript;
|
|
@@ -21,6 +22,7 @@ exports.getXpubFromXpriv = getXpubFromXpriv;
|
|
|
21
22
|
exports.isDustOutput = isDustOutput;
|
|
22
23
|
exports.signCet = signCet;
|
|
23
24
|
exports.signFundTransactionInput = signFundTransactionInput;
|
|
25
|
+
exports.verifyCetAdaptorSigFromOracleInfo = verifyCetAdaptorSigFromOracleInfo;
|
|
24
26
|
exports.verifyFundTxSignature = verifyFundTxSignature;
|
|
25
27
|
exports.version = version;
|
|
26
28
|
var _ddk_ffiFfi = _interopRequireDefault(require("./ddk_ffi-ffi.js"));
|
|
@@ -64,6 +66,14 @@ function createCetAdaptorSignatureFromOracleInfo(cet, oracleInfo, fundingSk, fun
|
|
|
64
66
|
})()(FfiConverterTypeTransaction.lower(cet), FfiConverterTypeOracleInfo.lower(oracleInfo), FfiConverterArrayUInt8.lower(fundingSk), FfiConverterArrayUInt8.lower(fundingScriptPubkey), _uniffiBindgenReactNative.FfiConverterUInt64.lower(totalCollateral), FfiConverterArrayArrayUInt8.lower(msgs), callStatus);
|
|
65
67
|
}, /*liftString:*/FfiConverterString.lift));
|
|
66
68
|
}
|
|
69
|
+
function createCetAdaptorSigsFromOracleInfo(cets, oracleInfo, fundingSecretKey, fundingScriptPubkey, fundOutputValue, msgs) /*throws*/{
|
|
70
|
+
return FfiConverterArrayTypeAdaptorSignature.lift(uniffiCaller.rustCallWithError(/*liftError:*/FfiConverterTypeDLCError.lift.bind(FfiConverterTypeDLCError), /*caller:*/callStatus => {
|
|
71
|
+
return (() => {
|
|
72
|
+
console.debug(`-- uniffi_ddk_ffi_fn_func_create_cet_adaptor_sigs_from_oracle_info`);
|
|
73
|
+
return (0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_fn_func_create_cet_adaptor_sigs_from_oracle_info;
|
|
74
|
+
})()(FfiConverterArrayTypeTransaction.lower(cets), FfiConverterArrayTypeOracleInfo.lower(oracleInfo), FfiConverterArrayUInt8.lower(fundingSecretKey), FfiConverterArrayUInt8.lower(fundingScriptPubkey), _uniffiBindgenReactNative.FfiConverterUInt64.lower(fundOutputValue), FfiConverterArrayArrayArrayUInt8.lower(msgs), callStatus);
|
|
75
|
+
}, /*liftString:*/FfiConverterString.lift));
|
|
76
|
+
}
|
|
67
77
|
function createCets(fundTxId, fundVout, localFinalScriptPubkey, remoteFinalScriptPubkey, outcomes, lockTime, localSerialId, remoteSerialId) /*throws*/{
|
|
68
78
|
return FfiConverterArrayTypeTransaction.lift(uniffiCaller.rustCallWithError(/*liftError:*/FfiConverterTypeDLCError.lift.bind(FfiConverterTypeDLCError), /*caller:*/callStatus => {
|
|
69
79
|
return (() => {
|
|
@@ -168,6 +178,14 @@ function signFundTransactionInput(fundTransaction, privkey, prevTxId, prevTxVout
|
|
|
168
178
|
})()(FfiConverterTypeTransaction.lower(fundTransaction), FfiConverterArrayUInt8.lower(privkey), FfiConverterString.lower(prevTxId), _uniffiBindgenReactNative.FfiConverterUInt32.lower(prevTxVout), _uniffiBindgenReactNative.FfiConverterUInt64.lower(value), callStatus);
|
|
169
179
|
}, /*liftString:*/FfiConverterString.lift));
|
|
170
180
|
}
|
|
181
|
+
function verifyCetAdaptorSigFromOracleInfo(adaptorSig, cet, oracleInfo, pubkey, fundingScriptPubkey, totalCollateral, msgs) {
|
|
182
|
+
return _uniffiBindgenReactNative.FfiConverterBool.lift(uniffiCaller.rustCall(/*caller:*/callStatus => {
|
|
183
|
+
return (() => {
|
|
184
|
+
console.debug(`-- uniffi_ddk_ffi_fn_func_verify_cet_adaptor_sig_from_oracle_info`);
|
|
185
|
+
return (0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_fn_func_verify_cet_adaptor_sig_from_oracle_info;
|
|
186
|
+
})()(FfiConverterTypeAdaptorSignature.lower(adaptorSig), FfiConverterTypeTransaction.lower(cet), FfiConverterArrayTypeOracleInfo.lower(oracleInfo), FfiConverterArrayUInt8.lower(pubkey), FfiConverterArrayUInt8.lower(fundingScriptPubkey), _uniffiBindgenReactNative.FfiConverterUInt64.lower(totalCollateral), FfiConverterArrayArrayArrayUInt8.lower(msgs), callStatus);
|
|
187
|
+
}, /*liftString:*/FfiConverterString.lift));
|
|
188
|
+
}
|
|
171
189
|
function verifyFundTxSignature(fundTx, signature, pubkey, txid, vout, inputAmount) /*throws*/{
|
|
172
190
|
return _uniffiBindgenReactNative.FfiConverterBool.lift(uniffiCaller.rustCallWithError(/*liftError:*/FfiConverterTypeDLCError.lift.bind(FfiConverterTypeDLCError), /*caller:*/callStatus => {
|
|
173
191
|
return (() => {
|
|
@@ -1158,12 +1176,18 @@ const FfiConverterTypeExtendedKey = (() => {
|
|
|
1158
1176
|
// FfiConverter for string | undefined
|
|
1159
1177
|
const FfiConverterOptionalString = new _uniffiBindgenReactNative.FfiConverterOptional(FfiConverterString);
|
|
1160
1178
|
|
|
1179
|
+
// FfiConverter for Array<AdaptorSignature>
|
|
1180
|
+
const FfiConverterArrayTypeAdaptorSignature = new _uniffiBindgenReactNative.FfiConverterArray(FfiConverterTypeAdaptorSignature);
|
|
1181
|
+
|
|
1161
1182
|
// FfiConverter for Array<DlcInputInfo>
|
|
1162
1183
|
const FfiConverterArrayTypeDlcInputInfo = new _uniffiBindgenReactNative.FfiConverterArray(FfiConverterTypeDlcInputInfo);
|
|
1163
1184
|
|
|
1164
1185
|
// FfiConverter for Array<DlcOutcome>
|
|
1165
1186
|
const FfiConverterArrayTypeDlcOutcome = new _uniffiBindgenReactNative.FfiConverterArray(FfiConverterTypeDlcOutcome);
|
|
1166
1187
|
|
|
1188
|
+
// FfiConverter for Array<OracleInfo>
|
|
1189
|
+
const FfiConverterArrayTypeOracleInfo = new _uniffiBindgenReactNative.FfiConverterArray(FfiConverterTypeOracleInfo);
|
|
1190
|
+
|
|
1167
1191
|
// FfiConverter for Array<Transaction>
|
|
1168
1192
|
const FfiConverterArrayTypeTransaction = new _uniffiBindgenReactNative.FfiConverterArray(FfiConverterTypeTransaction);
|
|
1169
1193
|
|
|
@@ -1182,6 +1206,9 @@ const FfiConverterArrayUInt8 = new _uniffiBindgenReactNative.FfiConverterArray(_
|
|
|
1182
1206
|
// FfiConverter for Array<Array</*u8*/number>>
|
|
1183
1207
|
const FfiConverterArrayArrayUInt8 = new _uniffiBindgenReactNative.FfiConverterArray(FfiConverterArrayUInt8);
|
|
1184
1208
|
|
|
1209
|
+
// FfiConverter for Array<Array<Array</*u8*/number>>>
|
|
1210
|
+
const FfiConverterArrayArrayArrayUInt8 = new _uniffiBindgenReactNative.FfiConverterArray(FfiConverterArrayArrayUInt8);
|
|
1211
|
+
|
|
1185
1212
|
/**
|
|
1186
1213
|
* This should be called before anything else.
|
|
1187
1214
|
*
|
|
@@ -1209,6 +1236,9 @@ function uniffiEnsureInitialized() {
|
|
|
1209
1236
|
if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_create_cet_adaptor_signature_from_oracle_info() !== 65174) {
|
|
1210
1237
|
throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_create_cet_adaptor_signature_from_oracle_info');
|
|
1211
1238
|
}
|
|
1239
|
+
if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_create_cet_adaptor_sigs_from_oracle_info() !== 59405) {
|
|
1240
|
+
throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_create_cet_adaptor_sigs_from_oracle_info');
|
|
1241
|
+
}
|
|
1212
1242
|
if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_create_cets() !== 45293) {
|
|
1213
1243
|
throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_create_cets');
|
|
1214
1244
|
}
|
|
@@ -1248,6 +1278,9 @@ function uniffiEnsureInitialized() {
|
|
|
1248
1278
|
if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_sign_fund_transaction_input() !== 50531) {
|
|
1249
1279
|
throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_sign_fund_transaction_input');
|
|
1250
1280
|
}
|
|
1281
|
+
if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_verify_cet_adaptor_sig_from_oracle_info() !== 52232) {
|
|
1282
|
+
throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_verify_cet_adaptor_sig_from_oracle_info');
|
|
1283
|
+
}
|
|
1251
1284
|
if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_verify_fund_tx_signature() !== 27316) {
|
|
1252
1285
|
throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_verify_fund_tx_signature');
|
|
1253
1286
|
}
|