electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 7b44e270877a7604cae81f824f742e824d7ce5d8
parent d7b853f2716acb2808278e552987bf598821a4e4
Author: ThomasV <thomasv@electrum.org>
Date:   Tue,  5 May 2020 18:32:43 +0200

lnpay: return payment log, increase timeout

Diffstat:
Melectrum/commands.py | 6++++--
Melectrum/lnworker.py | 6+++---
2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/electrum/commands.py b/electrum/commands.py @@ -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 = { diff --git a/electrum/lnworker.py b/electrum/lnworker.py @@ -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