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 the fidelity bonds #389

Open
mojoX911 opened this issue Jan 26, 2025 · 10 comments
Open

[apps] Pretty print the fidelity bonds #389

mojoX911 opened this issue Jan 26, 2025 · 10 comments
Labels
enhancement This enhances the code and improves stuffs good first issue issues suitable for early contributors
Milestone

Comments

@mojoX911
Copy link

mojoX911 commented Jan 26, 2025

Currently we are debug displaying the FidelityBond struct. Which is too verbose. Instead, we should pretty print the following json.

{
    outpoint: Txid:vout
    amount: u64
    bond-value: u64
    expires-in: u32
 }

where

bond-value = wallet.calculate_bond_value()
expires-in = lock_time - conf_height

@mojoX911 mojoX911 added the enhancement This enhances the code and improves stuffs label Jan 26, 2025
@mojoX911 mojoX911 added this to the v0.1.1 milestone Jan 26, 2025
@Levi0804
Copy link

Levi0804 commented Jan 28, 2025

I was wondering if a custom Debug implementation might be a good fit here. What do you think?

@mojoX911
Copy link
Author

mojoX911 commented Feb 1, 2025

I was wondering if a custom Debug implementation might be a good fit here. What do you think?

It will be a good fit here. ACK. You want a custom Display, not Debug.

@mojoX911 mojoX911 added the good first issue issues suitable for early contributors label Feb 6, 2025
@cyberhumble
Copy link

cyberhumble commented Feb 6, 2025

@mojoX911 for calculating bond-value we need to do some rpc calls (see the method calculate_bond_value for Wallet), for using that method we need to load or initialize a wallet in a "path" and provide a RPCCConfig, what makes impossible IMO the implementation of the Display trait for obtaining the desired output, since we dont have a wallet instance in the FidelityBond struct or at least rpc.

We can create a cutom print method that takes a &Wallet as a parameter, or add rpc capabilities to the FidelityBond, or maybe I am missing something, Am I right?

@mojoX911
Copy link
Author

mojoX911 commented Feb 7, 2025

Yes, you are right. Bond value calculation requires RPC. We can have a workaround than Display trait. We can have a function in the wallet called display_fidelity_bonds. The wallet has rpc access as well as fidelity bond data. So that function can include everything it needs.

We have access to the wallet at the maker app, so we can directly call that function to print the bonds.

@cyberhumble
Copy link

cyberhumble commented Feb 7, 2025

expires-in = lock_time - conf_height
@mojoX911
It should be expires-in=lock_time - current_height (instead of conf_height) or Am I wrong? If not, expires-in is static, it never moves, it never expires, since lock_time and conf_height are fixed values. In case that the locktime is expressed as seconds, we should use median time past or the latest block timestamp to infer the expected expiration block height?.
Note: I am assuming that expires-in is a block height and not a timestamp

cyberhumble added a commit to cyberhumble/coinswap that referenced this issue Feb 7, 2025
@cyberhumble
Copy link

I made a pull request, if something is not ok, give me a feedback please.

@mojoX911
Copy link
Author

mojoX911 commented Feb 8, 2025

It should be expires-in=lock_time - current_height (instead of conf_height) or Am I wrong?

You are right, I was wrong.

@cyberhumble
Copy link

I think I did all the requested changes, take a look please when you are available.

@mojoX911
Copy link
Author

mojoX911 commented Feb 8, 2025

It's ready to go once CI passes.

@cyberhumble
Copy link

I think I did all the requested changes, take a look please when you are available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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