Browse Source

pylightning: Reorder LightningRpc methods alphabetically

htlc_accepted_hook
darosior 6 years ago
committed by Christian Decker
parent
commit
efecd64bf3
  1. 446
      contrib/pylightning/lightning/lightning.py

446
contrib/pylightning/lightning/lightning.py

@ -284,179 +284,174 @@ class LightningRpc(UnixDomainSocketRpc):
def __init__(self, socket_path, executor=None, logger=logging): def __init__(self, socket_path, executor=None, logger=logging):
super().__init__(socket_path, executor, logging, self.LightningJSONEncoder, self.LightningJSONDecoder()) super().__init__(socket_path, executor, logging, self.LightningJSONEncoder, self.LightningJSONDecoder())
def getpeer(self, peer_id, level=None): def close(self, peer_id, force=None, timeout=None):
""" """
Show peer with {peer_id}, if {level} is set, include {log}s Close the channel with peer {id}, forcing a unilateral
close if {force} is True, and timing out with {timeout}
seconds.
""" """
payload = { payload = {
"id": peer_id, "id": peer_id,
"level": level "force": force,
"timeout": timeout
} }
res = self.call("listpeers", payload) return self.call("close", payload)
return res.get("peers") and res["peers"][0] or None
def listnodes(self, node_id=None): def connect(self, peer_id, host=None, port=None):
""" """
Show all nodes in our local network view, filter on node {id} Connect to {peer_id} at {host} and {port}
if provided
""" """
payload = { payload = {
"id": node_id "id": peer_id,
"host": host,
"port": port
} }
return self.call("listnodes", payload) return self.call("connect", payload)
def getroute(self, node_id, msatoshi, riskfactor, cltv=9, fromid=None, fuzzpercent=None, exclude=[], maxhops=20): def decodepay(self, bolt11, description=None):
""" """
Show route to {id} for {msatoshi}, using {riskfactor} and optional Decode {bolt11}, using {description} if necessary
{cltv} (default 9). If specified search from {fromid} otherwise use
this node as source. Randomize the route with up to {fuzzpercent}
(0.0 -> 100.0, default 5.0). {exclude} is an optional array of
scid/direction to exclude. Limit the number of hops in the route to
{maxhops}.
""" """
payload = { payload = {
"id": node_id, "bolt11": bolt11,
"msatoshi": msatoshi, "description": description
"riskfactor": riskfactor,
"cltv": cltv,
"fromid": fromid,
"fuzzpercent": fuzzpercent,
"exclude": exclude,
"maxhops": maxhops
} }
return self.call("getroute", payload) return self.call("decodepay", payload)
def listchannels(self, short_channel_id=None, source=None): def delexpiredinvoice(self, maxexpirytime=None):
""" """
Show all known channels, accept optional {short_channel_id} or {source} Delete all invoices that have expired on or before the given {maxexpirytime}
""" """
payload = { payload = {
"short_channel_id": short_channel_id, "maxexpirytime": maxexpirytime
"source": source
} }
return self.call("listchannels", payload) return self.call("delexpiredinvoice", payload)
def invoice(self, msatoshi, label, description, expiry=None, fallbacks=None, preimage=None, exposeprivatechannels=None): def delinvoice(self, label, status):
""" """
Create an invoice for {msatoshi} with {label} and {description} with Delete unpaid invoice {label} with {status}
optional {expiry} seconds (default 1 hour)
""" """
payload = { payload = {
"msatoshi": msatoshi,
"label": label, "label": label,
"description": description, "status": status
"expiry": expiry,
"fallbacks": fallbacks,
"preimage": preimage,
"exposeprivatechannels": exposeprivatechannels
} }
return self.call("invoice", payload) return self.call("delinvoice", payload)
def listinvoices(self, label=None): def dev_crash(self):
""" """
Show invoice {label} (or all, if no {label)) Crash lightningd by calling fatal()
""" """
payload = { return self.call("dev-crash")
"label": label
}
return self.call("listinvoices", payload)
def delinvoice(self, label, status): def dev_fail(self, peer_id):
""" """
Delete unpaid invoice {label} with {status} Fail with peer {peer_id}
""" """
payload = { payload = {
"label": label, "id": peer_id
"status": status
} }
return self.call("delinvoice", payload) return self.call("dev-fail", payload)
def delexpiredinvoice(self, maxexpirytime=None): def dev_forget_channel(self, peerid, force=False):
""" Forget the channel with id=peerid
""" """
Delete all invoices that have expired on or before the given {maxexpirytime} return self.call(
"dev-forget-channel",
payload={"id": peerid, "force": force}
)
def dev_memdump(self):
""" """
payload = { Show memory objects currently in use
"maxexpirytime": maxexpirytime """
} return self.call("dev-memdump")
return self.call("delexpiredinvoice", payload)
def waitanyinvoice(self, lastpay_index=None): def dev_memleak(self):
""" """
Wait for the next invoice to be paid, after {lastpay_index} Show unreferenced memory objects
(if supplied)
""" """
payload = { return self.call("dev-memleak")
"lastpay_index": lastpay_index
}
return self.call("waitanyinvoice", payload)
def waitinvoice(self, label): def dev_query_scids(self, id, scids):
""" """
Wait for an incoming payment matching the invoice with {label} Ask peer for a particular set of scids
""" """
payload = { payload = {
"label": label "id": id,
"scids": scids
} }
return self.call("waitinvoice", payload) return self.call("dev-query-scids", payload)
def decodepay(self, bolt11, description=None): def dev_reenable_commit(self, peer_id):
""" """
Decode {bolt11}, using {description} if necessary Re-enable the commit timer on peer {id}
""" """
payload = { payload = {
"bolt11": bolt11, "id": peer_id
"description": description
} }
return self.call("decodepay", payload) return self.call("dev-reenable-commit", payload)
def help(self, command=None): def dev_rescan_outputs(self):
""" """
Show available commands, or just {command} if supplied. Synchronize the state of our funds with bitcoind
""" """
payload = { return self.call("dev-rescan-outputs")
"command": command,
}
return self.call("help", payload)
def stop(self): def dev_rhash(self, secret):
""" """
Shut down the lightningd process Show SHA256 of {secret}
""" """
return self.call("stop") payload = {
"secret": secret
}
return self.call("dev-rhash", payload)
def getlog(self, level=None): def dev_sign_last_tx(self, peer_id):
""" """
Show logs, with optional log {level} (info|unusual|debug|io) Sign and show the last commitment transaction with peer {id}
""" """
payload = { payload = {
"level": level "id": peer_id
} }
return self.call("getlog", payload) return self.call("dev-sign-last-tx", payload)
def dev_rhash(self, secret): def disconnect(self, peer_id, force=False):
""" """
Show SHA256 of {secret} Disconnect from peer with {peer_id}, optional {force} even if has active channel
""" """
payload = { payload = {
"secret": secret "id": peer_id,
"force": force,
} }
return self.call("dev-rhash", payload) return self.call("disconnect", payload)
def dev_crash(self): def feerates(self, style, urgent=None, normal=None, slow=None):
""" """
Crash lightningd by calling fatal() Supply feerate estimates manually.
""" """
return self.call("dev-crash") payload = {
"style": style,
"urgent": urgent,
"normal": normal,
"slow": slow
}
return self.call("feerates", payload)
def dev_query_scids(self, id, scids): def fundchannel(self, node_id, satoshi, feerate=None, announce=True, minconf=None):
""" """
Ask peer for a particular set of scids Fund channel with {id} using {satoshi} satoshis
with feerate of {feerate} (uses default feerate if unset).
If {announce} is False, don't send channel announcements.
Only select outputs with {minconf} confirmations
""" """
payload = { payload = {
"id": id, "id": node_id,
"scids": scids "satoshi": satoshi,
"feerate": feerate,
"announce": announce,
"minconf": minconf,
} }
return self.call("dev-query-scids", payload) return self.call("fundchannel", payload)
def getinfo(self): def getinfo(self):
""" """
@ -464,132 +459,154 @@ class LightningRpc(UnixDomainSocketRpc):
""" """
return self.call("getinfo") return self.call("getinfo")
def sendpay(self, route, payment_hash, description=None, msatoshi=None): def getlog(self, level=None):
""" """
Send along {route} in return for preimage of {payment_hash} Show logs, with optional log {level} (info|unusual|debug|io)
""" """
payload = { payload = {
"route": route, "level": level
"payment_hash": payment_hash,
"description": description,
"msatoshi": msatoshi,
} }
return self.call("sendpay", payload) return self.call("getlog", payload)
def waitsendpay(self, payment_hash, timeout=None): def getpeer(self, peer_id, level=None):
""" """
Wait for payment for preimage of {payment_hash} to complete Show peer with {peer_id}, if {level} is set, include {log}s
""" """
payload = { payload = {
"payment_hash": payment_hash, "id": peer_id,
"timeout": timeout "level": level
} }
return self.call("waitsendpay", payload) res = self.call("listpeers", payload)
return res.get("peers") and res["peers"][0] or None
def pay(self, bolt11, msatoshi=None, label=None, riskfactor=None, description=None): def getroute(self, node_id, msatoshi, riskfactor, cltv=9, fromid=None, fuzzpercent=None, exclude=[], maxhops=20):
""" """
Send payment specified by {bolt11} with {msatoshi} Show route to {id} for {msatoshi}, using {riskfactor} and optional
(ignored if {bolt11} has an amount), optional {label} {cltv} (default 9). If specified search from {fromid} otherwise use
and {riskfactor} (default 1.0) this node as source. Randomize the route with up to {fuzzpercent}
(0.0 -> 100.0, default 5.0). {exclude} is an optional array of
scid/direction to exclude. Limit the number of hops in the route to
{maxhops}.
""" """
payload = { payload = {
"bolt11": bolt11, "id": node_id,
"msatoshi": msatoshi, "msatoshi": msatoshi,
"label": label,
"riskfactor": riskfactor, "riskfactor": riskfactor,
# Deprecated. "cltv": cltv,
"description": description, "fromid": fromid,
"fuzzpercent": fuzzpercent,
"exclude": exclude,
"maxhops": maxhops
} }
return self.call("pay", payload) return self.call("getroute", payload)
def listpayments(self, bolt11=None, payment_hash=None): def help(self, command=None):
""" """
Show outgoing payments, regarding {bolt11} or {payment_hash} if set Show available commands, or just {command} if supplied.
Can only specify one of {bolt11} or {payment_hash}
""" """
assert not (bolt11 and payment_hash)
payload = { payload = {
"bolt11": bolt11, "command": command,
"payment_hash": payment_hash
} }
return self.call("listpayments", payload) return self.call("help", payload)
def connect(self, peer_id, host=None, port=None): def invoice(self, msatoshi, label, description, expiry=None, fallbacks=None, preimage=None, exposeprivatechannels=None):
""" """
Connect to {peer_id} at {host} and {port} Create an invoice for {msatoshi} with {label} and {description} with
optional {expiry} seconds (default 1 hour)
""" """
payload = { payload = {
"id": peer_id, "msatoshi": msatoshi,
"host": host, "label": label,
"port": port "description": description,
"expiry": expiry,
"fallbacks": fallbacks,
"preimage": preimage,
"exposeprivatechannels": exposeprivatechannels
} }
return self.call("connect", payload) return self.call("invoice", payload)
def listpeers(self, peerid=None, level=None): def listchannels(self, short_channel_id=None, source=None):
""" """
Show current peers, if {level} is set, include {log}s" Show all known channels, accept optional {short_channel_id} or {source}
""" """
payload = { payload = {
"id": peerid, "short_channel_id": short_channel_id,
"level": level, "source": source
} }
return self.call("listpeers", payload) return self.call("listchannels", payload)
def fundchannel(self, node_id, satoshi, feerate=None, announce=True, minconf=None): def listforwards(self):
"""List all forwarded payments and their information
""" """
Fund channel with {id} using {satoshi} satoshis return self.call("listforwards")
with feerate of {feerate} (uses default feerate if unset).
If {announce} is False, don't send channel announcements. def listfunds(self):
Only select outputs with {minconf} confirmations """
Show funds available for opening channels
"""
return self.call("listfunds")
def listinvoices(self, label=None):
"""
Show invoice {label} (or all, if no {label))
""" """
payload = { payload = {
"id": node_id, "label": label
"satoshi": satoshi,
"feerate": feerate,
"announce": announce,
"minconf": minconf,
} }
return self.call("fundchannel", payload) return self.call("listinvoices", payload)
def close(self, peer_id, force=None, timeout=None): def listnodes(self, node_id=None):
""" """
Close the channel with peer {id}, forcing a unilateral Show all nodes in our local network view, filter on node {id}
close if {force} is True, and timing out with {timeout} if provided
seconds.
""" """
payload = { payload = {
"id": peer_id, "id": node_id
"force": force,
"timeout": timeout
} }
return self.call("close", payload) return self.call("listnodes", payload)
def dev_sign_last_tx(self, peer_id): def listpayments(self, bolt11=None, payment_hash=None):
""" """
Sign and show the last commitment transaction with peer {id} Show outgoing payments, regarding {bolt11} or {payment_hash} if set
Can only specify one of {bolt11} or {payment_hash}
""" """
assert not (bolt11 and payment_hash)
payload = { payload = {
"id": peer_id "bolt11": bolt11,
"payment_hash": payment_hash
} }
return self.call("dev-sign-last-tx", payload) return self.call("listpayments", payload)
def dev_fail(self, peer_id): def listpeers(self, peerid=None, level=None):
""" """
Fail with peer {peer_id} Show current peers, if {level} is set, include {log}s"
""" """
payload = { payload = {
"id": peer_id "id": peerid,
"level": level,
} }
return self.call("dev-fail", payload) return self.call("listpeers", payload)
def dev_reenable_commit(self, peer_id): def newaddr(self, addresstype=None):
"""Get a new address of type {addresstype} of the internal wallet.
""" """
Re-enable the commit timer on peer {id} return self.call("newaddr", {"addresstype": addresstype})
def pay(self, bolt11, msatoshi=None, label=None, riskfactor=None, description=None):
"""
Send payment specified by {bolt11} with {msatoshi}
(ignored if {bolt11} has an amount), optional {label}
and {riskfactor} (default 1.0)
""" """
payload = { payload = {
"id": peer_id "bolt11": bolt11,
"msatoshi": msatoshi,
"label": label,
"riskfactor": riskfactor,
# Deprecated.
"description": description,
} }
return self.call("dev-reenable-commit", payload) return self.call("pay", payload)
def ping(self, peer_id, length=128, pongbytes=128): def ping(self, peer_id, length=128, pongbytes=128):
""" """
@ -602,80 +619,63 @@ class LightningRpc(UnixDomainSocketRpc):
} }
return self.call("ping", payload) return self.call("ping", payload)
def dev_memdump(self): def sendpay(self, route, payment_hash, description=None, msatoshi=None):
""" """
Show memory objects currently in use Send along {route} in return for preimage of {payment_hash}
""" """
return self.call("dev-memdump") payload = {
"route": route,
"payment_hash": payment_hash,
"description": description,
"msatoshi": msatoshi,
}
return self.call("sendpay", payload)
def dev_memleak(self): def stop(self):
""" """
Show unreferenced memory objects Shut down the lightningd process
""" """
return self.call("dev-memleak") return self.call("stop")
def withdraw(self, destination, satoshi, feerate=None, minconf=None): def waitanyinvoice(self, lastpay_index=None):
""" """
Send to {destination} address {satoshi} (or "all") Wait for the next invoice to be paid, after {lastpay_index}
amount via Bitcoin transaction. Only select outputs (if supplied)
with {minconf} confirmations
""" """
payload = { payload = {
"destination": destination, "lastpay_index": lastpay_index
"satoshi": satoshi,
"feerate": feerate,
"minconf": minconf,
} }
return self.call("withdraw", payload) return self.call("waitanyinvoice", payload)
def newaddr(self, addresstype=None):
"""Get a new address of type {addresstype} of the internal wallet.
"""
return self.call("newaddr", {"addresstype": addresstype})
def listfunds(self):
"""
Show funds available for opening channels
"""
return self.call("listfunds")
def listforwards(self):
"""List all forwarded payments and their information
"""
return self.call("listforwards")
def dev_rescan_outputs(self): def waitinvoice(self, label):
"""
Synchronize the state of our funds with bitcoind
""" """
return self.call("dev-rescan-outputs") Wait for an incoming payment matching the invoice with {label}
def dev_forget_channel(self, peerid, force=False):
""" Forget the channel with id=peerid
""" """
return self.call( payload = {
"dev-forget-channel", "label": label
payload={"id": peerid, "force": force} }
) return self.call("waitinvoice", payload)
def disconnect(self, peer_id, force=False): def waitsendpay(self, payment_hash, timeout=None):
""" """
Disconnect from peer with {peer_id}, optional {force} even if has active channel Wait for payment for preimage of {payment_hash} to complete
""" """
payload = { payload = {
"id": peer_id, "payment_hash": payment_hash,
"force": force, "timeout": timeout
} }
return self.call("disconnect", payload) return self.call("waitsendpay", payload)
def feerates(self, style, urgent=None, normal=None, slow=None): def withdraw(self, destination, satoshi, feerate=None, minconf=None):
""" """
Supply feerate estimates manually. Send to {destination} address {satoshi} (or "all")
amount via Bitcoin transaction. Only select outputs
with {minconf} confirmations
""" """
payload = { payload = {
"style": style, "destination": destination,
"urgent": urgent, "satoshi": satoshi,
"normal": normal, "feerate": feerate,
"slow": slow "minconf": minconf,
} }
return self.call("feerates", payload) return self.call("withdraw", payload)

Loading…
Cancel
Save