-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Validate LnUrl payments against lightning limits * Rename isLnurlPayment to isLnUrlPayment for consistency of capitalization of LnUrl
- Loading branch information
1 parent
8859315
commit a67a108
Showing
9 changed files
with
114 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import 'package:flutter_breez_liquid/flutter_breez_liquid.dart'; | ||
import 'package:hydrated_bloc/hydrated_bloc.dart'; | ||
import 'package:l_breez/bloc/account/breez_sdk_liquid.dart'; | ||
import 'package:l_breez/bloc/lnurl/lnurl_state.dart'; | ||
import 'package:logging/logging.dart'; | ||
|
||
class LnUrlBloc extends Cubit<LnUrlState> { | ||
final _log = Logger("LnUrlBloc"); | ||
final BreezSDKLiquid _liquidSdk; | ||
|
||
LnUrlBloc(this._liquidSdk) : super(LnUrlState.initial()); | ||
|
||
Future<LightningPaymentLimitsResponse> fetchLightningLimits() async { | ||
try { | ||
final limits = await _liquidSdk.instance!.fetchLightningLimits(); | ||
emit(state.copyWith(limits: limits)); | ||
return limits; | ||
} catch (e) { | ||
_log.severe("fetchLightningLimits error", e); | ||
rethrow; | ||
} | ||
} | ||
|
||
Future<LnUrlWithdrawResult> lnurlWithdraw({ | ||
required LnUrlWithdrawRequest req, | ||
}) async { | ||
try { | ||
return await _liquidSdk.instance!.lnurlWithdraw(req: req); | ||
} catch (e) { | ||
_log.severe("lnurlWithdraw error", e); | ||
rethrow; | ||
} | ||
} | ||
|
||
Future<LnUrlPayResult> lnurlPay({ | ||
required LnUrlPayRequest req, | ||
}) async { | ||
try { | ||
return await _liquidSdk.instance!.lnurlPay(req: req); | ||
} catch (e) { | ||
_log.severe("lnurlPay error", e); | ||
rethrow; | ||
} | ||
} | ||
|
||
Future<LnUrlCallbackStatus> lnurlAuth({ | ||
required LnUrlAuthRequestData reqData, | ||
}) async { | ||
try { | ||
return await _liquidSdk.instance!.lnurlAuth(reqData: reqData); | ||
} catch (e) { | ||
_log.severe("lnurlAuth error", e); | ||
rethrow; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import 'package:flutter_breez_liquid/flutter_breez_liquid.dart'; | ||
|
||
class LnUrlState { | ||
final LightningPaymentLimitsResponse? limits; | ||
|
||
LnUrlState({this.limits}); | ||
|
||
LnUrlState.initial() : this(); | ||
|
||
LnUrlState copyWith({ | ||
LightningPaymentLimitsResponse? limits, | ||
}) { | ||
return LnUrlState( | ||
limits: limits ?? this.limits, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters