lnworker.pay(): lightning-integration support
This commit is contained in:
@@ -775,7 +775,7 @@ class Commands:
|
|||||||
|
|
||||||
@command('wn')
|
@command('wn')
|
||||||
def lnpay(self, invoice):
|
def lnpay(self, invoice):
|
||||||
f = self.wallet.lnworker.pay(invoice)
|
addr, peer, f = self.wallet.lnworker.pay(invoice)
|
||||||
return f.result()
|
return f.result()
|
||||||
|
|
||||||
@command('wn')
|
@command('wn')
|
||||||
|
|||||||
@@ -1683,7 +1683,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
|||||||
failure_list = []
|
failure_list = []
|
||||||
for i in range(LN_NUM_PAYMENT_ATTEMPTS):
|
for i in range(LN_NUM_PAYMENT_ATTEMPTS):
|
||||||
try:
|
try:
|
||||||
future = self.wallet.lnworker.pay(invoice, amount_sat=amount)
|
addr, peer, future = self.wallet.lnworker.pay(invoice, amount_sat=amount)
|
||||||
future.result()
|
future.result()
|
||||||
break
|
break
|
||||||
except PaymentFailure as e:
|
except PaymentFailure as e:
|
||||||
|
|||||||
@@ -289,6 +289,7 @@ class Peer(PrintError):
|
|||||||
self.commitment_signed = defaultdict(asyncio.Queue)
|
self.commitment_signed = defaultdict(asyncio.Queue)
|
||||||
self.announcement_signatures = defaultdict(asyncio.Queue)
|
self.announcement_signatures = defaultdict(asyncio.Queue)
|
||||||
self.closing_signed = defaultdict(asyncio.Queue)
|
self.closing_signed = defaultdict(asyncio.Queue)
|
||||||
|
self.payment_preimages = defaultdict(asyncio.Queue)
|
||||||
self.localfeatures = (0x08 if request_initial_sync else 0)
|
self.localfeatures = (0x08 if request_initial_sync else 0)
|
||||||
self.invoices = lnworker.invoices
|
self.invoices = lnworker.invoices
|
||||||
self.attempted_route = {}
|
self.attempted_route = {}
|
||||||
@@ -959,6 +960,9 @@ class Peer(PrintError):
|
|||||||
await self.receive_revoke(chan)
|
await self.receive_revoke(chan)
|
||||||
self.lnworker.save_channel(chan)
|
self.lnworker.save_channel(chan)
|
||||||
|
|
||||||
|
# used in lightning-integration
|
||||||
|
self.payment_preimages[sha256(preimage)].put_nowait(preimage)
|
||||||
|
|
||||||
def on_update_fail_malformed_htlc(self, payload):
|
def on_update_fail_malformed_htlc(self, payload):
|
||||||
self.on_error(payload)
|
self.on_error(payload)
|
||||||
|
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ class LNWorker(PrintError):
|
|||||||
else:
|
else:
|
||||||
raise Exception("ChannelDB returned path with short_channel_id {} that is not in channel list".format(bh2u(short_channel_id)))
|
raise Exception("ChannelDB returned path with short_channel_id {} that is not in channel list".format(bh2u(short_channel_id)))
|
||||||
coro = peer.pay(path, chan, amount_msat, payment_hash, invoice_pubkey, addr.min_final_cltv_expiry)
|
coro = peer.pay(path, chan, amount_msat, payment_hash, invoice_pubkey, addr.min_final_cltv_expiry)
|
||||||
return asyncio.run_coroutine_threadsafe(coro, self.network.asyncio_loop)
|
return addr, peer, asyncio.run_coroutine_threadsafe(coro, self.network.asyncio_loop)
|
||||||
|
|
||||||
def add_invoice(self, amount_sat, message):
|
def add_invoice(self, amount_sat, message):
|
||||||
payment_preimage = os.urandom(32)
|
payment_preimage = os.urandom(32)
|
||||||
|
|||||||
Reference in New Issue
Block a user