summary: add offline annotation.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-03-05 14:10:17 +10:30
parent 16dc96263a
commit ac1478f5a5
2 changed files with 55 additions and 46 deletions

View File

@@ -12,45 +12,46 @@ otherwise normal ASCII.
## Example Usage
Unfortunately the python plugin framework doesn't pretty-print, nor does
lightning-cli, and json_pp doesn't maintain order, so I use a hacky 'tr':
lightning-cli, so best viewed with -H:
```
$ lightning-cli summary | tr ',' '\n'
{"network": "TESTNET"
"my_address": "031a3478d481b92e3c28810228252898c5f0d82fc4d07f5210c4f34d4aba56b769@165.227.30.200"
"num_utxos": 5
"utxo_amount": "1.20119332000btc = USD $4476.10"
"num_channels": 29
"num_connected": 4
"num_gossipers": 27
"avail_out": "0.27095103btc = USD $1009.67"
"avail_in": "2.05851379btc = "
"channels": [" ├────────────╢ :02ac05912f89e43b88de3472e8c3003b"
" ├───────────╢ :02dd4cef0192611bc34cd1c3a0a7eb0f"
" ╟────────────┤ :02a13878947a133d7c96e70303a9bf27 (priv)"
" ║ :033e2db012833d997e3c"
" ╟┤ :Kenny_Loggins"
"──────────────────────┤:DeutscheTestnetBank"
" ╟─────────────────────┤ :BlueLagoon1"
" ╟──────────────────────┤:0270dd38e8af9a64b4a483ab12b6aeb1"
"┤ :btctest.lnetwork.tokyo"
":microbet.fun"
" ╟──────────────────────┤:02fcab6e34a2ad21be2a752ab96d13f5 (priv)"
" ╟──────────────────────┤:htlc.me"
" ╟───┤ :02229ea9a7a4f9bf8bf25ce225079aed"
" ╟─────────────────────┤ :025d5b572a94235cfcbdc429181b2b88"
" ╟────────────┤ :03c56de3a84336b4a939777ace9ecbef (priv)"
" ╟────────┤ :LiteStrikeBTClnd"
" ╟────────────────┤ :037c9cf1cde4414c59407d547b7eac08 (priv)"
" ║ :03490a74e4def9125a84aee2d84e8cfe"
" ├─────────┼─────────┤ :aranguren.org"
" ║ :03cc6603e1f6df535dd8b423284f2c09 (priv)"
":cyclopes"
" ╟─────────────────────┤ :02b73a2160863e925e9fa978b0ddc56b (priv)"
" ╟───┤ :lnd-testnet.ignios.net"
" ╟─┤ :0327a104108173d4a4f34ab2cbc3084c (priv)"
" ╟─┤ :dwarf"
" :028133777757ce281658804dd82f5758 (priv)"
" ╟────────────┤ :02db62ffff5c35be74e7f856bba136db (priv)"
"┤ :03015ac044f5fa9768ededf6fed9c0ff (priv)"
"──────────────────────┤:0270685ca81a8e4d4d01"]}
$ lightning-cli -H summary
network=TESTNET
my_address=031a3478d481b92e3c28810228252898c5f0d82fc4d07f5210c4f34d4aba56b769@165.227.30.200
num_utxos=5
utxo_amount=1.20119332000btc (USD $4473.84)
num_channels=29
num_connected=2
num_gossipers=29
avail_out=0.27095103btc (USD $1009.16)
avail_in=2.05851379btc (USD $7666.93)
channels_key=P=private O=offline
channels= ├───────────(O):02ac05912f89e43b88de3472e8c3003b
├───────────╢ (O):02dd4cef0192611bc34cd1c3a0a7eb0f
╟────────────┤ (PO):02a13878947a133d7c96e70303a9bf27
(O):033e2db012833d997e3c
┤ (O):Kenny_Loggins
╟──────────────────────┤(O):DeutscheTestnetBank
╟─────────────────────┤ (O):BlueLagoon1
──────────────────────┤(O):0270dd38e8af9a64b4a483ab12b6aeb1
╟┤ (O):btctest.lnetwork.tokyo
╟─┤ (O):microbet.fun
╟──────────────────────┤(PO):02fcab6e34a2ad21be2a752ab96d13f5
╟──────────────────────┤(O):htlc.me
╟───┤ (O):02229ea9a7a4f9bf8bf25ce225079aed
╟─────────────────────┤ (O):025d5b572a94235cfcbdc429181b2b88
╟────────────(PO):03c56de3a84336b4a939777ace9ecbef
╟────────┤ (O):LiteStrikeBTClnd
╟────────────────┤ (PO):037c9cf1cde4414c59407d547b7eac08
║ (O):03490a74e4def9125a84aee2d84e8cfe
├─────────┼─────────┤ (O):aranguren.org
(PO):03cc6603e1f6df535dd8b423284f2c09
║ (O):cyclopes
╟─────────────────────┤ (PO):02b73a2160863e925e9fa978b0ddc56b
╟───(O):lnd-testnet.ignios.net
╟─┤ (PO):0327a104108173d4a4f34ab2cbc3084c
╟─┤ :dwarf
║ (PO):028133777757ce281658804dd82f5758
────────────┤ (PO):02db62ffff5c35be74e7f856bba136db
┤ (PO):03015ac044f5fa9768ededf6fed9c0ff
╟──────────────────────┤:0270685ca81a8e4d4d01

View File

@@ -100,17 +100,18 @@ def summary(plugin):
to_them = Millisatoshi(0)
avail_in += to_them
reply['num_channels'] += 1
chans.append((c['total_msat'], to_us, to_them, p['id'], c['private']))
chans.append((c['total_msat'], to_us, to_them, p['id'], c['private'], p['connected']))
reply['avail_out'] = avail_out.to_btc_str()
reply['avail_in'] = avail_in.to_btc_str()
if plugin.fiat_per_btc:
reply['utxo_amount'] += ' = {}'.format(to_fiatstr(utxo_amount))
reply['avail_out'] += ' = {}'.format(to_fiatstr(avail_out))
reply['avail_in'] += ' = '.format(to_fiatstr(avail_in))
reply['utxo_amount'] += ' ({})'.format(to_fiatstr(utxo_amount))
reply['avail_out'] += ' ({})'.format(to_fiatstr(avail_out))
reply['avail_in'] += ' ({})'.format(to_fiatstr(avail_in))
if chans != []:
reply['channels_key'] = 'P=private O=offline'
reply['channels'] = []
biggest = max(max(int(c[1]), int(c[2])) for c in chans)
for c in chans:
@@ -138,13 +139,20 @@ def summary(plugin):
right = "{:23}".format(draw.bar * (their_len - 1) + draw.right)
s = left + mid + right
extra = ''
if c[4]:
extra += 'P'
if not c[5]:
extra += 'O'
if extra != '':
s += '({})'.format(extra)
node = plugin.rpc.listnodes(c[3])['nodes']
if len(node) != 0:
s += ':' + node[0]['alias']
else:
s += ':' + c[3][0:32]
if c[4]:
s += ' (priv)'
reply['channels'].append(s)
return reply