Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
alias list for bitcoind, bitcoin-cli, lnd, lncli

These can be added to your .bashrc or .zshrc

some cmd's require jq tool.
  • linux - sudo apt-get install jq
  • mac - brew install jq
alias btcinfo='bitcoin-cli getwalletinfo | egrep "\"balance\""; bitcoin-cli getnetworkinfo | egrep "\"version\"|connections"; bitcoin-cli getmininginfo | egrep "\"blocks\"|errors"'

alias bcstart="bitcoind -daemon"
alias btstart="bitcoind -testnet -daemon"
alias brstart="bitcoind -regtest -daemon"

alias bcstop="bitcoin-cli stop"
alias btstop="bitcoin-cli -testnet stop"
alias brstop="bitcoin-cli -regtest stop"

alias bcdir="cd ~/.bitcoin/" #linux default bitcoin path
alias btdir="cd ~/.bitcoin/testnet" #linux default bitcoin testnet path
alias brdir="cd ~/.bitcoin/regtest" #linux default bitcoin regtest path

alias bc="bitcoin-cli"
alias bt="bitcoin-cli -testnet"
alias br="bitcoin-cli -regtest"
alias gbinfo="bitcoin-cli getblockchaininfo"

alias lchannelcaps='lncli describegraph | jq '\''.nodes[].total_channel_capacities=0 | foreach .nodes[] as  ( . ; foreach .edges[] as  ( . ; if .node1_pub==.pub_key then (|.total_channel_capacities=.total_channel_capacity+(.capacity|tonumber)) else empty end ; .)  ; . )'\'''
alias lnactive='lncli listchannels | jq '\''[ .channels | .[] | select(.active==true) ] | length'\'''
alias lnchaninfo='lncli listchannels | jq '\''[ .channels | .[] | { "remote_pubkey": .remote_pubkey, "capacity": .capacity|tonumber, "local_balance": .local_balance|tonumber, "remote_balance": .remote_balance|
tonumber, "distribution_pct": ( ( .local_balance|tonumber ) / ( (.remote_balance|tonumber ) + ( .local_balance|tonumber ) ) ), "total_satoshis_sent": .total_satoshis_sent|tonumber, "total_satoshis_received": .total_satoshis_received|tonumber } ]'\'''
alias lndist='lncli listchannels | jq '\''[ .channels | .[] |  { "remote_pubkey": .remote_pubkey, "capacity": .capacity, "distribution_pct": ( ( .local_balance|tonumber ) / ( (.remote_balance|tonumber ) + ( .local_balance|tonumber ) ) ) } ]'\'''
alias lnforcegraph='lncli describegraph | jq -c '\''{ "nodes": .nodes | map({ "id": .pub_key, "alias": .alias|match("[^\u0000]+")| .string, "group": 1, "color": .color, "addresses": .addresses }), "links": .edges | map({"source": .node1_pub, "target": .node2_pub, "capacity": .capacity|tonumber }) }'\'''
alias lninactive='lncli listchannels | jq '\''[ .channels | .[] | select(.active==false) ] | length'\'''
alias lnlimbo='lncli pendingchannels | jq '\''.total_limbo_balance|tonumber'\'''
alias lnnodeinfo='lncli listchannels | jq -r .channels[].remote_pubkey | while read p; do lncli getnodeinfo "$p"; done'
alias lnoffchain='lncli listchannels | jq '\''[ .channels | .[] | select(.num_updates|tonumber>0) ]'\'''
alias lnoffchainupdates='lncli listchannels | jq '\''.channels | map(.num_updates|tonumber) | add'\'''
alias lnpendingc='lncli pendingchannels | jq '\''.pending_close_channels|length'\'''
alias lnpendingf='lncli pendingchannels | jq '\''.pending_force_closing_channels|length'\'''
alias lnpendingo='lncli pendingchannels | jq '\''.pending_open_channels|length'\'''
alias lnreceivedbal='lncli listchannels | jq '\''.channels | map(.total_satoshis_received|tonumber) | add'\'''
alias lnrecv='lncli listchannels | jq '\''[ .channels | .[] | select(.total_satoshis_received|tonumber>0) ]'\'''
alias lnremotebal='lncli listchannels | jq '\''.channels | map(.remote_balance|tonumber) | add'\'''
alias lnsentbal='lncli listchannels | jq '\''.channels | map(.total_satoshis_sent|tonumber) | add'\'''
alias lntopchannels='lncli describegraph | jq '\''[ .edges | sort_by(.capacity|tonumber) | reverse | .[] | { "node1_pub": .node1_pub, "node2_pub": .node2_pub, "Capacity": .capacity|tonumber,  } ]'\'''
alias lntotalcap='lncli listchannels | jq '\''.channels | map(.capacity|tonumber) | add'\'''
alias lnunsettled='lncli listchannels | jq '\''[ .channels | .[] | select(.unsettled_balance|tonumber>0) ]'\'''
alias lnunsettledbal='lncli listchannels | jq '\''.channels | map(.unsettled_balance|tonumber) | add'\'''
alias lndstatus='sudo journalctl -f -u lnd'
alias bitcoindstatus='sudo tail -f /home/bitcoin/.bitcoin/testnet3/debug.log'
alias unlock='lncli unlock'
alias newaddress='lncli newaddress np2wkh'
alias txns='lncli listchaintxns'
alias getinfo='lncli getinfo'
alias walletbalance='lncli walletbalance'
alias peers='lncli listpeers'
alias channels='lncli listchannels'
alias channelbalance='lncli channelbalance'
alias pendingchannels='lncli pendingchannels'
alias openchannel='lncli openchannel'
alias connect='lncli connect'
alias payinvoice='lncli payinvoice'
alias addinvoice='lncli addinvoice'
@thejerrod
Copy link

thejerrod commented Jul 12, 2021

alias openchannel='lncli --etwork=testnet openchannel'
to
alias openchannel='lncli --network=testnet openchannel'

#pleblife

@bliotti
Copy link
Author

bliotti commented Jul 13, 2021

alias openchannel='lncli --etwork=testnet openchannel'
to
alias openchannel='lncli --network=testnet openchannel'

#pleblife

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment