Skip to content

Changes for lightning_payjoin integration - #233

Closed
jbesraa wants to merge 4 commits into
payjoin:masterfrom
jbesraa:lightning-changes
Closed

jbesraa wants to merge 4 commits into
payjoin:masterfrom
jbesraa:lightning-changes

Conversation

@jbesraa

@jbesraa jbesraa commented Apr 16, 2024 •

Copy link
Copy Markdown
Contributor

Here are few commits I have while working on the payjoin integration with ldk_node lightningdevkit/ldk-node#257.

@jbesraa
jbesraa force-pushed the lightning-changes branch 6 times, most recently from 9869bbc to 9e4f454 Compare April 18, 2024 09:10
@jbesraa
jbesraa force-pushed the lightning-changes branch from 9e4f454 to 241947a Compare May 8, 2024 12:30
BadRequest(RequestError),
// To be returned as HTTP 500
Server(Box<dyn error::Error>),
Server(Box<dyn error::Error + 'static + Sync + Send>),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I dont think I need this anymore, but would be nice to leave it I guess

@jbesraa
jbesraa marked this pull request as ready for review May 8, 2024 12:32
@jbesraa
jbesraa requested a review from DanGould May 8, 2024 12:33
@DanGould

DanGould commented May 8, 2024

Copy link
Copy Markdown
Member

All of these changes are new API surface. I imagine some of these will be required but others might be able to be worked around. May you please enumerate why each change is required or is a better design? I'd especially like to better understand the changes that affect type/method visibility.

I think #69 might be better to fix with a dedicated PR designed to fix the problem in general, allowing for substitution of the original payment output with any number of outputs, rather than an additional substitution method that increases the surface area of the API. Glad you're having success finding compatiblity with lightning payjoin integration in any case.

Comment thread payjoin/src/lib.rs
#[cfg(feature = "base64")]
pub use bitcoin::base64;
pub use uri::{PjParseError, PjUri, PjUriBuilder, Uri};
pub use uri::{MaybePayjoinExtras, PjParseError, PjUri, PjUriBuilder, Uri};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is useful in testing where we want to mutate the pjuri in order to change test direction(ie start with a pj uri and then maybe change it to something different) example: https://github.com/lightningdevkit/ldk-node/pull/257/files#diff-ebba69f49eedcd3dd6a656eff964c6184b6d29c02fbad6a49d3b41c87cc3de79R192

Comment thread payjoin/src/uri.rs
#[derive(Clone)]
pub struct PayjoinExtras {
pub(crate) endpoint: Url,
pub endpoint: Url,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is useful in testing where we want to mutate the pjuri in order to change test direction(ie start with a pj uri and then maybe change it to something different) example: https://github.com/lightningdevkit/ldk-node/pull/257/files#diff-ebba69f49eedcd3dd6a656eff964c6184b6d29c02fbad6a49d3b41c87cc3de79R192

self.payjoin_psbt.unsigned_tx.output[self.owned_vouts[0]].script_pubkey = script;
}

/// payjoin request value in satoshis

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

}

fn proposal_from_test_vector() -> Result<UncheckedProposal, RequestError> {
fn proposal_from_test_vector() -> Result<UncheckedProposal, Error> {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Makes it easier to integrate testing, otherwise we would need to handle RequestError in downstream in addition to Error which we already need to deal with

@jbesraa

jbesraa commented May 8, 2024

Copy link
Copy Markdown
Contributor Author

@DanGould added a comment on each commit
regarding the output substitution, am i right to think you mean something like the following?

pub fn substitue_our_output(&mut self, txo: TxOut) {
    self.payjoin_psbt.unsigned_tx.output[self.owned_vouts[0]] = txo;
}

@DanGould

DanGould commented May 8, 2024 •

Copy link
Copy Markdown
Member

You should be able to substitute the output with many outputs at random index, not just one. I'm not exactly sure what that interface looks like yet.

I assume this will require adjustment to both the psbt.unsigned_tx output map and the psbt.outputs map.

@jbesraa
jbesraa force-pushed the lightning-changes branch from 241947a to b3770f6 Compare May 10, 2024 12:28
@jbesraa

jbesraa commented May 10, 2024

Copy link
Copy Markdown
Contributor Author

Took out the substitute_output_script commits

@jbesraa jbesraa closed this May 11, 2024
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