@bennyblader/ddk-rn 0.3.20 → 0.3.22
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/ddk-ffi/Cargo.lock +13 -12
- package/ddk-ffi/Cargo.toml +4 -3
- package/ddk-ffi/src/lib.rs +30 -30
- package/package.json +1 -1
package/ddk-ffi/Cargo.lock
CHANGED
|
@@ -281,27 +281,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
|
281
281
|
checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675"
|
|
282
282
|
|
|
283
283
|
[[package]]
|
|
284
|
-
name = "
|
|
285
|
-
version = "0.
|
|
284
|
+
name = "ddk-dlc"
|
|
285
|
+
version = "0.0.21"
|
|
286
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
287
|
+
checksum = "cd81ea804b1fe6ad44621b79db9261b7a595e0c41e9fb33642ec4798100eeff7"
|
|
286
288
|
dependencies = [
|
|
287
|
-
"bip39",
|
|
288
289
|
"bitcoin",
|
|
289
|
-
"
|
|
290
|
+
"miniscript",
|
|
291
|
+
"secp256k1-sys",
|
|
290
292
|
"secp256k1-zkp",
|
|
291
|
-
"
|
|
292
|
-
"uniffi",
|
|
293
|
+
"serde",
|
|
293
294
|
]
|
|
294
295
|
|
|
295
296
|
[[package]]
|
|
296
|
-
name = "
|
|
297
|
-
version = "0.
|
|
298
|
-
source = "git+https://github.com/bennyhodl/dlcdevkit.git?branch=master#95e7450cf9254ac8d872ad8c4a2491cb26500e19"
|
|
297
|
+
name = "ddk_ffi"
|
|
298
|
+
version = "0.3.22"
|
|
299
299
|
dependencies = [
|
|
300
|
+
"bip39",
|
|
300
301
|
"bitcoin",
|
|
301
|
-
"
|
|
302
|
-
"secp256k1-sys",
|
|
302
|
+
"ddk-dlc",
|
|
303
303
|
"secp256k1-zkp",
|
|
304
|
-
"
|
|
304
|
+
"thiserror",
|
|
305
|
+
"uniffi",
|
|
305
306
|
]
|
|
306
307
|
|
|
307
308
|
[[package]]
|
package/ddk-ffi/Cargo.toml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "ddk_ffi"
|
|
3
|
-
version = "0.3.
|
|
3
|
+
version = "0.3.22"
|
|
4
4
|
edition = "2021"
|
|
5
5
|
license = "MIT"
|
|
6
6
|
description = "rust-dlc language bindings"
|
|
@@ -14,8 +14,9 @@ crate-type = ["cdylib", "staticlib", "rlib"]
|
|
|
14
14
|
|
|
15
15
|
[dependencies]
|
|
16
16
|
uniffi = { version = "0.29.4", features = ["cli"] }
|
|
17
|
-
# dlc = { path = "../../../ernest/dlcdevkit/dlc", features = ["use-serde"] }
|
|
18
|
-
dlc = { git = "https://github.com/bennyhodl/dlcdevkit.git", branch = "master", features = ["use-serde"] }
|
|
17
|
+
# ddk-dlc = { path = "../../../ernest/dlcdevkit/dlc", features = ["use-serde"] }
|
|
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
20
|
bitcoin = "0.32.7"
|
|
20
21
|
thiserror = "2.0.12"
|
|
21
22
|
secp256k1-zkp = "0.11.0"
|
package/ddk-ffi/src/lib.rs
CHANGED
|
@@ -8,7 +8,7 @@ use bitcoin::{
|
|
|
8
8
|
TxOut as BtcTxOut, Txid, Witness,
|
|
9
9
|
};
|
|
10
10
|
use bitcoin::{Script, WPubkeyHash};
|
|
11
|
-
use
|
|
11
|
+
use ddk_dlc::{
|
|
12
12
|
self, dlc_input::DlcInputInfo as RustDlcInputInfo, DlcTransactions as RustDlcTransactions,
|
|
13
13
|
OracleInfo as DlcOracleInfo, PartyParams as DlcPartyParams, Payout as DlcPayout,
|
|
14
14
|
TxInputInfo as DlcTxInputInfo,
|
|
@@ -78,16 +78,16 @@ pub enum ExtendedKey {
|
|
|
78
78
|
InvalidDerivationPath,
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
impl From<
|
|
82
|
-
fn from(err:
|
|
81
|
+
impl From<ddk_dlc::Error> for DLCError {
|
|
82
|
+
fn from(err: ddk_dlc::Error) -> Self {
|
|
83
83
|
match err {
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
ddk_dlc::Error::Secp256k1(_) => DLCError::Secp256k1Error(err.to_string()),
|
|
85
|
+
ddk_dlc::Error::InvalidArgument => {
|
|
86
86
|
DLCError::InvalidArgument("Error from rust-dlc".to_string())
|
|
87
87
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
ddk_dlc::Error::Miniscript(_) => DLCError::MiniscriptError,
|
|
89
|
+
ddk_dlc::Error::P2wpkh(_) => DLCError::InvalidTransaction,
|
|
90
|
+
ddk_dlc::Error::InputsIndex(_) => {
|
|
91
91
|
DLCError::InvalidArgument("Error from rust-dlc: InputsIndex".to_string())
|
|
92
92
|
}
|
|
93
93
|
}
|
|
@@ -345,7 +345,7 @@ pub fn create_fund_tx_locking_script(
|
|
|
345
345
|
let remote_pk =
|
|
346
346
|
PublicKey::from_slice(&remote_fund_pubkey).map_err(|_| DLCError::InvalidPublicKey)?;
|
|
347
347
|
|
|
348
|
-
let script =
|
|
348
|
+
let script = ddk_dlc::make_funding_redeemscript(&local_pk, &remote_pk);
|
|
349
349
|
Ok(script.to_bytes())
|
|
350
350
|
}
|
|
351
351
|
|
|
@@ -374,7 +374,7 @@ pub fn create_dlc_transactions(
|
|
|
374
374
|
.collect();
|
|
375
375
|
|
|
376
376
|
// Use rust-dlc library to create transactions
|
|
377
|
-
let dlc_txs =
|
|
377
|
+
let dlc_txs = ddk_dlc::create_dlc_transactions(
|
|
378
378
|
&rust_local_params,
|
|
379
379
|
&rust_remote_params,
|
|
380
380
|
&payouts,
|
|
@@ -415,7 +415,7 @@ pub fn create_spliced_dlc_transactions(
|
|
|
415
415
|
.collect();
|
|
416
416
|
|
|
417
417
|
// Use rust-dlc library to create spliced transactions
|
|
418
|
-
let dlc_txs =
|
|
418
|
+
let dlc_txs = ddk_dlc::create_spliced_dlc_transactions(
|
|
419
419
|
&rust_local_params,
|
|
420
420
|
&rust_remote_params,
|
|
421
421
|
&payouts,
|
|
@@ -464,7 +464,7 @@ pub fn create_cet(
|
|
|
464
464
|
witness: Witness::new(),
|
|
465
465
|
};
|
|
466
466
|
|
|
467
|
-
let btc_tx =
|
|
467
|
+
let btc_tx = ddk_dlc::create_cet(
|
|
468
468
|
local_btc_output,
|
|
469
469
|
local_payout_serial_id,
|
|
470
470
|
remote_btc_output,
|
|
@@ -511,7 +511,7 @@ pub fn create_cets(
|
|
|
511
511
|
})
|
|
512
512
|
.collect();
|
|
513
513
|
|
|
514
|
-
let btc_txs =
|
|
514
|
+
let btc_txs = ddk_dlc::create_cets(
|
|
515
515
|
&fund_tx_input,
|
|
516
516
|
local_script,
|
|
517
517
|
local_serial_id,
|
|
@@ -558,7 +558,7 @@ pub fn create_refund_transaction(
|
|
|
558
558
|
};
|
|
559
559
|
|
|
560
560
|
let btc_tx =
|
|
561
|
-
|
|
561
|
+
ddk_dlc::create_refund_transaction(local_output, remote_output, funding_input, lock_time);
|
|
562
562
|
|
|
563
563
|
Ok(btc_tx_to_transaction(&btc_tx))
|
|
564
564
|
}
|
|
@@ -631,7 +631,7 @@ pub fn verify_fund_tx_signature(
|
|
|
631
631
|
let sig = EcdsaSignature::from_der(&signature).map_err(|_| DLCError::InvalidSignature)?;
|
|
632
632
|
|
|
633
633
|
let secp = Secp256k1::verification_only();
|
|
634
|
-
match
|
|
634
|
+
match ddk_dlc::verify_tx_input_sig(
|
|
635
635
|
&secp,
|
|
636
636
|
&sig,
|
|
637
637
|
&btc_tx,
|
|
@@ -680,7 +680,7 @@ pub fn get_raw_funding_transaction_input_signature(
|
|
|
680
680
|
let wpkh = WPubkeyHash::hash(&pk.serialize());
|
|
681
681
|
let script = bitcoin::ScriptBuf::new_p2wpkh(&wpkh);
|
|
682
682
|
|
|
683
|
-
let sig =
|
|
683
|
+
let sig = ddk_dlc::util::get_sig_for_tx_input(
|
|
684
684
|
secp,
|
|
685
685
|
&btc_tx,
|
|
686
686
|
input_index,
|
|
@@ -720,7 +720,7 @@ pub fn sign_fund_transaction_input(
|
|
|
720
720
|
)))?;
|
|
721
721
|
|
|
722
722
|
let secp = Secp256k1::signing_only();
|
|
723
|
-
|
|
723
|
+
ddk_dlc::util::sign_p2wpkh_input(
|
|
724
724
|
&secp,
|
|
725
725
|
&sk,
|
|
726
726
|
&mut btc_tx,
|
|
@@ -751,7 +751,7 @@ pub fn sign_multi_sig_input(
|
|
|
751
751
|
|
|
752
752
|
let dlc_input = dlc_input_info_to_rust(&dlc_input)?;
|
|
753
753
|
|
|
754
|
-
let signature =
|
|
754
|
+
let signature = ddk_dlc::dlc_input::create_dlc_funding_input_signature(
|
|
755
755
|
secp,
|
|
756
756
|
&btc_tx,
|
|
757
757
|
dlc_input.fund_vout as usize,
|
|
@@ -766,7 +766,7 @@ pub fn sign_multi_sig_input(
|
|
|
766
766
|
(remote_pk, local_pk)
|
|
767
767
|
};
|
|
768
768
|
|
|
769
|
-
let witness =
|
|
769
|
+
let witness = ddk_dlc::dlc_input::combine_dlc_input_signatures(
|
|
770
770
|
&dlc_input,
|
|
771
771
|
&signature,
|
|
772
772
|
&remote_signature,
|
|
@@ -802,10 +802,10 @@ pub fn sign_cet(
|
|
|
802
802
|
let other_pk = PublicKey::from_slice(&other_pubkey).map_err(|_| DLCError::InvalidPublicKey)?;
|
|
803
803
|
let funding_pubkey =
|
|
804
804
|
PublicKey::from_slice(&funding_script_pubkey).map_err(|_| DLCError::InvalidPublicKey)?;
|
|
805
|
-
let dlc_redeem_script =
|
|
805
|
+
let dlc_redeem_script = ddk_dlc::make_funding_redeemscript(&funding_pubkey, &other_pk);
|
|
806
806
|
let secp = get_secp_context();
|
|
807
807
|
|
|
808
|
-
|
|
808
|
+
ddk_dlc::sign_cet(
|
|
809
809
|
secp,
|
|
810
810
|
&mut btc_tx,
|
|
811
811
|
&adaptor_sig,
|
|
@@ -882,7 +882,7 @@ pub fn create_cet_adaptor_sigs_from_oracle_info(
|
|
|
882
882
|
})
|
|
883
883
|
.collect::<Result<Vec<_>, _>>()?;
|
|
884
884
|
let secp = get_secp_context();
|
|
885
|
-
let adaptor_sigs =
|
|
885
|
+
let adaptor_sigs = ddk_dlc::create_cet_adaptor_sigs_from_oracle_info(
|
|
886
886
|
secp,
|
|
887
887
|
&cets,
|
|
888
888
|
&oracle_infos,
|
|
@@ -931,7 +931,7 @@ pub fn verify_cet_adaptor_sig_from_oracle_info(
|
|
|
931
931
|
.collect::<Result<Vec<_>, _>>()?;
|
|
932
932
|
Ok(DlcOracleInfo { public_key, nonces })
|
|
933
933
|
})
|
|
934
|
-
.collect::<Result<Vec<_>,
|
|
934
|
+
.collect::<Result<Vec<_>, ddk_dlc::Error>>()
|
|
935
935
|
else {
|
|
936
936
|
return false;
|
|
937
937
|
};
|
|
@@ -950,11 +950,11 @@ pub fn verify_cet_adaptor_sig_from_oracle_info(
|
|
|
950
950
|
else {
|
|
951
951
|
return false;
|
|
952
952
|
};
|
|
953
|
-
let Ok(adaptor_point) =
|
|
953
|
+
let Ok(adaptor_point) = ddk_dlc::get_adaptor_point_from_oracle_info(secp, &oracle_infos, &msgs)
|
|
954
954
|
else {
|
|
955
955
|
return false;
|
|
956
956
|
};
|
|
957
|
-
let Ok(_) =
|
|
957
|
+
let Ok(_) = ddk_dlc::verify_cet_adaptor_sig_from_point(
|
|
958
958
|
secp,
|
|
959
959
|
&adaptor_sig,
|
|
960
960
|
&btc_tx,
|
|
@@ -1032,7 +1032,7 @@ pub fn create_cet_adaptor_signature_from_oracle_info(
|
|
|
1032
1032
|
let nested_msgs = vec![msg_vec]; // Wrap in vector for single oracle
|
|
1033
1033
|
|
|
1034
1034
|
let secp = get_secp_context();
|
|
1035
|
-
let adaptor_sig =
|
|
1035
|
+
let adaptor_sig = ddk_dlc::create_cet_adaptor_sig_from_oracle_info(
|
|
1036
1036
|
secp,
|
|
1037
1037
|
&btc_tx,
|
|
1038
1038
|
&[dlc_oracle_info],
|
|
@@ -1104,7 +1104,7 @@ pub fn get_xpub_from_xpriv(xpriv: Vec<u8>, network: String) -> Result<Vec<u8>, D
|
|
|
1104
1104
|
mod tests {
|
|
1105
1105
|
use super::*;
|
|
1106
1106
|
use bitcoin::{hashes::sha256, locktime::absolute::LockTime, Address, CompressedPublicKey};
|
|
1107
|
-
use
|
|
1107
|
+
use ddk_dlc::secp_utils;
|
|
1108
1108
|
use secp256k1_zkp::{
|
|
1109
1109
|
rand::{thread_rng, RngCore},
|
|
1110
1110
|
Keypair, Scalar,
|
|
@@ -1220,7 +1220,7 @@ mod tests {
|
|
|
1220
1220
|
.unwrap();
|
|
1221
1221
|
|
|
1222
1222
|
// Compare with direct rust-dlc call
|
|
1223
|
-
let direct_result =
|
|
1223
|
+
let direct_result = ddk_dlc::make_funding_redeemscript(&offer_pk, &accept_pk);
|
|
1224
1224
|
|
|
1225
1225
|
assert_eq!(wrapper_result, direct_result.to_bytes());
|
|
1226
1226
|
}
|
|
@@ -1596,7 +1596,7 @@ mod tests {
|
|
|
1596
1596
|
let script = ScriptBuf::from_bytes(script_pubkey);
|
|
1597
1597
|
let sig = EcdsaSignature::from_der(&signature).map_err(|_| DLCError::InvalidSignature)?;
|
|
1598
1598
|
let pk = PublicKey::from_slice(&pk).map_err(|_| DLCError::InvalidPublicKey)?;
|
|
1599
|
-
|
|
1599
|
+
ddk_dlc::verify_tx_input_sig(
|
|
1600
1600
|
secp,
|
|
1601
1601
|
&sig,
|
|
1602
1602
|
&btc_txn,
|
|
@@ -1691,7 +1691,7 @@ mod tests {
|
|
|
1691
1691
|
oracle_sk_nonce.push(sk_nonces);
|
|
1692
1692
|
oracle_sks.push(oracle_kp);
|
|
1693
1693
|
}
|
|
1694
|
-
let funding_script_pubkey =
|
|
1694
|
+
let funding_script_pubkey = ddk_dlc::make_funding_redeemscript(
|
|
1695
1695
|
&PublicKey::from_slice(&offer_party_params.fund_pubkey.clone()).unwrap(),
|
|
1696
1696
|
&PublicKey::from_slice(&accept_party_params.fund_pubkey.clone()).unwrap(),
|
|
1697
1697
|
);
|