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

Implement returning payment hash (#1159) #1166

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Patti88
Copy link

@Patti88 Patti88 commented Feb 12, 2025

No description provided.

Copy link
Contributor

@JssDWt JssDWt left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

There's quite a few changes unrelated to the PR. Some I've listed in comments. The following files shouldn't need any changes, can you remove those changes please?

Please remove the changes to

  • .gitignore
  • libs/Cargo.lock
  • libs/sdk-bindings/bindings-android/buildForJitpack.sh
  • libs/sdk-bindings/bindings-android/gradle/wrapper/gradle-wrapper.jar
  • libs/sdk-bindings/bindings-android/gradlew
  • libs/sdk-bindings/bindings-android/gradlew.bat
  • libs/sdk-bindings/bindings-csharp/src/.gitignore
  • libs/sdk-bindings/bindings-csharp/src/Breez.Sdk.csproj
  • libs/sdk-bindings/bindings-csharp/test/.gitignore
  • libs/sdk-bindings/bindings-csharp/test/Program.cs
  • libs/sdk-bindings/bindings-csharp/test/sdk-cs-demo.csproj
  • libs/sdk-bindings/bindings-kotlin-multiplatform/gradle/wrapper/gradle-wrapper.jar
  • libs/sdk-bindings/bindings-kotlin-multiplatform/gradlew
  • libs/sdk-bindings/bindings-kotlin-multiplatform/gradlew.bat
  • libs/sdk-bindings/tests/bindings/csharp/.gitignore
  • libs/sdk-bindings/tests/bindings/csharp/Program.cs
  • libs/sdk-bindings/tests/bindings/csharp/sdk-cs-demo.csproj
  • libs/sdk-common/Cargo.toml
  • libs/sdk-common/build.rs
  • libs/sdk-common/src/breez_server.rs
  • libs/sdk-common/src/buy/moonpay.rs
  • libs/sdk-common/src/fiat.rs
  • libs/sdk-common/src/grpc/breez.rs
  • libs/sdk-common/src/grpc/mod.rs
  • libs/sdk-common/src/grpc/proto/breez.proto
  • libs/sdk-common/src/model.rs
  • libs/sdk-core/src/breez_services.rs
  • libs/sdk-core/src/persist/send_pays.rs
  • libs/sdk-core/src/swap_out/reverseswap.rs
  • libs/sdk-react-native/android/gradle/wrapper/gradle-wrapper.jar
  • libs/sdk-react-native/android/gradlew
  • libs/sdk-react-native/android/gradlew.bat
  • libs/sdk-react-native/example/android/gradle/wrapper/gradle-wrapper.jar
  • libs/sdk-react-native/example/android/gradlew
  • libs/sdk-react-native/example/android/gradlew.bat

Perhaps you were targeting the wrong branch with your PR?

Comment on lines +2 to +9
string src_node_id;
string short_channel_id;
u32 fees_base_msat;
u32 fees_proportional_millionths;
u64 cltv_expiry_delta;
u64? htlc_minimum_msat;
u64? htlc_maximum_msat;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

This whitespace change is not needed

Payment payment;
Optional<SuccessActionProcessed> success_action;
Copy link
Contributor

Choose a reason for hiding this comment

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

The success_action field doesn't need a change here? Does the order matter?
At least it should be SuccessActionProcessed? success_action;

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for catching that! You're right, the correct syntax should be SuccessActionProcessed? success_action; to use UDL's optional syntax.

@@ -918,7 +918,7 @@ interface BlockingBreezServices {

[Throws=SdkError]
SwapInfo? in_progress_swap();

Copy link
Contributor

Choose a reason for hiding this comment

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

Whitespace change not needed

@@ -974,7 +974,7 @@ interface BlockingBreezServices {
PrepareRedeemOnchainFundsResponse prepare_redeem_onchain_funds(PrepareRedeemOnchainFundsRequest req);
};

namespace breez_sdk {
namespace breez_sdk {
Copy link
Contributor

Choose a reason for hiding this comment

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

Whitespace change not needed

},
LnUrlPayResult::EndpointSuccess { data } => {
let expected_hash = inv.payment_hash().to_hex();
assert_eq!(data.payment_hash, expected_hash);
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -26,6 +26,7 @@ pub enum LnUrlPayResult {
pub struct LnUrlPaySuccessData {
pub payment: Payment,
pub success_action: Option<SuccessActionProcessed>,
pub payment_hash: String, // Add payment_hash field
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub payment_hash: String, // Add payment_hash field
pub payment_hash: String,

@@ -659,6 +659,7 @@ pub enum PaymentStatus {
#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
pub struct Payment {
pub id: String,
pub payment_hash: String, // Explicitly adding the payment_hash field
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub payment_hash: String, // Explicitly adding the payment_hash field
pub payment_hash: String,

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for your feedback! I see your point about the payment_hash, but it's actually supposed to be there. It's how we keep track of each payment.

@Patti88
Copy link
Author

Patti88 commented Feb 18, 2025

Hi @JssDWt, thank you for the review, I have fixed the success_action type, removed the extra payment_hash field in lnurl/pay.rs, and confirmed that the payment_hash in models.rs is correct. I've also reverted the changes to the unrelated files you pointed out.

@JssDWt
Copy link
Contributor

JssDWt commented Feb 18, 2025

@Patti88 If you look at the 'files changed' tab, there's still 38 changed files. Can you bring that down to only the relevant files? When that's done please squash the commits in a single commit. You could use Github Desktop for example, it has a nice diff viewer and allows you to squash commits by selecting them and right-clicking.

@roeierez
Copy link
Member

The diff is still very large and not relevant.
Also @Patti88 I see your comment here: #1159 (comment)
The comment was about reverse swap and this PR is about lnurl. Was that the intention?
Asking also because the Payment object already contains the payment hash (inside PaymentDetails when relevant) so I am not sure there is a need to do something for lightning/lnurl payments.

@JssDWt
Copy link
Contributor

JssDWt commented Feb 19, 2025

I see the diff has been much improved. Now I can see the trees in the forest. Let me review the code.

You're creating a fix for this issue.
The goal in that issue is to return the payment hash from the claim_reverse_swap function.

That function is here in the udl file. It should return a response object, rather than void.

The corresponding function implementation is here. That should return that new object. You can retrieve the payment hash by hashing the preimage, or decoding the invoice. Decoding the invoice is probably the preferred way.

Currently this PR changes the response of the lnurl_pay function, but the payment hash is already included in the returned payment there.

I would suggest to start fresh with this PR, implementing the required changes for the mentioned issue.

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.

3 participants