Skip to content

Commit

Permalink
fixup! feat: Unreserve utxos after offered channel gets rejected
Browse files Browse the repository at this point in the history
Only unreserve utxos on the offering side.
  • Loading branch information
holzeis committed Feb 16, 2024
1 parent fd34a33 commit 300cbf1
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions dlc-manager/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -932,18 +932,6 @@ where
let offered_channel = get_channel_in_state!(self, channel_id, Offered, None as Option<PublicKey>)?;
let offered_contract = get_contract_in_state!(self, &offered_channel.offered_contract_id, Offered, None as Option<PublicKey>)?;

if offered_channel.is_offer_party {
let utxos = offered_contract.funding_inputs_info.iter().map(|funding_input_info| {
let txid = Transaction::consensus_decode(&mut funding_input_info.funding_input.prev_tx.as_slice())
.expect("Transaction Decode Error")
.txid();
let vout = funding_input_info.funding_input.prev_tx_vout;
OutPoint{txid, vout}
}).collect::<Vec<_>>();

self.wallet.unreserve_utxos(&utxos)?;
}

let counterparty = offered_channel.counter_party;
self.store.upsert_channel(Channel::Cancelled(offered_channel), Some(Contract::Rejected(offered_contract)))?;

Expand Down Expand Up @@ -2028,6 +2016,16 @@ where
match channel {
Channel::Offered(offered_channel) => {
let offered_contract = get_contract_in_state!(self, &offered_channel.offered_contract_id, Offered, None as Option<PublicKey>)?;
let utxos = offered_contract.funding_inputs_info.iter().map(|funding_input_info| {
let txid = Transaction::consensus_decode(&mut funding_input_info.funding_input.prev_tx.as_slice())
.expect("Transaction Decode Error")
.txid();
let vout = funding_input_info.funding_input.prev_tx_vout;
OutPoint{txid, vout}
}).collect::<Vec<_>>();

self.wallet.unreserve_utxos(&utxos)?;

// remove rejected channel, since nothing has been confirmed on chain yet.
self.store.upsert_channel(Channel::Cancelled(offered_channel), Some(Contract::Rejected(offered_contract)))?;
},
Expand Down

0 comments on commit 300cbf1

Please sign in to comment.