@bennyblader/ddk-rn 0.3.4 → 0.3.6
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 +2 -2
- package/ddk-ffi/Cargo.toml +1 -1
- package/ddk-ffi/src/ddk_ffi.udl +3 -9
- package/ddk-ffi/src/lib.rs +77 -55
- package/lib/commonjs/ddk_ffi.js +10 -54
- package/lib/commonjs/ddk_ffi.js.map +1 -1
- package/lib/module/ddk_ffi.js +9 -53
- package/lib/module/ddk_ffi.js.map +1 -1
- package/lib/typescript/commonjs/src/ddk_ffi.d.ts +3 -33
- package/lib/typescript/commonjs/src/ddk_ffi.d.ts.map +1 -1
- package/lib/typescript/module/src/ddk_ffi.d.ts +3 -33
- package/lib/typescript/module/src/ddk_ffi.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ddk_ffi.ts +14 -73
package/ddk-ffi/Cargo.lock
CHANGED
|
@@ -282,7 +282,7 @@ checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675"
|
|
|
282
282
|
|
|
283
283
|
[[package]]
|
|
284
284
|
name = "ddk_ffi"
|
|
285
|
-
version = "0.3.
|
|
285
|
+
version = "0.3.6"
|
|
286
286
|
dependencies = [
|
|
287
287
|
"bip39",
|
|
288
288
|
"bitcoin",
|
|
@@ -295,7 +295,7 @@ dependencies = [
|
|
|
295
295
|
[[package]]
|
|
296
296
|
name = "dlc"
|
|
297
297
|
version = "0.7.1"
|
|
298
|
-
source = "git+https://github.com/bennyhodl/dlcdevkit.git?branch=deterministic-contract-keys#
|
|
298
|
+
source = "git+https://github.com/bennyhodl/dlcdevkit.git?branch=deterministic-contract-keys#7ea0a69ed6ae8888adda4576b411deb4f26a4ec3"
|
|
299
299
|
dependencies = [
|
|
300
300
|
"bitcoin",
|
|
301
301
|
"miniscript",
|
package/ddk-ffi/Cargo.toml
CHANGED
package/ddk-ffi/src/ddk_ffi.udl
CHANGED
|
@@ -22,7 +22,7 @@ namespace ddk_ffi {
|
|
|
22
22
|
|
|
23
23
|
[Throws=DLCError]
|
|
24
24
|
DlcTransactions create_dlc_transactions(
|
|
25
|
-
sequence<
|
|
25
|
+
sequence<Payout> outcomes,
|
|
26
26
|
PartyParams local_params,
|
|
27
27
|
PartyParams remote_params,
|
|
28
28
|
u32 refund_locktime,
|
|
@@ -34,7 +34,7 @@ namespace ddk_ffi {
|
|
|
34
34
|
|
|
35
35
|
[Throws=DLCError]
|
|
36
36
|
DlcTransactions create_spliced_dlc_transactions(
|
|
37
|
-
sequence<
|
|
37
|
+
sequence<Payout> outcomes,
|
|
38
38
|
PartyParams local_params,
|
|
39
39
|
PartyParams remote_params,
|
|
40
40
|
u32 refund_locktime,
|
|
@@ -61,7 +61,7 @@ namespace ddk_ffi {
|
|
|
61
61
|
u32 fund_vout,
|
|
62
62
|
sequence<u8> local_final_script_pubkey,
|
|
63
63
|
sequence<u8> remote_final_script_pubkey,
|
|
64
|
-
sequence<
|
|
64
|
+
sequence<Payout> outcomes,
|
|
65
65
|
u32 lock_time,
|
|
66
66
|
u64 local_serial_id,
|
|
67
67
|
u64 remote_serial_id
|
|
@@ -204,12 +204,6 @@ dictionary TxInputInfo {
|
|
|
204
204
|
u64 serial_id;
|
|
205
205
|
};
|
|
206
206
|
|
|
207
|
-
// DLC outcome with payouts
|
|
208
|
-
dictionary DlcOutcome {
|
|
209
|
-
u64 local_payout;
|
|
210
|
-
u64 remote_payout;
|
|
211
|
-
};
|
|
212
|
-
|
|
213
207
|
// Payout for offer and accept parties
|
|
214
208
|
dictionary Payout {
|
|
215
209
|
u64 offer;
|
package/ddk-ffi/src/lib.rs
CHANGED
|
@@ -52,8 +52,8 @@ pub enum DLCError {
|
|
|
52
52
|
InvalidTransaction,
|
|
53
53
|
#[error("Insufficient funds")]
|
|
54
54
|
InsufficientFunds,
|
|
55
|
-
#[error("Invalid argument")]
|
|
56
|
-
InvalidArgument,
|
|
55
|
+
#[error("Invalid argument: {0}")]
|
|
56
|
+
InvalidArgument(String),
|
|
57
57
|
#[error("Serialization error")]
|
|
58
58
|
SerializationError,
|
|
59
59
|
#[error("Secp256k1 error: {0}")]
|
|
@@ -82,10 +82,14 @@ impl From<dlc::Error> for DLCError {
|
|
|
82
82
|
fn from(err: dlc::Error) -> Self {
|
|
83
83
|
match err {
|
|
84
84
|
dlc::Error::Secp256k1(_) => DLCError::Secp256k1Error(err.to_string()),
|
|
85
|
-
dlc::Error::InvalidArgument =>
|
|
85
|
+
dlc::Error::InvalidArgument => {
|
|
86
|
+
DLCError::InvalidArgument("Error from rust-dlc".to_string())
|
|
87
|
+
}
|
|
86
88
|
dlc::Error::Miniscript(_) => DLCError::MiniscriptError,
|
|
87
89
|
dlc::Error::P2wpkh(_) => DLCError::InvalidTransaction,
|
|
88
|
-
dlc::Error::InputsIndex(_) =>
|
|
90
|
+
dlc::Error::InputsIndex(_) => {
|
|
91
|
+
DLCError::InvalidArgument("Error from rust-dlc: InputsIndex".to_string())
|
|
92
|
+
}
|
|
89
93
|
}
|
|
90
94
|
}
|
|
91
95
|
}
|
|
@@ -130,12 +134,6 @@ pub struct TxInputInfo {
|
|
|
130
134
|
pub serial_id: u64,
|
|
131
135
|
}
|
|
132
136
|
|
|
133
|
-
#[derive(Clone)]
|
|
134
|
-
pub struct DlcOutcome {
|
|
135
|
-
pub local_payout: u64,
|
|
136
|
-
pub remote_payout: u64,
|
|
137
|
-
}
|
|
138
|
-
|
|
139
137
|
#[derive(Clone)]
|
|
140
138
|
pub struct Payout {
|
|
141
139
|
pub offer: u64,
|
|
@@ -242,11 +240,9 @@ pub fn dlc_input_info_to_rust(input: &DlcInputInfo) -> Result<RustDlcInputInfo,
|
|
|
242
240
|
PublicKey::from_slice(&input.local_fund_pubkey).map_err(|_| DLCError::InvalidPublicKey)?;
|
|
243
241
|
let remote_fund_pubkey =
|
|
244
242
|
PublicKey::from_slice(&input.remote_fund_pubkey).map_err(|_| DLCError::InvalidPublicKey)?;
|
|
245
|
-
let contract_id: [u8; 32] = input
|
|
246
|
-
.
|
|
247
|
-
|
|
248
|
-
.try_into()
|
|
249
|
-
.map_err(|_| DLCError::InvalidArgument)?;
|
|
243
|
+
let contract_id: [u8; 32] = input.contract_id.as_slice().try_into().map_err(|_| {
|
|
244
|
+
DLCError::InvalidArgument("Contract id length must be 32 bytes.".to_string())
|
|
245
|
+
})?;
|
|
250
246
|
Ok(RustDlcInputInfo {
|
|
251
247
|
fund_tx: btc_tx,
|
|
252
248
|
fund_vout: input.fund_vout,
|
|
@@ -261,7 +257,8 @@ pub fn dlc_input_info_to_rust(input: &DlcInputInfo) -> Result<RustDlcInputInfo,
|
|
|
261
257
|
|
|
262
258
|
/// Convert UniFFI TxInputInfo to rust-dlc TxInputInfo
|
|
263
259
|
pub fn tx_input_info_to_rust(input: &TxInputInfo) -> Result<DlcTxInputInfo, DLCError> {
|
|
264
|
-
let txid = Txid::from_str(&input.txid)
|
|
260
|
+
let txid = Txid::from_str(&input.txid)
|
|
261
|
+
.map_err(|_| DLCError::InvalidArgument("Invalid transaction id".to_string()))?;
|
|
265
262
|
Ok(DlcTxInputInfo {
|
|
266
263
|
outpoint: OutPoint {
|
|
267
264
|
txid,
|
|
@@ -325,7 +322,7 @@ pub fn create_fund_tx_locking_script(
|
|
|
325
322
|
|
|
326
323
|
/// Create complete DLC transactions
|
|
327
324
|
pub fn create_dlc_transactions(
|
|
328
|
-
outcomes: Vec<
|
|
325
|
+
outcomes: Vec<Payout>,
|
|
329
326
|
local_params: PartyParams,
|
|
330
327
|
remote_params: PartyParams,
|
|
331
328
|
refund_locktime: u32,
|
|
@@ -342,8 +339,8 @@ pub fn create_dlc_transactions(
|
|
|
342
339
|
let payouts: Vec<DlcPayout> = outcomes
|
|
343
340
|
.iter()
|
|
344
341
|
.map(|outcome| DlcPayout {
|
|
345
|
-
offer: Amount::from_sat(outcome.
|
|
346
|
-
accept: Amount::from_sat(outcome.
|
|
342
|
+
offer: Amount::from_sat(outcome.offer),
|
|
343
|
+
accept: Amount::from_sat(outcome.accept),
|
|
347
344
|
})
|
|
348
345
|
.collect();
|
|
349
346
|
|
|
@@ -366,7 +363,7 @@ pub fn create_dlc_transactions(
|
|
|
366
363
|
|
|
367
364
|
/// Create spliced DLC transactions
|
|
368
365
|
pub fn create_spliced_dlc_transactions(
|
|
369
|
-
outcomes: Vec<
|
|
366
|
+
outcomes: Vec<Payout>,
|
|
370
367
|
local_params: PartyParams,
|
|
371
368
|
remote_params: PartyParams,
|
|
372
369
|
refund_locktime: u32,
|
|
@@ -383,8 +380,8 @@ pub fn create_spliced_dlc_transactions(
|
|
|
383
380
|
let payouts: Vec<DlcPayout> = outcomes
|
|
384
381
|
.iter()
|
|
385
382
|
.map(|outcome| DlcPayout {
|
|
386
|
-
offer: Amount::from_sat(outcome.
|
|
387
|
-
accept: Amount::from_sat(outcome.
|
|
383
|
+
offer: Amount::from_sat(outcome.offer),
|
|
384
|
+
accept: Amount::from_sat(outcome.accept),
|
|
388
385
|
})
|
|
389
386
|
.collect();
|
|
390
387
|
|
|
@@ -415,7 +412,8 @@ pub fn create_cet(
|
|
|
415
412
|
fund_vout: u32,
|
|
416
413
|
lock_time: u32,
|
|
417
414
|
) -> Result<Transaction, DLCError> {
|
|
418
|
-
let txid = Txid::from_str(&fund_tx_id)
|
|
415
|
+
let txid = Txid::from_str(&fund_tx_id)
|
|
416
|
+
.map_err(|_| DLCError::InvalidArgument("Invalid transaction id".to_string()))?;
|
|
419
417
|
|
|
420
418
|
let local_btc_output = BtcTxOut {
|
|
421
419
|
value: Amount::from_sat(local_output.value),
|
|
@@ -455,12 +453,13 @@ pub fn create_cets(
|
|
|
455
453
|
fund_vout: u32,
|
|
456
454
|
local_final_script_pubkey: Vec<u8>,
|
|
457
455
|
remote_final_script_pubkey: Vec<u8>,
|
|
458
|
-
outcomes: Vec<
|
|
456
|
+
outcomes: Vec<Payout>,
|
|
459
457
|
lock_time: u32,
|
|
460
458
|
local_serial_id: u64,
|
|
461
459
|
remote_serial_id: u64,
|
|
462
460
|
) -> Result<Vec<Transaction>, DLCError> {
|
|
463
|
-
let txid = Txid::from_str(&fund_tx_id)
|
|
461
|
+
let txid = Txid::from_str(&fund_tx_id)
|
|
462
|
+
.map_err(|_| DLCError::InvalidArgument("Invalid transaction id".to_string()))?;
|
|
464
463
|
|
|
465
464
|
let fund_tx_input = TxIn {
|
|
466
465
|
previous_output: OutPoint {
|
|
@@ -478,8 +477,8 @@ pub fn create_cets(
|
|
|
478
477
|
let payouts: Vec<DlcPayout> = outcomes
|
|
479
478
|
.iter()
|
|
480
479
|
.map(|outcome| DlcPayout {
|
|
481
|
-
offer: Amount::from_sat(outcome.
|
|
482
|
-
accept: Amount::from_sat(outcome.
|
|
480
|
+
offer: Amount::from_sat(outcome.offer),
|
|
481
|
+
accept: Amount::from_sat(outcome.accept),
|
|
483
482
|
})
|
|
484
483
|
.collect();
|
|
485
484
|
|
|
@@ -506,7 +505,8 @@ pub fn create_refund_transaction(
|
|
|
506
505
|
fund_tx_id: String,
|
|
507
506
|
fund_vout: u32,
|
|
508
507
|
) -> Result<Transaction, DLCError> {
|
|
509
|
-
let txid = Txid::from_str(&fund_tx_id)
|
|
508
|
+
let txid = Txid::from_str(&fund_tx_id)
|
|
509
|
+
.map_err(|_| DLCError::InvalidArgument("Invalid transaction id".to_string()))?;
|
|
510
510
|
|
|
511
511
|
let local_output = BtcTxOut {
|
|
512
512
|
value: Amount::from_sat(local_amount),
|
|
@@ -580,7 +580,8 @@ pub fn verify_fund_tx_signature(
|
|
|
580
580
|
) -> Result<bool, DLCError> {
|
|
581
581
|
let btc_tx = transaction_to_btc_tx(&fund_tx)?;
|
|
582
582
|
let pk = PublicKey::from_slice(&pubkey).map_err(|_| DLCError::InvalidPublicKey)?;
|
|
583
|
-
let input_txid = Txid::from_str(&txid)
|
|
583
|
+
let input_txid = Txid::from_str(&txid)
|
|
584
|
+
.map_err(|_| DLCError::InvalidArgument("Invalid transaction id".to_string()))?;
|
|
584
585
|
|
|
585
586
|
// Find the input index
|
|
586
587
|
let input_index = btc_tx
|
|
@@ -589,7 +590,10 @@ pub fn verify_fund_tx_signature(
|
|
|
589
590
|
.position(|input| {
|
|
590
591
|
input.previous_output.txid == input_txid && input.previous_output.vout == vout
|
|
591
592
|
})
|
|
592
|
-
.ok_or(DLCError::InvalidArgument
|
|
593
|
+
.ok_or(DLCError::InvalidArgument(format!(
|
|
594
|
+
"Input index not found in {}",
|
|
595
|
+
input_txid
|
|
596
|
+
)))?;
|
|
593
597
|
|
|
594
598
|
// Create a simple P2WPKH script for verification
|
|
595
599
|
let wpkh = WPubkeyHash::hash(&pk.serialize());
|
|
@@ -632,8 +636,10 @@ pub fn get_raw_funding_transaction_input_signature(
|
|
|
632
636
|
value: u64,
|
|
633
637
|
) -> Result<Vec<u8>, DLCError> {
|
|
634
638
|
let btc_tx = transaction_to_btc_tx(&funding_transaction)?;
|
|
635
|
-
let sk = SecretKey::from_slice(&privkey)
|
|
636
|
-
|
|
639
|
+
let sk = SecretKey::from_slice(&privkey)
|
|
640
|
+
.map_err(|_| DLCError::InvalidArgument("Invalid private key".to_string()))?;
|
|
641
|
+
let prev_txid = Txid::from_str(&prev_tx_id)
|
|
642
|
+
.map_err(|_| DLCError::InvalidArgument("Invalid transaction id".to_string()))?;
|
|
637
643
|
|
|
638
644
|
// Find the input index
|
|
639
645
|
let input_index = btc_tx
|
|
@@ -642,7 +648,10 @@ pub fn get_raw_funding_transaction_input_signature(
|
|
|
642
648
|
.position(|input| {
|
|
643
649
|
input.previous_output.txid == prev_txid && input.previous_output.vout == prev_tx_vout
|
|
644
650
|
})
|
|
645
|
-
.ok_or(DLCError::InvalidArgument
|
|
651
|
+
.ok_or(DLCError::InvalidArgument(format!(
|
|
652
|
+
"Input index not found in {}",
|
|
653
|
+
prev_txid
|
|
654
|
+
)))?;
|
|
646
655
|
|
|
647
656
|
let secp = get_secp_context();
|
|
648
657
|
// Create P2WPKH script for signing
|
|
@@ -672,8 +681,10 @@ pub fn sign_fund_transaction_input(
|
|
|
672
681
|
value: u64,
|
|
673
682
|
) -> Result<Transaction, DLCError> {
|
|
674
683
|
let mut btc_tx = transaction_to_btc_tx(&fund_transaction)?;
|
|
675
|
-
let sk = SecretKey::from_slice(&privkey)
|
|
676
|
-
|
|
684
|
+
let sk = SecretKey::from_slice(&privkey)
|
|
685
|
+
.map_err(|_| DLCError::InvalidArgument("Invalid private key".to_string()))?;
|
|
686
|
+
let prev_txid = Txid::from_str(&prev_tx_id)
|
|
687
|
+
.map_err(|_| DLCError::InvalidArgument("Invalid transaction id".to_string()))?;
|
|
677
688
|
|
|
678
689
|
// Find the input index
|
|
679
690
|
let input_index = btc_tx
|
|
@@ -682,7 +693,10 @@ pub fn sign_fund_transaction_input(
|
|
|
682
693
|
.position(|input| {
|
|
683
694
|
input.previous_output.txid == prev_txid && input.previous_output.vout == prev_tx_vout
|
|
684
695
|
})
|
|
685
|
-
.ok_or(DLCError::InvalidArgument
|
|
696
|
+
.ok_or(DLCError::InvalidArgument(format!(
|
|
697
|
+
"Input index not found in {}",
|
|
698
|
+
prev_txid
|
|
699
|
+
)))?;
|
|
686
700
|
|
|
687
701
|
let secp = Secp256k1::signing_only();
|
|
688
702
|
dlc::util::sign_p2wpkh_input(
|
|
@@ -713,8 +727,8 @@ pub fn sign_cet(
|
|
|
713
727
|
.iter()
|
|
714
728
|
.map(|sig| vec_to_schnorr_signature(sig))
|
|
715
729
|
.collect::<Result<Vec<_>, _>>()?;
|
|
716
|
-
let funding_sk =
|
|
717
|
-
|
|
730
|
+
let funding_sk = SecretKey::from_slice(&funding_secret_key)
|
|
731
|
+
.map_err(|_| DLCError::InvalidArgument("Invalid funding secret key".to_string()))?;
|
|
718
732
|
let other_pk = PublicKey::from_slice(&other_pubkey).map_err(|_| DLCError::InvalidPublicKey)?;
|
|
719
733
|
let funding_script = Script::from_bytes(&funding_script_pubkey);
|
|
720
734
|
let secp = get_secp_context();
|
|
@@ -752,7 +766,9 @@ pub fn create_cet_adaptor_sigs_from_oracle_info(
|
|
|
752
766
|
msgs: Vec<Vec<Vec<u8>>>,
|
|
753
767
|
) -> Result<Vec<AdaptorSignature>, DLCError> {
|
|
754
768
|
if msgs.len() != cets.len() {
|
|
755
|
-
return Err(DLCError::InvalidArgument
|
|
769
|
+
return Err(DLCError::InvalidArgument(
|
|
770
|
+
"Messages length must be equal to cets length".to_string(),
|
|
771
|
+
));
|
|
756
772
|
}
|
|
757
773
|
|
|
758
774
|
let cets = cets
|
|
@@ -762,25 +778,30 @@ pub fn create_cet_adaptor_sigs_from_oracle_info(
|
|
|
762
778
|
let oracle_infos = oracle_info
|
|
763
779
|
.iter()
|
|
764
780
|
.map(|info| {
|
|
765
|
-
let public_key = XOnlyPublicKey::from_slice(&info.public_key)
|
|
781
|
+
let public_key = XOnlyPublicKey::from_slice(&info.public_key)
|
|
782
|
+
.map_err(|_| DLCError::InvalidPublicKey)?;
|
|
766
783
|
let nonces = info
|
|
767
784
|
.nonces
|
|
768
785
|
.iter()
|
|
769
786
|
.map(|nonce| XOnlyPublicKey::from_slice(nonce))
|
|
770
|
-
.collect::<Result<Vec<_>, _>>()
|
|
787
|
+
.collect::<Result<Vec<_>, _>>()
|
|
788
|
+
.map_err(|_| DLCError::InvalidArgument("Invalid nonce pubkey".to_string()))?;
|
|
771
789
|
Ok(DlcOracleInfo { public_key, nonces })
|
|
772
790
|
})
|
|
773
|
-
.collect::<Result<Vec<_>,
|
|
774
|
-
.map_err(|_| DLCError::InvalidArgument)?;
|
|
791
|
+
.collect::<Result<Vec<_>, DLCError>>()
|
|
792
|
+
.map_err(|_| DLCError::InvalidArgument("Invalid oracle info".to_string()))?;
|
|
775
793
|
|
|
776
|
-
let funding_sk =
|
|
777
|
-
|
|
794
|
+
let funding_sk = SecretKey::from_slice(&funding_secret_key)
|
|
795
|
+
.map_err(|_| DLCError::InvalidArgument("Invalid funding secret key".to_string()))?;
|
|
778
796
|
let funding_script = Script::from_bytes(&funding_script_pubkey);
|
|
779
797
|
let msgs = msgs
|
|
780
798
|
.iter()
|
|
781
799
|
.map(|msg| {
|
|
782
800
|
msg.iter()
|
|
783
|
-
.map(|m|
|
|
801
|
+
.map(|m| {
|
|
802
|
+
Message::from_digest_slice(m)
|
|
803
|
+
.map_err(|_| DLCError::InvalidArgument("Invalid message".to_string()))
|
|
804
|
+
})
|
|
784
805
|
.collect::<Result<Vec<_>, _>>()
|
|
785
806
|
})
|
|
786
807
|
.collect::<Result<Vec<_>, _>>()?;
|
|
@@ -907,7 +928,8 @@ pub fn create_cet_adaptor_signature_from_oracle_info(
|
|
|
907
928
|
msgs: Vec<Vec<u8>>,
|
|
908
929
|
) -> Result<AdaptorSignature, DLCError> {
|
|
909
930
|
let btc_tx = transaction_to_btc_tx(&cet)?;
|
|
910
|
-
let sk = SecretKey::from_slice(&funding_sk)
|
|
931
|
+
let sk = SecretKey::from_slice(&funding_sk)
|
|
932
|
+
.map_err(|_| DLCError::InvalidArgument("Invalid funding secret key".to_string()))?;
|
|
911
933
|
let funding_script = Script::from_bytes(&funding_script_pubkey);
|
|
912
934
|
|
|
913
935
|
// Convert oracle info
|
|
@@ -930,7 +952,7 @@ pub fn create_cet_adaptor_signature_from_oracle_info(
|
|
|
930
952
|
.iter()
|
|
931
953
|
.map(|msg| Message::from_digest_slice(msg))
|
|
932
954
|
.collect();
|
|
933
|
-
let msg_vec = messages.map_err(|_| DLCError::InvalidArgument)?;
|
|
955
|
+
let msg_vec = messages.map_err(|_| DLCError::InvalidArgument("Invalid message".to_string()))?;
|
|
934
956
|
let nested_msgs = vec![msg_vec]; // Wrap in vector for single oracle
|
|
935
957
|
|
|
936
958
|
let secp = get_secp_context();
|
|
@@ -1178,13 +1200,13 @@ mod tests {
|
|
|
1178
1200
|
);
|
|
1179
1201
|
|
|
1180
1202
|
let outcomes = vec![
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1203
|
+
Payout {
|
|
1204
|
+
offer: 200_000_000, // 2 BTC to offer
|
|
1205
|
+
accept: 0, // 0 BTC to accept
|
|
1184
1206
|
},
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1207
|
+
Payout {
|
|
1208
|
+
offer: 0, // 0 BTC to offer
|
|
1209
|
+
accept: 200_000_000, // 2 BTC to accept
|
|
1188
1210
|
},
|
|
1189
1211
|
];
|
|
1190
1212
|
|
|
@@ -1401,6 +1423,6 @@ mod tests {
|
|
|
1401
1423
|
0,
|
|
1402
1424
|
0,
|
|
1403
1425
|
);
|
|
1404
|
-
assert!(matches!(result, Err(DLCError::InvalidArgument)));
|
|
1426
|
+
assert!(matches!(result, Err(DLCError::InvalidArgument(_))));
|
|
1405
1427
|
}
|
|
1406
1428
|
}
|
package/lib/commonjs/ddk_ffi.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.TxOutput = exports.TxInputInfo = exports.TxInput = exports.Transaction = exports.Payout = exports.PartyParams = exports.OracleInfo = exports.ExtendedKey_Tags = exports.ExtendedKey = exports.DlcTransactions = exports.
|
|
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
7
|
exports.convertMnemonicToSeed = convertMnemonicToSeed;
|
|
8
8
|
exports.createCet = createCet;
|
|
9
9
|
exports.createCetAdaptorSignatureFromOracleInfo = createCetAdaptorSignatureFromOracleInfo;
|
|
@@ -80,7 +80,7 @@ function createCets(fundTxId, fundVout, localFinalScriptPubkey, remoteFinalScrip
|
|
|
80
80
|
return (() => {
|
|
81
81
|
console.debug(`-- uniffi_ddk_ffi_fn_func_create_cets`);
|
|
82
82
|
return (0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_fn_func_create_cets;
|
|
83
|
-
})()(FfiConverterString.lower(fundTxId), _uniffiBindgenReactNative.FfiConverterUInt32.lower(fundVout), FfiConverterArrayUInt8.lower(localFinalScriptPubkey), FfiConverterArrayUInt8.lower(remoteFinalScriptPubkey),
|
|
83
|
+
})()(FfiConverterString.lower(fundTxId), _uniffiBindgenReactNative.FfiConverterUInt32.lower(fundVout), FfiConverterArrayUInt8.lower(localFinalScriptPubkey), FfiConverterArrayUInt8.lower(remoteFinalScriptPubkey), FfiConverterArrayTypePayout.lower(outcomes), _uniffiBindgenReactNative.FfiConverterUInt32.lower(lockTime), _uniffiBindgenReactNative.FfiConverterUInt64.lower(localSerialId), _uniffiBindgenReactNative.FfiConverterUInt64.lower(remoteSerialId), callStatus);
|
|
84
84
|
}, /*liftString:*/FfiConverterString.lift));
|
|
85
85
|
}
|
|
86
86
|
function createDlcTransactions(outcomes, localParams, remoteParams, refundLocktime, feeRate, fundLockTime, cetLockTime, fundOutputSerialId) /*throws*/{
|
|
@@ -88,7 +88,7 @@ function createDlcTransactions(outcomes, localParams, remoteParams, refundLockti
|
|
|
88
88
|
return (() => {
|
|
89
89
|
console.debug(`-- uniffi_ddk_ffi_fn_func_create_dlc_transactions`);
|
|
90
90
|
return (0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_fn_func_create_dlc_transactions;
|
|
91
|
-
})()(
|
|
91
|
+
})()(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);
|
|
92
92
|
}, /*liftString:*/FfiConverterString.lift));
|
|
93
93
|
}
|
|
94
94
|
function createFundTxLockingScript(localFundPubkey, remoteFundPubkey) /*throws*/{
|
|
@@ -112,7 +112,7 @@ function createSplicedDlcTransactions(outcomes, localParams, remoteParams, refun
|
|
|
112
112
|
return (() => {
|
|
113
113
|
console.debug(`-- uniffi_ddk_ffi_fn_func_create_spliced_dlc_transactions`);
|
|
114
114
|
return (0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_fn_func_create_spliced_dlc_transactions;
|
|
115
|
-
})()(
|
|
115
|
+
})()(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);
|
|
116
116
|
}, /*liftString:*/FfiConverterString.lift));
|
|
117
117
|
}
|
|
118
118
|
function createXprivFromParentPath(xpriv, baseDerivationPath, network, path) /*throws*/{
|
|
@@ -354,49 +354,6 @@ const FfiConverterTypeDlcInputInfo = (() => {
|
|
|
354
354
|
}
|
|
355
355
|
return new FFIConverter();
|
|
356
356
|
})();
|
|
357
|
-
/**
|
|
358
|
-
* Generated factory for {@link DlcOutcome} record objects.
|
|
359
|
-
*/
|
|
360
|
-
const DlcOutcome = exports.DlcOutcome = (() => {
|
|
361
|
-
const defaults = () => ({});
|
|
362
|
-
const create = (() => {
|
|
363
|
-
return (0, _uniffiBindgenReactNative.uniffiCreateRecord)(defaults);
|
|
364
|
-
})();
|
|
365
|
-
return Object.freeze({
|
|
366
|
-
/**
|
|
367
|
-
* Create a frozen instance of {@link DlcOutcome}, with defaults specified
|
|
368
|
-
* in Rust, in the {@link ddk_ffi} crate.
|
|
369
|
-
*/
|
|
370
|
-
create,
|
|
371
|
-
/**
|
|
372
|
-
* Create a frozen instance of {@link DlcOutcome}, with defaults specified
|
|
373
|
-
* in Rust, in the {@link ddk_ffi} crate.
|
|
374
|
-
*/
|
|
375
|
-
new: create,
|
|
376
|
-
/**
|
|
377
|
-
* Defaults specified in the {@link ddk_ffi} crate.
|
|
378
|
-
*/
|
|
379
|
-
defaults: () => Object.freeze(defaults())
|
|
380
|
-
});
|
|
381
|
-
})();
|
|
382
|
-
const FfiConverterTypeDlcOutcome = (() => {
|
|
383
|
-
class FFIConverter extends _uniffiBindgenReactNative.AbstractFfiConverterByteArray {
|
|
384
|
-
read(from) {
|
|
385
|
-
return {
|
|
386
|
-
localPayout: _uniffiBindgenReactNative.FfiConverterUInt64.read(from),
|
|
387
|
-
remotePayout: _uniffiBindgenReactNative.FfiConverterUInt64.read(from)
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
write(value, into) {
|
|
391
|
-
_uniffiBindgenReactNative.FfiConverterUInt64.write(value.localPayout, into);
|
|
392
|
-
_uniffiBindgenReactNative.FfiConverterUInt64.write(value.remotePayout, into);
|
|
393
|
-
}
|
|
394
|
-
allocationSize(value) {
|
|
395
|
-
return _uniffiBindgenReactNative.FfiConverterUInt64.allocationSize(value.localPayout) + _uniffiBindgenReactNative.FfiConverterUInt64.allocationSize(value.remotePayout);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
return new FFIConverter();
|
|
399
|
-
})();
|
|
400
357
|
/**
|
|
401
358
|
* Generated factory for {@link DlcTransactions} record objects.
|
|
402
359
|
*/
|
|
@@ -1191,12 +1148,12 @@ const FfiConverterArrayTypeAdaptorSignature = new _uniffiBindgenReactNative.FfiC
|
|
|
1191
1148
|
// FfiConverter for Array<DlcInputInfo>
|
|
1192
1149
|
const FfiConverterArrayTypeDlcInputInfo = new _uniffiBindgenReactNative.FfiConverterArray(FfiConverterTypeDlcInputInfo);
|
|
1193
1150
|
|
|
1194
|
-
// FfiConverter for Array<DlcOutcome>
|
|
1195
|
-
const FfiConverterArrayTypeDlcOutcome = new _uniffiBindgenReactNative.FfiConverterArray(FfiConverterTypeDlcOutcome);
|
|
1196
|
-
|
|
1197
1151
|
// FfiConverter for Array<OracleInfo>
|
|
1198
1152
|
const FfiConverterArrayTypeOracleInfo = new _uniffiBindgenReactNative.FfiConverterArray(FfiConverterTypeOracleInfo);
|
|
1199
1153
|
|
|
1154
|
+
// FfiConverter for Array<Payout>
|
|
1155
|
+
const FfiConverterArrayTypePayout = new _uniffiBindgenReactNative.FfiConverterArray(FfiConverterTypePayout);
|
|
1156
|
+
|
|
1200
1157
|
// FfiConverter for Array<Transaction>
|
|
1201
1158
|
const FfiConverterArrayTypeTransaction = new _uniffiBindgenReactNative.FfiConverterArray(FfiConverterTypeTransaction);
|
|
1202
1159
|
|
|
@@ -1248,10 +1205,10 @@ function uniffiEnsureInitialized() {
|
|
|
1248
1205
|
if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_create_cet_adaptor_sigs_from_oracle_info() !== 59405) {
|
|
1249
1206
|
throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_create_cet_adaptor_sigs_from_oracle_info');
|
|
1250
1207
|
}
|
|
1251
|
-
if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_create_cets() !==
|
|
1208
|
+
if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_create_cets() !== 50529) {
|
|
1252
1209
|
throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_create_cets');
|
|
1253
1210
|
}
|
|
1254
|
-
if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_create_dlc_transactions() !==
|
|
1211
|
+
if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_create_dlc_transactions() !== 29518) {
|
|
1255
1212
|
throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_create_dlc_transactions');
|
|
1256
1213
|
}
|
|
1257
1214
|
if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_create_fund_tx_locking_script() !== 2761) {
|
|
@@ -1260,7 +1217,7 @@ function uniffiEnsureInitialized() {
|
|
|
1260
1217
|
if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_create_refund_transaction() !== 57261) {
|
|
1261
1218
|
throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_create_refund_transaction');
|
|
1262
1219
|
}
|
|
1263
|
-
if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_create_spliced_dlc_transactions() !==
|
|
1220
|
+
if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_create_spliced_dlc_transactions() !== 19497) {
|
|
1264
1221
|
throw new _uniffiBindgenReactNative.UniffiInternalError.ApiChecksumMismatch('uniffi_ddk_ffi_checksum_func_create_spliced_dlc_transactions');
|
|
1265
1222
|
}
|
|
1266
1223
|
if ((0, _ddk_ffiFfi.default)().ubrn_uniffi_ddk_ffi_checksum_func_create_xpriv_from_parent_path() !== 50010) {
|
|
@@ -1307,7 +1264,6 @@ var _default = exports.default = Object.freeze({
|
|
|
1307
1264
|
FfiConverterTypeChangeOutputAndFees,
|
|
1308
1265
|
FfiConverterTypeDLCError,
|
|
1309
1266
|
FfiConverterTypeDlcInputInfo,
|
|
1310
|
-
FfiConverterTypeDlcOutcome,
|
|
1311
1267
|
FfiConverterTypeDlcTransactions,
|
|
1312
1268
|
FfiConverterTypeExtendedKey,
|
|
1313
1269
|
FfiConverterTypeOracleInfo,
|