MPP: can_send/can_receive is now the sum, no longer the max
This commit is contained in:
@@ -32,15 +32,17 @@ class ChannelsList(MyTreeView):
|
|||||||
class Columns(IntEnum):
|
class Columns(IntEnum):
|
||||||
SHORT_CHANID = 0
|
SHORT_CHANID = 0
|
||||||
NODE_ALIAS = 1
|
NODE_ALIAS = 1
|
||||||
LOCAL_BALANCE = 2
|
CAPACITY = 2
|
||||||
REMOTE_BALANCE = 3
|
LOCAL_BALANCE = 3
|
||||||
CHANNEL_STATUS = 4
|
REMOTE_BALANCE = 4
|
||||||
|
CHANNEL_STATUS = 5
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
Columns.SHORT_CHANID: _('Short Channel ID'),
|
Columns.SHORT_CHANID: _('Short Channel ID'),
|
||||||
Columns.NODE_ALIAS: _('Node alias'),
|
Columns.NODE_ALIAS: _('Node alias'),
|
||||||
Columns.LOCAL_BALANCE: _('Local'),
|
Columns.CAPACITY: _('Capacity'),
|
||||||
Columns.REMOTE_BALANCE: _('Remote'),
|
Columns.LOCAL_BALANCE: _('Can send'),
|
||||||
|
Columns.REMOTE_BALANCE: _('Can receive'),
|
||||||
Columns.CHANNEL_STATUS: _('Status'),
|
Columns.CHANNEL_STATUS: _('Status'),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,8 +71,8 @@ class ChannelsList(MyTreeView):
|
|||||||
def format_fields(self, chan):
|
def format_fields(self, chan):
|
||||||
labels = {}
|
labels = {}
|
||||||
for subject in (REMOTE, LOCAL):
|
for subject in (REMOTE, LOCAL):
|
||||||
bal_minus_htlcs = chan.balance_minus_outgoing_htlcs(subject)//1000
|
can_send = chan.available_to_spend(subject) / 1000
|
||||||
label = self.parent.format_amount(bal_minus_htlcs)
|
label = self.parent.format_amount(can_send)
|
||||||
other = subject.inverted()
|
other = subject.inverted()
|
||||||
bal_other = chan.balance(other)//1000
|
bal_other = chan.balance(other)//1000
|
||||||
bal_minus_htlcs_other = chan.balance_minus_outgoing_htlcs(other)//1000
|
bal_minus_htlcs_other = chan.balance_minus_outgoing_htlcs(other)//1000
|
||||||
@@ -83,6 +85,7 @@ class ChannelsList(MyTreeView):
|
|||||||
return [
|
return [
|
||||||
chan.short_id_for_GUI(),
|
chan.short_id_for_GUI(),
|
||||||
node_alias,
|
node_alias,
|
||||||
|
self.parent.format_amount(chan.constraints.capacity),
|
||||||
'' if closed else labels[LOCAL],
|
'' if closed else labels[LOCAL],
|
||||||
'' if closed else labels[REMOTE],
|
'' if closed else labels[REMOTE],
|
||||||
status
|
status
|
||||||
|
|||||||
@@ -1086,9 +1086,6 @@ class Channel(AbstractChannel):
|
|||||||
sender = subject
|
sender = subject
|
||||||
receiver = subject.inverted()
|
receiver = subject.inverted()
|
||||||
initiator = LOCAL if self.constraints.is_initiator else REMOTE # the initiator/funder pays on-chain fees
|
initiator = LOCAL if self.constraints.is_initiator else REMOTE # the initiator/funder pays on-chain fees
|
||||||
is_frozen = self.is_frozen_for_sending() if subject == LOCAL else self.is_frozen_for_receiving()
|
|
||||||
if not self.is_active() or is_frozen:
|
|
||||||
return 0
|
|
||||||
|
|
||||||
def consider_ctx(*, ctx_owner: HTLCOwner, is_htlc_dust: bool) -> int:
|
def consider_ctx(*, ctx_owner: HTLCOwner, is_htlc_dust: bool) -> int:
|
||||||
ctn = self.get_next_ctn(ctx_owner)
|
ctn = self.get_next_ctn(ctx_owner)
|
||||||
|
|||||||
@@ -1774,20 +1774,22 @@ class LNWallet(LNWorker):
|
|||||||
for chan in self.channels.values())) / 1000
|
for chan in self.channels.values())) / 1000
|
||||||
|
|
||||||
def num_sats_can_send(self) -> Decimal:
|
def num_sats_can_send(self) -> Decimal:
|
||||||
send_values = [Decimal(0)]
|
can_send = Decimal(0)
|
||||||
with self.lock:
|
with self.lock:
|
||||||
if self.channels:
|
if self.channels:
|
||||||
for c in self.channels.values():
|
for c in self.channels.values():
|
||||||
send_values.append(Decimal(c.available_to_spend(LOCAL)) / 1000)
|
if c.is_active() and not c.is_frozen_for_sending():
|
||||||
return max(send_values)
|
can_send += Decimal(c.available_to_spend(LOCAL)) / 1000
|
||||||
|
return can_send
|
||||||
|
|
||||||
def num_sats_can_receive(self) -> Decimal:
|
def num_sats_can_receive(self) -> Decimal:
|
||||||
receive_values = [Decimal(0)]
|
can_receive = Decimal(0)
|
||||||
with self.lock:
|
with self.lock:
|
||||||
if self.channels:
|
if self.channels:
|
||||||
for c in self.channels.values():
|
for c in self.channels.values():
|
||||||
receive_values.append(Decimal(c.available_to_spend(REMOTE)) / 1000)
|
if c.is_active() and not c.is_frozen_for_receiving():
|
||||||
return max(receive_values)
|
can_receive += Decimal(c.available_to_spend(REMOTE)) / 1000
|
||||||
|
return can_receive
|
||||||
|
|
||||||
def can_pay_invoice(self, invoice: LNInvoice) -> bool:
|
def can_pay_invoice(self, invoice: LNInvoice) -> bool:
|
||||||
return invoice.get_amount_sat() <= self.num_sats_can_send()
|
return invoice.get_amount_sat() <= self.num_sats_can_send()
|
||||||
|
|||||||
Reference in New Issue
Block a user