Skip to content

Commit

Permalink
Add check if maker has enough money
Browse files Browse the repository at this point in the history
Previously if there wasnt enough money then the ProofOfFunding stage
would fail, however at that point the taker has already wasted miner
fees getting transactions confirmed, so it would be very nice to
let them know before.
  • Loading branch information
chris-belcher committed Feb 3, 2022
1 parent e36e1a3 commit e1e896e
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/maker_protocol.rs
Expand Up @@ -468,14 +468,22 @@ fn handle_sign_senders_contract_tx(
funding_txids.push(txinfo.senders_contract_tx.input[0].previous_output.txid);
total_amount += txinfo.funding_input_value;
}
log::info!(
"requested contracts amount={}, for funding txids = {:?}",
Amount::from_sat(total_amount),
funding_txids
);
Ok(Some(MakerToTakerMessage::SendersContractSig(
SendersContractSig { sigs },
)))
if total_amount < wallet.read().unwrap().get_offer_maxsize_cache() {
log::info!(
"requested contracts amount={}, for funding txids = {:?}",
Amount::from_sat(total_amount),
funding_txids
);
Ok(Some(MakerToTakerMessage::SendersContractSig(
SendersContractSig { sigs },
)))
} else {
log::info!(
"rejecting contracts for amount={} because not enough funds",
Amount::from_sat(total_amount)
);
Err(Error::Protocol("not enough funds"))
}
}

fn handle_proof_of_funding(
Expand Down

0 comments on commit e1e896e

Please sign in to comment.