Skip to content

Added ability to configure AMP2 client connection#143

Open
kevandee wants to merge 2 commits intoBlockstream:masterfrom
kevandee:feature/configurable-amp2-client
Open

Added ability to configure AMP2 client connection#143
kevandee wants to merge 2 commits intoBlockstream:masterfrom
kevandee:feature/configurable-amp2-client

Conversation

@kevandee
Copy link

No description provided.

@LeoComandini
Copy link
Contributor

LeoComandini commented Mar 17, 2026

In commit b39bc8f "Removed unnecessary constants in config", you're removing stuff that you added in your previous commit.

Please clean up your commits before submitting for review.

@LeoComandini
Copy link
Contributor

We have an internal gitlab ci, you should submit PR there (too).

@LeoComandini
Copy link
Contributor

You're doing changes to both "wollet" and "app/cli" crate.
Use different commit for those,
also use prefixes and imperative (add not added) in commit message, eg

  • "wollet: amp2: add new"
  • "app/cli: amp2: ..."

See git history for reference.

@LeoComandini
Copy link
Contributor

Why are you doing the change for "app/cli",
are you using it in your tests?
if you're not using, I'd rather not exposing the option in the cli


impl Amp2 {
/// Create a new AMP2 client
pub fn new(server_key: String, url: String) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is very easy to misuse,
what the server key should be? docs should mention it
if the server_key is wrong/has a typo, which function fails?

Copy link
Author

Choose a reason for hiding this comment

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

I will add the validation for the variables. I left the naming the same as the fields in the structure, but yes, I will update the docs too.

Method::Amp2Descriptor => {
let r: request::Amp2Descriptor = serde_json::from_value(params)?;
let mut s = state.lock()?;
if !matches!(s.config.network, lwk_wollet::ElementsNetwork::LiquidTestnet) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why are you removing this?

do you need to enable regtest? if this is your intent, state it explicitly

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I'm using the regtest to test everything locally. And also, now, I'm declining only the mainnet network - https://github.com/kevandee/lwk/blob/feature/configurable-amp2-client/lwk_app/src/config.rs#L150-L153

Copy link
Author

Choose a reason for hiding this comment

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

And yes, I'm using the CLI and app for manual tests, that's the fastest way for me to debug the proxy

Copy link
Contributor

Choose a reason for hiding this comment

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

if you're adding regtest support, commit message should mention it.

config.server_url = url;
} else if let Network::Regtest = args.network {
anyhow::bail!("on regtest you have to specify --electrum-url");
anyhow::bail!("on regtest you have to specify --server-url");
Copy link
Contributor

Choose a reason for hiding this comment

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

when you do unrelated fixes, do them in a separate commit

} else if let Network::Regtest = args.network {
anyhow::bail!("on regtest you have to specify --amp2-keyorigin-xpub");
}

Copy link
Contributor

Choose a reason for hiding this comment

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

when you extend lwk_cli functionalities, you should also extend lwk_cli tests to cover what you have added

@LeoComandini
Copy link
Contributor

if we want to allow callers to set amp2 url and xpub in app/cli, then you need to do the changes also on bindings and wasm

pub timeout: Duration,
pub scanning_interval: Duration,

pub amp2_url: Option<String>,
Copy link
Contributor

@LeoComandini LeoComandini Mar 17, 2026

Choose a reason for hiding this comment

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

these should be string for consistency with the other fields (none of them is option)

    pub amp2_url: String,
    pub amp2_keyorigin_xpub: String,

let amp_keyorigin_xpub = self.amp2_keyorigin_xpub
.clone()
.ok_or_else(|| Error::Generic(
"AMP2 methods are not available. AMP2 connection is not configured properly: missing amp_keyorigin_xpub".into()
Copy link
Contributor

Choose a reason for hiding this comment

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

error messages should suggest how to fix the issue, here you should speficy which flag should be passed

if let Some(amp2_url) = amp2_url {
config.amp2_url = Some(amp2_url);
} else if let Network::Regtest = args.network {
anyhow::bail!("on regtest you have to specify --amp2-url");
Copy link
Contributor

Choose a reason for hiding this comment

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

If I dont plan to do any amp2 calls, I should not be forced to specify this flag/option/param

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.

2 participants