コード例 #1
0
def filter_channels(rpc, filter_name, amount=0, unit='msat'):
    if not is_valid_filter(filter_name):
        return "Value filter_name's are %s" % ', '.join(channel_filters)

    if filter_name.lower() == 'pending':
        return pending_channels(rpc)
    if filter_name.lower() == 'active':
        return active_channels(rpc)
    if filter_name.lower() == 'closed':
        return closed_channels(rpc)
    if filter_name.lower() == 'incoming':
        return incoming_channels(rpc)
    if filter_name.lower() == 'outgoing':
        return outgoing_channels(rpc)
    if filter_name.lower() == 'nochannel':
        return peers_no_channel(rpc)
    if filter_name.lower() == 'greater_than':
        amt = Amount(amount, unit)
        return channels_greater_than(rpc, amt)
    if filter_name.lower() == 'less_than':
        amt = Amount(amount, unit)
        return channels_less_than(rpc, amt)
コード例 #2
0
def total_payments_no_fees(rpc):
    return Amount(sum((p['msatoshi'] for p in complete_payments(rpc))), 'msat')
コード例 #3
0
def routing_fees_paid(rpc):
    return Amount(
        sum((p['msatoshi_sent'] - p['msatoshi']
             for p in complete_payments(rpc))), 'msat')
コード例 #4
0
def active_balance(rpc):
    return Amount(sum((p['channels'][0]['msatoshi_to_us']
                  for p in active_channels(rpc))), 'msat')
コード例 #5
0
def reserve_balance(rpc):
    return Amount(sum((p['channels'][0]['our_channel_reserve_satoshis']
                       for p in active_channels(rpc))), 'msat')
コード例 #6
0
def funded_incoming_balance(rpc):
    return Amount(sum((p['channels'][0]['msatoshi_total']
                       for p in incoming_channels(rpc))), 'msat')
コード例 #7
0
def closed_incoming_balance(rpc):
    return Amount(sum((p['channels'][0]['msatoshi_total'] - p['channels'][0]['msatoshi_to_us']
                  for p in closed_channels(rpc))), 'msat')
コード例 #8
0
def pending_balance(rpc):
    return Amount(sum((p['channels'][0]['msatoshi_to_us']
                       for p in pending_channels(rpc))), 'msat')
コード例 #9
0
def channels_less_than(rpc, amount):
    assert type(amount) is Amount
    return [
        p for p in rpc.listpeers()['peers'] if p['channels']
        and Amount(p['channels'][0]['msatoshi_total'], 'msat') <= amount
    ]
コード例 #10
0
def get_node_capacity(rpc, node_id):
    return Amount(
        sum((c['satoshis'] for c in rpc.listchannels()['channels']
             if c['source'] == node_id)), 'sat')
コード例 #11
0
def onchain_unconfirmed_balance(rpc):
    return Amount(
        sum((int(x["value"]) for x in rpc.listfunds()["outputs"]
             if x["status"] == "unconfirmed")), 'sat')
コード例 #12
0
def onchain_balance(rpc):
    return Amount(sum((int(x["value"]) for x in rpc.listfunds()["outputs"])),
                  'sat')
コード例 #13
0
from collections import defaultdict
from lib.amount import Amount

# Default max channel size (for now)
WUMBO = Amount(16777216, 'sat')


# Get own node id
def nodeid(rpc):
    return rpc.getinfo()['id']


# Get total onchain funds including unconfirmed
def onchain_balance(rpc):
    return Amount(sum((int(x["value"]) for x in rpc.listfunds()["outputs"])),
                  'sat')


# Get total unconfirmed onchain funds
def onchain_confirmed_balance(rpc):
    return Amount(
        sum((int(x["value"]) for x in rpc.listfunds()["outputs"]
             if x["status"] == "confirmed")), 'sat')


# Get total confirmed onchain funds
def onchain_unconfirmed_balance(rpc):
    return Amount(
        sum((int(x["value"]) for x in rpc.listfunds()["outputs"]
             if x["status"] == "unconfirmed")), 'sat')