8000 cli: add invoice handling route hints by jbrill · Pull Request #1 · jbrill/lnd · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

cli: add invoice handling route hints #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

jbrill
Copy link
Owner
@jbrill jbrill commented May 20, 2024

Change Description

This PR adds route hints to the add invoice cli. This change mimics the RPC addinvoice method, which allows for route hints to be added. Several things to note:

  1. The route hints are a base64 json list
  2. The route hints are only valid if the --private flag is also included

Steps to Test

Simply start up LND with these changes and attempt to add an invoice with the route hints. I've used the following bash script to do this:

function getRouteHint() {
  local node_name=$1

  # Execute the 'getinfo' command and extract the public key
  local pub_key_output=$(run $node_name getinfo)
  local pub_key=$(echo "$pub_key_output" | jq -r '.identity_pubkey // empty')
  
  # Execute the 'listchannels' command and extract the channel ID, ensuring it remains as a numerical value
  local channel_id_output=$(run $node_name listchannels)
  local channel_id=$(echo "$channel_id_output" | jq -r '.channels[0].chan_id // empty')

  # Check if either public key or channel ID are empty, indicating a problem
  if [ -z "$pub_key" ] || [ -z "$channel_id" ]; then
    echo "Error: Public key or channel ID not found for $node_name." >&2
    return 1
  fi

  # Ensure channel_id is numeric (important for Go struct expectation)
  local numeric_channel_id=$(echo "$channel_id" | jq -r 'tonumber')

  # Construct the JSON structure for the route hint, ensuring types match expected schema
  local route_hint_json=$(echo "{\"node_id\":\"$pub_key\",\"chan_id\":$numeric_channel_id,\"fee_base_msat\":1000,\"fee_proportional_millionths\":100,\"cltv_expiry_delta\":40}" | jq -c .)

  # Encode the JSON string to Base64
  echo "$route_hint_json" | base64
}

Then simply run:

local payment_request1_json=$(run olivia addinvoice --private --route_hints "$(getRouteHint)" --amt=1000000)

You should see the relevant route hints encoded in the payment request data.

Pull Request Checklist

Testing

  • Your PR passes all CI checks.
  • Tests covering the positive and negative (error paths) are included.
  • Bug fixes contain tests triggering the bug to prevent regressions.

Code Style and Documentation

📝 Please see our Contribution Guidelines for further guidance.

@jbrill jbrill self-assigned this May 20, 2024
@jbrill jbrill force-pushed the route-hints-cli branch 16 times, most recently from 651ab49 to 598a4dd Compare May 21, 2024 22:55
@jbrill jbrill force-pushed the route-hints-cli branch 6 times, most recently from 6b6439e to ce26c6d Compare June 10, 2024 18:55
@coveralls
Copy link
coveralls commented Jun 10, 2024

Pull Request Test Coverage Report for Build 9453979026

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 22798 unchanged lines in 394 files lost coverage.
  • Overall coverage decreased (-8.4%) to 49.861%

Files with Coverage Reduction New Missed Lines %
routing/errors.go 1 94.74%
routing/graph.go 1 88.0%
signal/signal.go 1 75.0%
lnwallet/parameters.go 1 91.67%
lnwire/typed_lease_expiry.go 2 78.95%
lnwire/typed_fee.go 2 66.67%
channeldb/forwarding_policy.go 2 85.14%
routing/chainview/queue.go 2 94.29%
lnwallet/musig_session.go 2 79.29%
record/hop.go 2 93.33%
Totals Coverage Status
Change from base Build 9410219958: -8.4%
Covered Lines: 93732
Relevant Lines: 187987

💛 - Coveralls

@jbrill jbrill force-pushed the route-hints-cli branch from ce26c6d to 995e900 Compare June 10, 2024 20:45
@coveralls
Copy link
coveralls commented Jun 10, 2024

Pull Request Test Coverage Report for Build 9455298502

Details

  • 40 of 67 (59.7%) changed or added relevant lines in 1 file are covered.
  • 42 unchanged lines in 14 files lost coverage.
  • Overall coverage increased (+0.02%) to 58.27%

Changes Missing Coverage Covered Lines Changed/Added Lines %
cmd/lncli/cmd_invoice.go 40 67 59.7%
Files with Coverage Reduction New Missed Lines %
watchtower/wtclient/queue.go 1 85.56%
queue/gc_queue.go 2 96.51%
invoices/invoiceregistry.go 2 85.86%
rpcperms/interceptor.go 2 82.91%
lnrpc/websocket_proxy.go 2 76.87%
cmd/lncli/cmd_invoice.go 2 20.73%
rpcserver.go 2 71.48%
contractcourt/chain_arbitrator.go 3 80.21%
watchtower/wtdb/migration8/range_index.go 3 13.18%
contractcourt/channel_arbitrator.go 4 85.2%
Totals Coverage Status
Change from base Build 9410219958: 0.02%
Covered Lines: 122951
Relevant Lines: 211003

💛 - Coveralls

@jbrill jbrill force-pushed the route-hints-cli branch from 995e900 to 398cde3 Compare June 10, 2024 21:45
@coveralls
Copy link
coveralls commented Jun 10, 2024

Pull Request Test Coverage Report for Build 9455975232

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 22830 unchanged lines in 395 files lost coverage.
  • Overall coverage decreased (-8.4%) to 49.845%

Files with Coverage Reduction New Missed Lines %
routing/errors.go 1 94.74%
routing/graph.go 1 88.0%
signal/signal.go 1 75.0%
lnwallet/parameters.go 1 91.67%
lnwire/typed_lease_expiry.go 2 78.95%
lnwire/typed_fee.go 2 66.67%
channeldb/forwarding_policy.go 2 85.14%
routing/chainview/queue.go 2 94.29%
lnwallet/musig_session.go 2 79.29%
input/taproot.go 2 93.26%
Totals Coverage Status
Change from base Build 941 8000 0219958: -8.4%
Covered Lines: 93702
Relevant Lines: 187987

💛 - Coveralls

@jbrill jbrill force-pushed the route-hints-cli branch from 398cde3 to 4bb9898 Compare June 12, 2024 17:59
@coveralls
Copy link
coveralls commented Jun 12, 2024

Pull Request Test Coverage Report for Build 9487432776

Details

  • 40 of 67 (59.7%) changed or added relevant lines in 1 file are covered.
  • 52 unchanged lines in 15 files lost coverage.
  • Overall coverage increased (+0.2%) to 58.442%

Changes Missing Coverage Covered Lines Changed/Added Lines %
cmd/lncli/cmd_invoice.go 40 67 59.7%
Files with Coverage Reduction New Missed Lines %
signal/signal.go 1 75.0%
queue/gc_queue.go 2 96.51%
channeldb/graph.go 2 76.92%
htlcswitch/link.go 2 80.16%
cmd/lncli/cmd_invoice.go 2 20.73%
lnwallet/rpcwallet/rpcwallet.go 3 72.02%
contractcourt/breach_resolver.go 3 88.33%
lnwallet/rpcwallet/healthcheck.go 3 58.82%
lnwallet/test/test_interface.go 3 77.62%
contractcourt/channel_arbitrator.go 4 85.2%
Totals Coverage Status
Change from base Build 9410219958: 0.2%
Covered Lines: 123315
Relevant Lines: 211003

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0