Fee reserve for lightning backends (#557)

* preparing fees

* fee_limit_msat

* await resp result

* clightning

* fix tests

* fix test

* add fee to test

* mypy

* invoice_status

* checking id fix

* fee reserve error message

* only for external payments
This commit is contained in:
calle
2022-03-16 07:20:15 +01:00
committed by GitHub
parent 911fe92e03
commit 0f97f8f18b
15 changed files with 129 additions and 84 deletions

View File

@@ -9,28 +9,42 @@ from lnbits.wallets.base import (
)
from lnbits.settings import WALLET
WALLET.status = AsyncMock(return_value=StatusResponse(
"",# no error
1000000,# msats
))
WALLET.create_invoice = AsyncMock(return_value=InvoiceResponse(
True,# ok
"6621aafbdd7709ca6eea6203f362d64bd7cb2911baa91311a176b3ecaf2274bd",# checking_id (i.e. payment_hash)
"lntb1u1psezhgspp5vcs6477awuyu5mh2vgplxckkf0tuk2g3h253xydpw6e7etezwj7sdqqcqzpgxqyz5vqsp5dxpw8zs77hw5pla4wz4mfujllyxtlpu443auur2uxqdrs8q2h56q9qyyssq65zk30ylmygvv5y4tuwalnf3ttnqjn57ef6rmcqg0s53akem560jh8ptemjcmytn3lrlatw4hv9smg88exv3v4f4lqnp96s0psdrhxsp6pp75q",# payment_request
"",# no error
))
def pay_invoice_side_effect(payment_request: str):
WALLET.status = AsyncMock(
return_value=StatusResponse(
"", # no error
1000000, # msats
)
)
WALLET.create_invoice = AsyncMock(
return_value=InvoiceResponse(
True, # ok
"6621aafbdd7709ca6eea6203f362d64bd7cb2911baa91311a176b3ecaf2274bd", # checking_id (i.e. payment_hash)
"lntb1u1psezhgspp5vcs6477awuyu5mh2vgplxckkf0tuk2g3h253xydpw6e7etezwj7sdqqcqzpgxqyz5vqsp5dxpw8zs77hw5pla4wz4mfujllyxtlpu443auur2uxqdrs8q2h56q9qyyssq65zk30ylmygvv5y4tuwalnf3ttnqjn57ef6rmcqg0s53akem560jh8ptemjcmytn3lrlatw4hv9smg88exv3v4f4lqnp96s0psdrhxsp6pp75q", # payment_request
"", # no error
)
)
def pay_invoice_side_effect(
payment_request: str, fee_limit_msat: int
) -> PaymentResponse:
invoice = bolt11.decode(payment_request)
return PaymentResponse(
True,# ok
invoice.payment_hash,# checking_id (i.e. payment_hash)
0,# fee_msat
"",# no error
True, # ok
invoice.payment_hash, # checking_id (i.e. payment_hash)
0, # fee_msat
"", # no error
)
WALLET.pay_invoice = AsyncMock(side_effect=pay_invoice_side_effect)
WALLET.get_invoice_status = AsyncMock(return_value=PaymentStatus(
True,# paid
))
WALLET.get_payment_status = AsyncMock(return_value=PaymentStatus(
True,# paid
))
WALLET.get_invoice_status = AsyncMock(
return_value=PaymentStatus(
True, # paid
)
)
WALLET.get_payment_status = AsyncMock(
return_value=PaymentStatus(
True, # paid
)
)