Skip to content

Commit

Permalink
Merge pull request #666 from breez/ok300-add-feerate-arg-create-invoice
Browse files Browse the repository at this point in the history
Add fee params arg to createInvoice
  • Loading branch information
ok300 authored Oct 10, 2023
2 parents d4e9e5f + 8308ef9 commit e398efa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/bloc/account/account_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,11 @@ class AccountBloc extends Cubit<AccountState> with HydratedMixin {
Future<sdk.ReceivePaymentResponse> addInvoice({
String description = "",
required int amountSats,
required sdk.OpeningFeeParams? chosenFeeParams,
}) async {
_log.fine("addInvoice: $description, $amountSats");

final requestData = sdk.ReceivePaymentRequest(amountSats: amountSats, description: description);
final requestData = sdk.ReceivePaymentRequest(amountSats: amountSats, description: description, openingFeeParams: chosenFeeParams);
final responseData = await _breezLib.receivePayment(reqData: requestData);
return responseData;
}
Expand Down
10 changes: 7 additions & 3 deletions lib/routes/create_invoice/create_invoice_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ class CreateInvoicePageState extends State<CreateInvoicePage> {
Widget build(BuildContext context) {
final texts = context.texts();

final lspState = context.watch<LSPBloc>().state;
final cheapestFeeParams = lspState?.lspInfo?.openingFeeParamsList.values.first;
final isChannelOpeningAvailable = lspState?.isChannelOpeningAvailable ?? false;

return Scaffold(
key: _scaffoldKey,
appBar: AppBar(
Expand Down Expand Up @@ -123,7 +127,6 @@ class CreateInvoicePageState extends State<CreateInvoicePage> {
builder: (context, accountState, currencyState, lspState) {
return ReceivableBTCBox(
onTap: () {
final isChannelOpeningAvailable = lspState?.isChannelOpeningAvailable ?? false;
if (!isChannelOpeningAvailable && accountState.maxInboundLiquidity > 0) {
_amountController.text = currencyState.bitcoinCurrency.format(
accountState.maxInboundLiquidity,
Expand Down Expand Up @@ -158,7 +161,7 @@ class CreateInvoicePageState extends State<CreateInvoicePage> {
if (data != null) {
_withdraw(context, data);
} else {
_createInvoice(context);
_createInvoice(context, cheapestFeeParams);
}
}
},
Expand Down Expand Up @@ -191,7 +194,7 @@ class CreateInvoicePageState extends State<CreateInvoicePage> {
);
}

Future _createInvoice(BuildContext context) async {
Future _createInvoice(BuildContext context, OpeningFeeParams? cheapestFeeParams) async {
_log.fine("Create invoice: description=${_descriptionController.text}, amount=${_amountController.text}");
final navigator = Navigator.of(context);
final currentRoute = ModalRoute.of(navigator.context)!;
Expand All @@ -201,6 +204,7 @@ class CreateInvoicePageState extends State<CreateInvoicePage> {
Future<ReceivePaymentResponse> receivePaymentResponse = accountBloc.addInvoice(
description: _descriptionController.text,
amountSats: currencyBloc.state.bitcoinCurrency.parse(_amountController.text),
chosenFeeParams: cheapestFeeParams
);
navigator.pop();
Widget dialog = FutureBuilder(
Expand Down

0 comments on commit e398efa

Please sign in to comment.