Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a ManagerOptions type to allow for customizable options #102

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
8 changes: 6 additions & 2 deletions dlc-manager/src/channel/offered_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ pub struct OfferedChannel {
}

impl OfferedChannel {
pub(crate) fn get_offer_channel_msg(&self, offered_contract: &OfferedContract) -> OfferChannel {
pub(crate) fn get_offer_channel_msg(
&self,
offered_contract: &OfferedContract,
cet_nsequence: u32,
) -> OfferChannel {
let party_points = &self.party_points;
OfferChannel {
protocol_version: crate::conversion_utils::PROTOCOL_VERSION,
Expand Down Expand Up @@ -72,7 +76,7 @@ impl OfferedChannel {
refund_locktime: offered_contract.refund_locktime,
fee_rate_per_vb: offered_contract.fee_rate_per_vb,
fund_output_serial_id: offered_contract.fund_output_serial_id,
cet_nsequence: crate::manager::CET_NSEQUENCE,
cet_nsequence,
}
}

Expand Down
8 changes: 5 additions & 3 deletions dlc-manager/src/channel_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::{
verify_signed_contract_internal,
},
error::Error,
manager::RefundDelayWindow,
utils::get_new_temporary_id,
Blockchain, Signer, Time, Wallet,
};
Expand Down Expand Up @@ -72,7 +73,7 @@ pub fn offer_channel<C: Signing, W: Deref, B: Deref, T: Deref>(
counter_party: &PublicKey,
oracle_announcements: &[Vec<OracleAnnouncement>],
cet_nsequence: u32,
refund_delay: u32,
refund_delay: RefundDelayWindow,
wallet: &W,
blockchain: &B,
time: &T,
Expand Down Expand Up @@ -957,7 +958,7 @@ pub fn renew_offer<C: Signing, S: Deref, T: Deref>(
contract_input: &ContractInput,
oracle_announcements: Vec<Vec<OracleAnnouncement>>,
counter_payout: u64,
refund_delay: u32,
refund_delay: RefundDelayWindow,
peer_timeout: u64,
cet_nsequence: u32,
signer: &S,
Expand Down Expand Up @@ -1490,6 +1491,7 @@ pub fn offer_collaborative_close<C: Signing, S: Deref, T: Deref>(
counter_payout: u64,
signer: &S,
time: &T,
peer_timeout: u64,
) -> Result<(CollaborativeCloseOffer, Transaction), Error>
where
S::Target: Signer,
Expand Down Expand Up @@ -1535,7 +1537,7 @@ where
counter_payout,
offer_signature: close_signature,
close_tx: close_tx.clone(),
timeout: time.unix_time_now() + super::manager::PEER_TIMEOUT,
timeout: time.unix_time_now() + peer_timeout,
};
std::mem::swap(&mut state, &mut signed_channel.state);
signed_channel.roll_back_state = Some(state);
Expand Down
5 changes: 3 additions & 2 deletions dlc-manager/src/contract/offered_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use crate::conversion_utils::{
get_contract_info_and_announcements, get_tx_input_infos, BITCOIN_CHAINHASH, PROTOCOL_VERSION,
};
use crate::manager::RefundDelayWindow;
use crate::utils::get_new_serial_id;

use super::contract_info::ContractInfo;
Expand Down Expand Up @@ -80,7 +81,7 @@ impl OfferedContract {
offer_params: &PartyParams,
funding_inputs_info: &[FundingInputInfo],
counter_party: &PublicKey,
refund_delay: u32,
refund_delay: RefundDelayWindow,
cet_locktime: u32,
) -> Self {
let total_collateral = contract.offer_collateral + contract.accept_collateral;
Expand Down Expand Up @@ -111,7 +112,7 @@ impl OfferedContract {
fund_output_serial_id,
fee_rate_per_vb: contract.fee_rate,
cet_locktime,
refund_locktime: latest_maturity + refund_delay,
refund_locktime: latest_maturity + refund_delay.min,
counter_party: *counter_party,
}
}
Expand Down
3 changes: 2 additions & 1 deletion dlc-manager/src/contract_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use crate::{
},
conversion_utils::get_tx_input_infos,
error::Error,
manager::RefundDelayWindow,
Blockchain, ChannelId, Signer, Time, Wallet,
};

Expand All @@ -29,7 +30,7 @@ pub fn offer_contract<C: Signing, W: Deref, B: Deref, T: Deref>(
secp: &Secp256k1<C>,
contract_input: &ContractInput,
oracle_announcements: Vec<Vec<OracleAnnouncement>>,
refund_delay: u32,
refund_delay: RefundDelayWindow,
counter_party: &PublicKey,
wallet: &W,
blockchain: &B,
Expand Down
Loading