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

Configure asset metadata #659

Open
wants to merge 3 commits into
base: savage-multi-assets
Choose a base branch
from

Conversation

dangeross
Copy link
Collaborator

Builds on PR #645

This PR:

  • adds default asset metadata for Liquid Bitcoin and Tether USD
  • adds asset metadata if available into the payment details and get_info response
  • parses the BIP21 URI and adjusts the amount_sats precision to the asset metadata
  • adds to the Config the option to add asset metadata for additional supported assets

Depends on breez/breez-sdk-greenlight#1157

@roeierez
Copy link
Member

I have to admit at first I thought we should provide a larger list of assets but this minimal approach is more appealing now.
Having a default of a minimal list of assets and let the user define more may work better as a start.
@kingonly what do you think? Can we start with lbtc and usdt as built in assets?

@kingonly
Copy link
Member

Yes

@dangeross dangeross marked this pull request as ready for review January 15, 2025 13:00
use super::{AssetMetadata, Persister};

impl Persister {
pub(crate) fn replace_asset_metadata(
Copy link
Member

Choose a reason for hiding this comment

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

Can you elaborate what is the advantage of persisting the configurable assets?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For rendering the payment list, it seems simpler to add them to the SQL join

Copy link
Contributor

@danielgranhao danielgranhao left a comment

Choose a reason for hiding this comment

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

Still reviewing, but will have to finish later, so here's what I got for now :)

lib/bindings/src/breez_sdk_liquid.udl Outdated Show resolved Hide resolved
lib/bindings/src/breez_sdk_liquid.udl Show resolved Hide resolved
Comment on lines 1488 to 1487
impl AssetMetadata {
pub fn to_sat(&self, amount: f64) -> u64 {
(amount * (10_u64.pow(self.precision) as f64)) as u64
}

pub fn from_sat(&self, amount_sat: u64) -> f64 {
amount_sat as f64 / (10_u64.pow(self.precision) as f64)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: this is a bit unconventional. Maybe we could have an AssetAmount struct with these methods.

lib/core/src/model.rs Outdated Show resolved Hide resolved
@dangeross dangeross force-pushed the savage-multi-assets branch 2 times, most recently from 36f9697 to 289d61f Compare January 17, 2025 19:54
@dangeross dangeross force-pushed the savage-asset-metadata branch 2 times, most recently from dbc649c to e01ea48 Compare January 17, 2025 21:13
@dangeross dangeross force-pushed the savage-multi-assets branch from 289d61f to 4dfef3b Compare January 20, 2025 09:15
@dangeross dangeross force-pushed the savage-asset-metadata branch from e01ea48 to 2e7501a Compare January 20, 2025 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants