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

[apps] Pretty-print offer data #413

Open
mojoX911 opened this issue Feb 10, 2025 · 1 comment
Open

[apps] Pretty-print offer data #413

mojoX911 opened this issue Feb 10, 2025 · 1 comment
Assignees
Labels
apps App related improvements enhancement This enhances the code and improves stuffs good first issue issues suitable for early contributors
Milestone

Comments

@mojoX911
Copy link

Currently the offer data we receive is pretty verbose. It should be compacted to make it readable by the users.

{
    base_fee                
    amount_relative_fee
    time_relative_fee 
    required_confirms
    minimum_locktime
    max_swap_size
    min_swap_size
    fidelity_bond_value:
    tor_addr
}
@mojoX911 mojoX911 added apps App related improvements enhancement This enhances the code and improves stuffs good first issue issues suitable for early contributors labels Feb 10, 2025
@mojoX911 mojoX911 added this to the v0.1.1 milestone Feb 10, 2025
@0xEgao
Copy link

0xEgao commented Feb 10, 2025

Hey @mojoX911 do you mean this by saying "make it readable by the user"

pub(crate) struct Offer {
    pub(crate) base_fee: u64,                // base fee in sats
    pub(crate) amount_relative_fee_pct: f64, // % fee on total amount
    pub(crate) time_relative_fee_pct: f64,   // amount * refund_locktime * TRF% = fees for locking the fund.
    pub(crate) required_confirms: u32,
    pub(crate) minimum_locktime: u16,
    pub(crate) max_size: u64,
    pub(crate) min_size: u64,
    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,
            self.fidelity
        )
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apps App related improvements enhancement This enhances the code and improves stuffs good first issue issues suitable for early contributors
Projects
Status: No status
Development

No branches or pull requests

3 participants