lnbits-legend/lnbits/extensions/lndhub/utils.py

22 lines
609 B
Python
Raw Normal View History

2020-08-31 16:18:05 -03:00
from binascii import unhexlify
from lnbits.bolt11 import Invoice
def to_buffer(payment_hash: str):
return {"type": "Buffer", "data": [b for b in unhexlify(payment_hash)]}
def decoded_as_lndhub(invoice: Invoice):
return {
"destination": invoice.payee,
"payment_hash": invoice.payment_hash,
"num_satoshis": invoice.amount_msat / 1000,
"timestamp": str(invoice.date),
"expiry": str(invoice.expiry),
"description": invoice.description,
"fallback_addr": "",
"cltv_expiry": invoice.min_final_cltv_expiry,
"route_hints": "",
}