Skip to content

Improving currencyrate plugin#9011

Merged
daywalker90 merged 4 commits into
ElementsProject:masterfrom
enaples:improve-currencyrate-plugin
May 11, 2026
Merged

Improving currencyrate plugin#9011
daywalker90 merged 4 commits into
ElementsProject:masterfrom
enaples:improve-currencyrate-plugin

Conversation

@enaples
Copy link
Copy Markdown
Collaborator

@enaples enaples commented Mar 31, 2026

Important

26.04 FREEZE March 11th: Non-bugfix PRs not ready by this date will wait for 26.06.

RC1 is scheduled on March 23rd

The final release is scheduled for April 15th.

Checklist

Before submitting the PR, ensure the following tasks are completed. If an item is not applicable to your PR, please mark it as checked:

  • The changelog has been updated in the relevant commit(s) according to the guidelines.
  • Tests have been added or modified to reflect the changes.
  • Documentation has been reviewed and updated as needed.
  • Related issues have been listed and linked, including any that this PR closes.
  • Important All PRs must consider how to reverse any persistent changes for tools/lightning-downgrade

Currencyrate plugin changes

As mentioned in #9010,

  1. Check on RPC argument number added
  2. Show max three decimal digits
  3. Added source argument to the currencyrate RPC call
  4. Added "Example" on RPC documentation

Info Needed

I would personally suggest to add a README.md file in the currencyrate plugin folder reporting how to configure new sources in the config file, plus some best practice using reckless to add and disable sources without restarting the node.

@enaples enaples requested a review from daywalker90 March 31, 2026 15:11
@enaples enaples added this to the 26.06 milestone Mar 31, 2026
@enaples enaples changed the title plugin: round to the tird digit and adding source argument to `curren… Improving currencyrate plugin Mar 31, 2026
@enaples enaples linked an issue Mar 31, 2026 that may be closed by this pull request
@sangbida sangbida removed the 26.04 RC label Apr 1, 2026
Comment thread plugins/currencyrate-plugin/src/main.rs
@daywalker90 daywalker90 force-pushed the improve-currencyrate-plugin branch from 1f75db1 to 3ef67e3 Compare April 2, 2026 08:15
@daywalker90 daywalker90 requested a review from cdecker as a code owner April 2, 2026 08:15
@daywalker90 daywalker90 force-pushed the improve-currencyrate-plugin branch from 3ef67e3 to d945873 Compare April 2, 2026 08:16
Comment thread contrib/msggen/msggen/schema.json
@daywalker90 daywalker90 force-pushed the improve-currencyrate-plugin branch from d945873 to 1a74aaa Compare April 2, 2026 08:27
@daywalker90
Copy link
Copy Markdown
Collaborator

I would personally suggest to add a README.md file in the currencyrate plugin folder reporting how to configure new sources in the config file

We can do that, but personally i go to https://docs.corelightning.org/reference/lightningd-config first to see documentation on config options and we have the currencyrate options with instructions on how they need to be written included there.

, plus some best practice using reckless to add and disable sources without restarting the node.

No sure if it can be done with reckless but it can be done with just the plugin command e.g.:

lightning-cli plugin stop cln-currencyrate

then to add a source:

lightning-cli plugin -k subcommand=start plugin=/media/addonssd/dev/lightning/plugins/cln-currencyrate currencyrate-add-source="test,https://test.com/{currency},rate"

But keep in mind that afaik any events happening while the plugin is stopped will have their currencyrate missing.

Comment thread plugins/currencyrate-plugin/src/main.rs Outdated
.to_owned();
(amount, currency.to_uppercase())
}
Value::Object(map) => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We should then also do the same check for object based queries here aswell.

Comment thread plugins/currencyrate-plugin/src/main.rs
Comment thread plugins/currencyrate-plugin/src/main.rs Outdated
.to_owned();
currency.to_uppercase()
}
Value::Object(map) => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We should then also do the same check for object based queries here aswell.

Comment thread plugins/currencyrate-plugin/src/main.rs Outdated
.to_owned();
currency.to_uppercase()
.to_uppercase();
let source = values.get(1).and_then(|v| v.as_str()).map(str::to_owned);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We do allow sources to be named as numbers only and this would then cause currencyrate to silently ignore the sourrce and return a median result. I suggest changing this to:

let source = values.get(1).and_then(|v| {
                v.as_str()
                    .map(str::to_owned)
                    .or_else(|| v.as_number().map(std::string::ToString::to_string))
            });

Comment thread plugins/currencyrate-plugin/src/main.rs Outdated
.to_owned();
currency.to_uppercase()
.to_uppercase();
let source = map.get("source").and_then(|v| v.as_str()).map(str::to_owned);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same as above:

let source = map.get("source").and_then(|v| {
                v.as_str()
                    .map(str::to_owned)
                    .or_else(|| v.as_number().map(std::string::ToString::to_string))
            });

@daywalker90
Copy link
Copy Markdown
Collaborator

Usually we would use setconfig to change options dynamically but since here we have multi options it's not possible until something like #8751. Then we could change sources without restarting the plugin or node or extra rpc methods(yikes).

@daywalker90 daywalker90 force-pushed the improve-currencyrate-plugin branch from aac28b1 to a674020 Compare April 17, 2026 11:10
@madelinevibes madelinevibes added the QA Blockstream QA team have reproduced, or a test has been created! Look for the linked PR/Issue label May 4, 2026
@daywalker90 daywalker90 force-pushed the improve-currencyrate-plugin branch 2 times, most recently from e4e549e to 7481f1b Compare May 11, 2026 08:24
@daywalker90 daywalker90 enabled auto-merge (rebase) May 11, 2026 08:27
enaples added 4 commits May 11, 2026 13:27
Changelog-Added: `currencyrate` can now take a `source` argument to get the rate of a specific source
@daywalker90 daywalker90 force-pushed the improve-currencyrate-plugin branch from 7481f1b to 28419c3 Compare May 11, 2026 11:27
@daywalker90 daywalker90 merged commit fdce487 into ElementsProject:master May 11, 2026
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

QA Blockstream QA team have reproduced, or a test has been created! Look for the linked PR/Issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

currencyrate plugin UI improvement proposals

5 participants