Friday, September 20, 2024
HomeBitcoinlightning community - SendToRouteRequest rpc not working in lnd

lightning community – SendToRouteRequest rpc not working in lnd


I am attempting to ship a fee in LND, utilizing the SendToRouteRequest rpc. It doesn’t matter what worth I enter as total_time_lock within the request, I get both EXPIRY_TOO_SOON or EXPIRY_TOO_FAR error.

Under is a concrete instance. I first attempt a sure total_time_lock, and I get error EXPIRY_TOO_SOON. Instantly, I enhance the total_time_lock by 1 (every thing else stays the identical), and I get EXPIRY_TOO_FAR. So, it appears that evidently no worth works.

What am I doing improper?

The code:

node = LightningNode() # object that handles rpc channel initialization

amount_msat=10000000
request = ln.Bill(
  memo='test-invoice',
  value_msat=amount_msat,
  expiry=3600
)
response = node.stub.AddInvoice(request, metadata=node.metadata)
r_hash = response.r_hash

block_height = get_block_count() # returns present block peak
route= {'hops': [{'amt_to_forward_msat': 10014010,
           'chan_capacity': 500000,
           'chan_id': 938853187921707009},
          {'amt_to_forward_msat': 10008020,
           'chan_capacity': 50000000,
           'chan_id': 939936206842560512},
          {'amt_to_forward_msat': 10008020,
           'chan_capacity': 50000000,
           'chan_id': 939936206848786432},
          {'amt_to_forward_msat': 10008010,
           'chan_capacity': 6056127,
           'chan_id': 937025799454982144},
          {'amt_to_forward_msat': 10008000,
           'chan_capacity': 10069462,
           'chan_id': 940502455302291457},
          {'amt_to_forward_msat': 10008000,
           'chan_capacity': 2065297,
           'chan_id': 929527130166001664},
          {'amt_to_forward_msat': 10000000,
           'chan_capacity': 500000,
           'chan_id': 938880675621371905}],
 'total_amt_msat': 10035100,
 'total_fees_msat': 35100,
 'total_time_lock': block_height + 2016}

routerStub = routerstub.RouterStub(node.channel)
send_request = routerrpc.SendToRouteRequest(
  payment_hash=r_hash,
  route=route,
)
pprint(send_request)
response = routerStub.SendToRouteV2(send_request, metadata=node.metadata)
pprint(MessageToDict(response))

route['total_time_lock'] += 1
send_request2 = routerrpc.SendToRouteRequest(
  payment_hash=r_hash,
  route=route,
)
pprint(send_request2)
response = routerStub.SendToRouteV2(send_request2, metadata=node.metadata)
pprint(MessageToDict(response))

request = invoicesrpc.CancelInvoiceMsg(
  payment_hash=r_hash,
)
response = node.invStub.CancelInvoice(request, metadata=node.metadata)

Output:

payment_hash: "30212,30332274percent251/u@ 027025535717G>177!!r/306{h347s[347;"
route {
  total_time_lock: 857929
  hops {
    chan_id: 938853187921707009
    chan_capacity: 500000
    amt_to_forward_msat: 10014010
  }
  hops {
    chan_id: 939936206842560512
    chan_capacity: 50000000
    amt_to_forward_msat: 10008020
  }
  hops {
    chan_id: 939936206848786432
    chan_capacity: 50000000
    amt_to_forward_msat: 10008020
  }
  hops {
    chan_id: 937025799454982144
    chan_capacity: 6056127
    amt_to_forward_msat: 10008010
  }
  hops {
    chan_id: 940502455302291457
    chan_capacity: 10069462
    amt_to_forward_msat: 10008000
  }
  hops {
    chan_id: 929527130166001664
    chan_capacity: 2065297
    amt_to_forward_msat: 10008000
  }
  hops {
    chan_id: 938880675621371905
    chan_capacity: 500000
    amt_to_forward_msat: 10000000
  }
  total_fees_msat: 35100
  total_amt_msat: 10035100
}

{'attemptId': '29703',
 'attemptTimeNs': '1723130821625335738',
 'failure': {'channelUpdate': {'baseFee': 1000,
                               'chainHash': 'b+KMCrbxs3LBpqJGrmP3T5Meg2XhWgicaNYZAAAAAAA=',
                               'chanId': '939936206842560512',
                               'channelFlags': 1,
                               'feeRate': 499,
                               'htlcMaximumMsat': '20000000000',
                               'htlcMinimumMsat': '1',
                               'messageFlags': 1,
                               'signature': 'qoOhVnK1MWRcwbjodVlWLgee5s2TbZUwMI6KPOVATFs9GRJZlP9kpBgT7UWBJs7Vw5QP2jDiH/QMoALI0XUnqA==',
                               'timeLockDelta': 144,
                               'timestamp': 1722473695},
             'code': 'EXPIRY_TOO_SOON',
             'failureSourceIndex': 1},
 'resolveTimeNs': '1723130821953436487',
 'route': {'hops': [{'amtToForward': '10014',
                     'amtToForwardMsat': '10014010',
                     'chanCapacity': '500000',
                     'chanId': '938853187921707009',
                     'fee': '21',
                     'feeMsat': '21090',
                     'pubKey': '03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f',
                     'tlvPayload': True},
                    {'amtToForward': '10008',
                     'amtToForwardMsat': '10008020',
                     'chanCapacity': '50000000',
                     'chanId': '939936206842560512',
                     'fee': '5',
                     'feeMsat': '5990',
                     'pubKey': '02dd3fcdaa17b9bc83bf7138fbea85d0e83385a68b5fc8f9933658c8ee04644f68',
                     'tlvPayload': True},
                    {'amtToForward': '10008',
                     'amtToForwardMsat': '10008020',
                     'chanCapacity': '50000000',
                     'chanId': '939936206848786432',
                     'pubKey': '026165850492521f4ac8abd9bd8088123446d126f648ca35e60f88177dc149ceb2',
                     'tlvPayload': True},
                    {'amtToForward': '10008',
                     'amtToForwardMsat': '10008010',
                     'chanCapacity': '6056127',
                     'chanId': '937025799454982144',
                     'feeMsat': '10',
                     'pubKey': '02972e2342498fa91691dc5efd0deeb3dc7877b2f3d68ba9a698cf276b1d5de6ca',
                     'tlvPayload': True},
                    {'amtToForward': '10008',
                     'amtToForwardMsat': '10008000',
                     'chanCapacity': '10069462',
                     'chanId': '940502455302291457',
                     'feeMsat': '10',
                     'pubKey': '0390b5d4492dc2f5318e5233ab2cebf6d48914881a33ef6a9c6bcdbb433ad986d0',
                     'tlvPayload': True},
                    {'amtToForward': '10008',
                     'amtToForwardMsat': '10008000',
                     'chanCapacity': '2065297',
                     'chanId': '929527130166001664',
                     'pubKey': '034ea80f8b148c750463546bd999bf7321a0e6dfc60aaf84bd0400a2e8d376c0d5',
                     'tlvPayload': True},
                    {'amtToForward': '10000',
                     'amtToForwardMsat': '10000000',
                     'chanCapacity': '500000',
                     'chanId': '938880675621371905',
                     'fee': '8',
                     'feeMsat': '8000',
                     'pubKey': '021a6d7cfefdf74b5112cde8a7e9632478f5c9bc4cc5780d231b11f95710ea7edd',
                     'tlvPayload': True}],
           'totalAmt': '10035',
           'totalAmtMsat': '10035100',
           'totalFees': '35',
           'totalFeesMsat': '35100',
           'totalTimeLock': 857929},
 'standing': 'FAILED'}
payment_hash: "30212,30332274percent251/u@ 027025535717G>177!!r/306{h347s[347;"
route {
  total_time_lock: 857930
  hops {
    chan_id: 938853187921707009
    chan_capacity: 500000
    amt_to_forward_msat: 10014010
  }
  hops {
    chan_id: 939936206842560512
    chan_capacity: 50000000
    amt_to_forward_msat: 10008020
  }
  hops {
    chan_id: 939936206848786432
    chan_capacity: 50000000
    amt_to_forward_msat: 10008020
  }
  hops {
    chan_id: 937025799454982144
    chan_capacity: 6056127
    amt_to_forward_msat: 10008010
  }
  hops {
    chan_id: 940502455302291457
    chan_capacity: 10069462
    amt_to_forward_msat: 10008000
  }
  hops {
    chan_id: 929527130166001664
    chan_capacity: 2065297
    amt_to_forward_msat: 10008000
  }
  hops {
    chan_id: 938880675621371905
    chan_capacity: 500000
    amt_to_forward_msat: 10000000
  }
  total_fees_msat: 35100
  total_amt_msat: 10035100
}

{'attemptId': '29704',
 'attemptTimeNs': '1723130822054676067',
 'failure': {'code': 'EXPIRY_TOO_FAR'},
 'resolveTimeNs': '1723130822078943747',
 'route': {'hops': [{'amtToForward': '10014',
                     'amtToForwardMsat': '10014010',
                     'chanCapacity': '500000',
                     'chanId': '938853187921707009',
                     'fee': '21',
                     'feeMsat': '21090',
                     'pubKey': '03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f',
                     'tlvPayload': True},
                    {'amtToForward': '10008',
                     'amtToForwardMsat': '10008020',
                     'chanCapacity': '50000000',
                     'chanId': '939936206842560512',
                     'fee': '5',
                     'feeMsat': '5990',
                     'pubKey': '02dd3fcdaa17b9bc83bf7138fbea85d0e83385a68b5fc8f9933658c8ee04644f68',
                     'tlvPayload': True},
                    {'amtToForward': '10008',
                     'amtToForwardMsat': '10008020',
                     'chanCapacity': '50000000',
                     'chanId': '939936206848786432',
                     'pubKey': '026165850492521f4ac8abd9bd8088123446d126f648ca35e60f88177dc149ceb2',
                     'tlvPayload': True},
                    {'amtToForward': '10008',
                     'amtToForwardMsat': '10008010',
                     'chanCapacity': '6056127',
                     'chanId': '937025799454982144',
                     'feeMsat': '10',
                     'pubKey': '02972e2342498fa91691dc5efd0deeb3dc7877b2f3d68ba9a698cf276b1d5de6ca',
                     'tlvPayload': True},
                    {'amtToForward': '10008',
                     'amtToForwardMsat': '10008000',
                     'chanCapacity': '10069462',
                     'chanId': '940502455302291457',
                     'feeMsat': '10',
                     'pubKey': '0390b5d4492dc2f5318e5233ab2cebf6d48914881a33ef6a9c6bcdbb433ad986d0',
                     'tlvPayload': True},
                    {'amtToForward': '10008',
                     'amtToForwardMsat': '10008000',
                     'chanCapacity': '2065297',
                     'chanId': '929527130166001664',
                     'pubKey': '034ea80f8b148c750463546bd999bf7321a0e6dfc60aaf84bd0400a2e8d376c0d5',
                     'tlvPayload': True},
                    {'amtToForward': '10000',
                     'amtToForwardMsat': '10000000',
                     'chanCapacity': '500000',
                     'chanId': '938880675621371905',
                     'fee': '8',
                     'feeMsat': '8000',
                     'pubKey': '021a6d7cfefdf74b5112cde8a7e9632478f5c9bc4cc5780d231b11f95710ea7edd',
                     'tlvPayload': True}],
           'totalAmt': '10035',
           'totalAmtMsat': '10035100',
           'totalFees': '35',
           'totalFeesMsat': '35100',
           'totalTimeLock': 857930},
 'standing': 'FAILED'}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments