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

pretty print offer-data #422

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/protocol/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,32 @@ pub(crate) struct Offer {
pub(crate) tweakable_point: PublicKey,
pub(crate) fidelity: FidelityProof,
}
impl Display for Offer {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"offer data received:\n\
- Base fee: {}\n\
- Percent Fee on total amount: {}\n\
- Time relative fee: {}\n\
- Required Confirms: {}\n\
- Minimum locktime: {}\n\
- Max size: {}\n\
- Min size: {}\n\
- Tweakable Point: {}\n\
- Fidelity Proof: {:?}",
self.base_fee,
self.amount_relative_fee_pct,
self.time_relative_fee_pct,
self.required_confirms,
self.minimum_locktime,
self.max_size,
self.min_size,
self.tweakable_point,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need the tweakable point.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add the tor address instead.

self.fidelity
Copy link

@mojoX911 mojoX911 Feb 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fidelity itself is a pretty big structure, we cannot directly print it. We just need the fidelity_bond value. And to calculate that we need access to the bitcoin RPC.

So this cannot be implemented directly with Display trait. Instead make a dedicated function at taker::api.rs, named display_fidelity, and use the taker::wallet::rpc to calculate the bond value. There is a caluclate_bond_value API on FidelityBond that you can directly use.

)
}
}

/// Contract Tx signatures provided by a Sender of a Coinswap.
#[derive(Debug, Serialize, Deserialize)]
Expand Down
Loading