Skip to content

Commit 510bcdd

Browse files
committed
use coop sign for submarine refunds
1 parent b8d8e51 commit 510bcdd

1 file changed

Lines changed: 47 additions & 9 deletions

File tree

src/lib.rs

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use boltz_client::network::{BitcoinChain, Chain, LiquidChain};
99
use boltz_client::swaps::BtcLikeTransaction;
1010
use boltz_client::swaps::bitcoin::{BtcSwapScript, BtcSwapTx};
1111
use boltz_client::swaps::liquid::{LBtcSwapScript, LBtcSwapTx};
12-
use boltz_client::swaps::{ChainClient, SwapScript, SwapTransactionParams, TransactionOptions};
12+
use boltz_client::swaps::{ChainClient, Cooperative, SwapScript, SwapTransactionParams, TransactionOptions};
1313
use boltz_client::util::secrets::{Preimage, SwapKey};
1414
use std::str::FromStr;
1515
use std::time::Duration;
@@ -110,7 +110,7 @@ pub async fn refund_rescue(
110110
liquid_chain,
111111
"blockstream.info:195",
112112
false, // no SSL
113-
true, // validate domain
113+
false, // no validation needed
114114
60, // timeout in seconds
115115
)?);
116116
}
@@ -257,7 +257,7 @@ pub async fn claim_rescue(
257257
liquid_chain,
258258
"blockstream.info:195",
259259
false, // no SSL
260-
true, // validate domain
260+
false, // no validation needed
261261
60, // timeout in seconds
262262
)?);
263263
}
@@ -277,7 +277,7 @@ pub async fn claim_rescue(
277277
liquid_chain,
278278
"blockstream.info:195",
279279
false, // no SSL
280-
true, // validate domain
280+
false, // no validation needed
281281
60, // timeout in seconds
282282
)?);
283283
}
@@ -401,7 +401,7 @@ pub async fn submarine_refund_rescue(
401401
liquid_chain,
402402
"blockstream.info:195",
403403
false, // no SSL
404-
true, // validate domain
404+
false, // no validation needed
405405
60, // timeout in seconds
406406
)?);
407407
}
@@ -444,8 +444,27 @@ pub async fn submarine_refund_rescue(
444444
swap_id.to_string(),
445445
).await?;
446446

447-
let signed_tx = swap_tx.sign_refund(&refund_swap_key.keypair, fee, None, true).await?;
448-
BtcLikeTransaction::liquid(signed_tx)
447+
let signed = match swap_tx
448+
.sign_refund(
449+
&refund_swap_key.keypair,
450+
fee.into(),
451+
if true {
452+
Some(Cooperative {
453+
boltz_api: &boltz_api,
454+
swap_id: swap_id.to_string(),
455+
signature: None,
456+
})
457+
} else {
458+
None
459+
},
460+
true,
461+
)
462+
.await
463+
{
464+
Ok(result) => result,
465+
Err(e) => return Err(e.into()),
466+
};
467+
BtcLikeTransaction::liquid(signed)
449468
}
450469
Chain::Bitcoin(_) => {
451470
let lockup_script = BtcSwapScript::submarine_from_swap_resp(
@@ -466,8 +485,27 @@ pub async fn submarine_refund_rescue(
466485
swap_id.to_string(),
467486
).await?;
468487

469-
let signed_tx = swap_tx.sign_refund(&refund_swap_key.keypair, fee, None).await?;
470-
BtcLikeTransaction::bitcoin(signed_tx)
488+
let signed = match swap_tx
489+
.sign_refund(
490+
&refund_swap_key.keypair,
491+
fee.into(),
492+
if true {
493+
Some(Cooperative {
494+
boltz_api: &boltz_api,
495+
swap_id: swap_id.to_string(),
496+
signature: None,
497+
})
498+
} else {
499+
None
500+
},
501+
true,
502+
)
503+
.await
504+
{
505+
Ok(result) => result,
506+
Err(e) => return Err(e.into()),
507+
};
508+
BtcLikeTransaction::bitcoin(signed)
471509
}
472510
};
473511

0 commit comments

Comments
 (0)