mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 09:21:39 +00:00
lnpay: return payment log, increase timeout
This commit is contained in:
parent
d7b853f271
commit
7b44e27087
2 changed files with 7 additions and 5 deletions
|
@ -1005,16 +1005,17 @@ class Commands:
|
|||
return parse_lightning_invoice(invoice)
|
||||
|
||||
@command('wn')
|
||||
async def lnpay(self, invoice, attempts=1, timeout=10, wallet: Abstract_Wallet = None):
|
||||
async def lnpay(self, invoice, attempts=1, timeout=30, wallet: Abstract_Wallet = None):
|
||||
lnworker = wallet.lnworker
|
||||
lnaddr = lnworker._check_invoice(invoice, None)
|
||||
payment_hash = lnaddr.paymenthash
|
||||
wallet.save_invoice(parse_lightning_invoice(invoice))
|
||||
success = await lnworker._pay(invoice, attempts=attempts)
|
||||
success, log = await lnworker._pay(invoice, attempts=attempts)
|
||||
return {
|
||||
'payment_hash': payment_hash.hex(),
|
||||
'success': success,
|
||||
'preimage': lnworker.get_preimage(payment_hash).hex() if success else None,
|
||||
'log': [x.formatted_tuple() for x in log]
|
||||
}
|
||||
|
||||
@command('w')
|
||||
|
@ -1202,6 +1203,7 @@ arg_types = {
|
|||
'encrypt_file': eval_bool,
|
||||
'rbf': eval_bool,
|
||||
'timeout': float,
|
||||
'attempts': int,
|
||||
}
|
||||
|
||||
config_variables = {
|
||||
|
|
|
@ -807,7 +807,7 @@ class LNWallet(LNWorker):
|
|||
"""
|
||||
coro = self._pay(invoice, amount_sat, attempts)
|
||||
fut = asyncio.run_coroutine_threadsafe(coro, self.network.asyncio_loop)
|
||||
success = fut.result()
|
||||
success, log = fut.result()
|
||||
|
||||
def get_channel_by_short_id(self, short_channel_id: ShortChannelID) -> Channel:
|
||||
for chan in self.channels.values():
|
||||
|
@ -827,7 +827,7 @@ class LNWallet(LNWorker):
|
|||
info = PaymentInfo(lnaddr.paymenthash, amount, SENT, PR_UNPAID)
|
||||
self.save_payment_info(info)
|
||||
self.wallet.set_label(key, lnaddr.get_description())
|
||||
log = self.logs[key]
|
||||
self.logs[key] = log = []
|
||||
success = False
|
||||
reason = ''
|
||||
for i in range(attempts):
|
||||
|
@ -856,7 +856,7 @@ class LNWallet(LNWorker):
|
|||
util.trigger_callback('payment_succeeded', key)
|
||||
else:
|
||||
util.trigger_callback('payment_failed', key, reason)
|
||||
return success
|
||||
return success, log
|
||||
|
||||
async def _pay_to_route(self, route: LNPaymentRoute, lnaddr: LnAddr) -> PaymentAttemptLog:
|
||||
short_channel_id = route[0].short_channel_id
|
||||
|
|
Loading…
Add table
Reference in a new issue