1
0

Use attr.s classes for invoices and requests:

- storage upgrade
 - fixes #6192
 - add can_pay_invoice, can_receive_invoice to lnworker
This commit is contained in:
ThomasV
2020-05-31 12:49:49 +02:00
parent 5f527720cf
commit 6058829870
21 changed files with 490 additions and 371 deletions

View File

@@ -13,7 +13,6 @@ from .bitcoin import hash160_to_b58_address, b58_address_to_hash160
from .segwit_addr import bech32_encode, bech32_decode, CHARSET
from . import constants
from . import ecc
from .util import PR_TYPE_LN
from .bitcoin import COIN
@@ -470,20 +469,6 @@ def lndecode(invoice: str, *, verbose=False, expected_hrp=None) -> LnAddr:
def parse_lightning_invoice(invoice):
lnaddr = lndecode(invoice, expected_hrp=constants.net.SEGWIT_HRP)
amount = int(lnaddr.amount * COIN) if lnaddr.amount else None
return {
'type': PR_TYPE_LN,
'invoice': invoice,
'amount': amount,
'message': lnaddr.get_description(),
'time': lnaddr.date,
'exp': lnaddr.get_expiry(),
'pubkey': lnaddr.pubkey.serialize().hex(),
'rhash': lnaddr.paymenthash.hex(),
}
if __name__ == '__main__':
# run using
# python3 -m electrum.lnaddr <invoice> <expected hrp>