orb.ln.ln module

class orb.ln.ln.Ln(node_type: str | None = None, fallback_to_mock: bool = True, cache: bool = True, use_prefs: bool = True, hostname: str | None = None, protocol: str | None = None, mac_secure: str | None = None, mac: str | None = None, cert_secure: str | None = None, cert: str | None = None, rest_port: int | None = None, grpc_port: int | None = None, version: str | None = None)

Bases: object

The orb.ln.Ln class can be used to perform RPC/REST calls on LND / CLN nodes using a unified interface.

Parameters:
  • node_type – either “lnd” or “cln”

  • fallback_to_mock – wehther to provide a mock class if construction fails

  • cache – whether to cache the result, or rebuilt the concrete class each time

  • use_prefs – whether to use the user prefs to initialize

  • hostname – the hostname or ip address to the node

  • protocol – rest or grpc

  • mac_secure – the rsa encrypted macaroon

  • mac – the plain macaroon

  • cert_secure – the rsa encrypted certificate string

  • cert – the plain certificate string

  • rest_port – the REST protocol port

  • grpc_port – the GRPC protocol port

  • version – the API version

close_channel(chan_id)

This is a general close_channel method, that provides no options besides providing the channel id. If more control is required, then use the .concrete attribute to call close_channel on the implementation itself.

CLN note:

With CLN, an unilateral_close of 60 seconds is used, with a 50% fee_negotiation_step.

LND note:

With LND, the channel is not force-closed, and sat_per_vbyte is set to mempool’s ‘halfHourFee’ policy.

decode_payment_request(bolt11: str) PaymentRequest

Decodes a bolt11 payment request.

Parameters:

bolt11 – the bolt11 payment request string

Returns:

The payment request as a orb.ln.types.PaymentRequest

Return type:

PaymentRequest

generate_invoice(amount: int, memo: str)
get_balance() Balance

Get balance for current node.

get_channels()
get_forwarding_history(index_offset=0, num_max_events=100) ForwardingEvents

Get the settled forwarding events for the current node.

Parameters:
  • index_offset – starting index.

  • num_max_events – number of paginated events to fetch.

get_htlc_events() HTLC
get_info() Info

Get basic info.

get_node_alias(pub_key)

Get the alias for the given pubkey. Note this command is cached, using a database and an LRU cache, so is thus safe to call in rapid succession.

get_node_info(pubkey) NodeInfo

Get information on the node provided in params.

Parameters:

pubkey – The pubkey of the node for which to get information.

get_policy_from(chan_id) Policy

Get policy from for the given channel.

Parameters:

chan_id (str) – the channel id for which to get policy.

get_policy_to(chan_id) Policy

Get policy to for the given channel.

Parameters:

chan_id (str) – the channel id for which to get policy.

get_route(fee_limit_msat=None, pub_key=None, source_pub_key=None, outgoing_chan_id=None, ignored_nodes=[], ignored_pairs=[], last_hop_pubkey=None, amount_sat=None, time_pref=None, cltv=0, **kwargs) Route

Get a route to the given pubkey.

Parameters:
  • fee_limit_msat – the fee limit in millisatoshis. If the route fee goes over, hops will be empty.

  • pub_key – the pub_key of the node to which to find a route.

  • source_pub_key – the pub_key of the node from which to find a route.

  • outgoing_chan_id – the channel id the first hop o the route.

  • ignored_nodes – list of nodes to ignore.

  • ignored_pairs – list of pairs to ignore (LND only).

  • last_hop_pubkey – the last node before ‘pub_key’ (LND only).

  • amount_sat – the amount in satoshis the route should accomodate.

  • time_pref – the time preference of the route, from 0 to 1. (LND only).

  • cltv – absolute lock time. (CLN only).

list_payments(index_offset: int = 0, max_payments: int = 100)

Get the completed payments for the current node.

Parameters:
  • index_offset – starting index.

  • max_payments – number of paginated payments to fetch.

list_peers() Peers

List peers for the current node.

local_remote_bal() LocalRemoteBal

Get balance for current node.

open_channel(node_pubkey_string, sat_per_vbyte, amount_sat)
send_coins(addr: str, satoshi: int, sat_per_vbyte: int, send_all: bool = False) ChainTransaction
send_payment(payment_request, route) SendPaymentResponse
update_channel_policy(channel, fee_rate=None, base_fee_msat=None, time_lock_delta=None, max_htlc_msat=None, min_htlc_msat=None)
orb.ln.ln.factory(pk: str) Ln