1
0

lnonion: add total_msat to onion payment data

This commit is contained in:
bitromortac
2021-02-19 08:34:03 +01:00
parent 613bab145d
commit 9f84fa9580
4 changed files with 25 additions and 9 deletions

View File

@@ -261,7 +261,7 @@ def new_onion_packet(payment_path_pubkeys: Sequence[bytes], session_key: bytes,
hmac=next_hmac)
def calc_hops_data_for_payment(route: 'LNPaymentRoute', amount_msat: int,
def calc_hops_data_for_payment(route: 'LNPaymentRoute', amount_msat: int, total_msat: int,
final_cltv: int, *, payment_secret: bytes = None) \
-> Tuple[List[OnionHopsDataSingle], int, int]:
"""Returns the hops_data to be used for constructing an onion packet,
@@ -277,8 +277,14 @@ def calc_hops_data_for_payment(route: 'LNPaymentRoute', amount_msat: int,
"amt_to_forward": {"amt_to_forward": amt},
"outgoing_cltv_value": {"outgoing_cltv_value": cltv},
}
# for multipart payments we need to tell the reciever about the total and
# partial amounts
if payment_secret is not None:
hop_payload["payment_data"] = {"payment_secret": payment_secret, "total_msat": amt}
hop_payload["payment_data"] = {
"payment_secret": payment_secret,
"total_msat": total_msat,
"amount_msat": amt
}
hops_data = [OnionHopsDataSingle(is_tlv_payload=route[-1].has_feature_varonion(),
payload=hop_payload)]
# payloads, backwards from last hop (but excluding the first edge):