-
Notifications
You must be signed in to change notification settings - Fork 41
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
Return success on failure to decrypt AES success action #637
Conversation
libs/sdk-core/src/lnurl/pay.rs
Outdated
@@ -236,7 +236,9 @@ pub(crate) mod model { | |||
/// See [SuccessAction::Aes] for received payload | |||
/// | |||
/// See [AesSuccessActionDataDecrypted] for decrypted payload | |||
Aes { data: AesSuccessActionDataDecrypted }, | |||
Aes { | |||
result: Result<AesSuccessActionDataDecrypted, String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a good idea to use Reslut
for that? If yes, how do I convert it into dart?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Result
is a good direction, try to use aResult
-like enum with an inner field. These play better with bindings and uniffi AFAIK.
Something like
pub enum AesSuccessActionDataResult {
Decrypted { data: AesSuccessActionDataDecrypted },
Error { data: String }
}
To propagate the changes to the bindings for other languages, you'd have to
- update
breez_sdk.udl
with the new fields - run
cargo build
insdk-bindings
- run
make init
/make dev
insdk-flutter
- run the command listed in the README of https://github.com/breez/breez-sdk-rn-generator
abc9b80
to
80f7b79
Compare
80f7b79
to
55ae92a
Compare
If there is an AES success action in `payRequest` (LUD-10) then failure to decrypt ciphertext should not fail the payment, since the funds were actually sent and the lightning payment has succeeded.
55ae92a
to
10df4e5
Compare
The PR is ready for review, I went with pub enum AesSuccessActionDataResult {
Decrypted { data: AesSuccessActionDataDecrypted },
ErrorStatus { data: String },
} Bindings and other stuff were generated with some help from @dleutenegger. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good I think, just some comments around the error variant variables
libs/sdk-core/src/lnurl/pay.rs
Outdated
#[derive(PartialEq, Eq, Debug, Clone, Deserialize, Serialize)] | ||
pub enum AesSuccessActionDataResult { | ||
Decrypted { data: AesSuccessActionDataDecrypted }, | ||
ErrorStatus { data: String }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's more consistent to call this reason
instead of data
with a string
ErrorStatus { data: String }, | |
ErrorStatus { reason: String }, |
or use LnUrlErrorData
like in LnUrlWithdrawResult
and LnUrlCallbackStatus
ErrorStatus { data: String }, | |
ErrorStatus { data: LnUrlErrorData }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed data
to reason
. There is no need to use LnUrlErrorData
here, because the payment hash will be returned in:
Ok(LnUrlPayResult::EndpointSuccess {
data: LnUrlPaySuccessData {
payment_hash: details.payment_hash.clone(),
success_action: maybe_sa_processed,
},
})
and maybe_sa_processed
will have AesSuccessActionDataResult::ErrorStatus
.
321c120
to
2b44bfb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Could you please also add a short test case for when decryption fails?
There is test_lnurl_pay_aes_success_action
that covers the success scenario, I imagine a similar one can check the new result type in case of failed decryption.
I added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, I missed it.
Then it's all good!
You haven't missed it, I added it after you asked. Do not trust git commit time ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
If there is an AES success action in
payRequest
(LUD-10) then failure to decrypt ciphertext should not fail the payment, since the funds were actually sent and the lightning payment has succeeded.Solves #632.