Skip to content

Conversation

@renepickhardt
Copy link
Contributor

which might be extended if payment channels are missing.

It would be nice if you could double check that I did not mess up the check of global features and the direction flag of channels (comments in the code with references to c-lightning and BOLTs)

This plugin helps you to construct a route object (to be used with sendpay) which goes over a sequence of node ids. if all these nodeids are on a path of payment channels an onion following this path will be constructed. In the case of missing channels lightning-cli geroute is invoked to find partial routs.

This plugin can be used to create circular onions or to send payments along specific paths if that is necessary (as long as the paths provide enough liquidity).

I guess this plugin could also be used to simulate the behaviour of trampoline payments.

And of course I imagine you the reader of this message will find even more creative ways of using it.

examples

First we have an example where a path of payment channel between all nodes exists. The output should be exactly the same as calling lightning-cli getroute 0383494542d2e21cafc46d80ae9d2a0bd6b55db4b50721ac3703315c59b9ec27b3 1000 1 9 032060a40a94dc7b848d02314e4ccebe20f451dc87f28c1ed685caa58bfcc3989a sufficiently often (until lightningd decides to return this particular route)

$ lightning-cli getfixedroute 1000 '["032060a40a94dc7b848d02314e4ccebe20f451dc87f28c1ed685caa58bfcc3989a","022c260f9ad58196af280c80a96ec9eabf6404df59ff1a7553b0f381c875a29ba0","02bb24da3d0fb0793f4918c7599f973cc402f0912ec3fb530470f1fc08bdd6ecb5","0217890e3aad8d35bc054f43acc00084b25229ecff0ab68debd82883ad65ee8266","0383494542d2e21cafc46d80ae9d2a0bd6b55db4b50721ac3703315c59b9ec27b3"]'
{
   "route": [
      {
         "id": "022c260f9ad58196af280c80a96ec9eabf6404df59ff1a7553b0f381c875a29ba0",
         "channel": "554745x2295x1",
         "direction": 1,
         "msatoshi": 2004,
         "amount_msat": "2004msat",
         "dealy": 187,
         "style": "tlv"
      },
      {
         "id": "02bb24da3d0fb0793f4918c7599f973cc402f0912ec3fb530470f1fc08bdd6ecb5",
         "channel": "574084x2058x1",
         "direction": 0,
         "msatoshi": 2004,
         "amount_msat": "2004msat",
         "dealy": 183,
         "style": "tlv"
      },
      {
         "id": "0217890e3aad8d35bc054f43acc00084b25229ecff0ab68debd82883ad65ee8266",
         "channel": "567407x202x1",
         "direction": 1,
         "msatoshi": 2000,
         "amount_msat": "2000msat",
         "dealy": 153,
         "style": "tlv"
      },
      {
         "id": "0383494542d2e21cafc46d80ae9d2a0bd6b55db4b50721ac3703315c59b9ec27b3",
         "channel": "554391x1396x1",
         "direction": 0,
         "msatoshi": 1000,
         "amount_msat": "1000msat",
         "dealy": 9,
         "style": "tlv"
      }
   ]
}

same example as above but I artificially injected my own node (03efccf2c383d7bf340da9a3f02e2c23104a0e4fe8ac1a880c8e2dc92fbdacd9df) at the 3rd hop so now the result contains more channels because my node was not connected to the nodes in this path.

 $ lightning-cli getfixedroute 1000 '["032060a40a94dc7b848d02314e4ccebe20f451dc87f28c1ed685caa58bfcc3989a","022c260f9ad58196af280c80a96ec9eabf6404df59ff1a7553b0f381c875a29ba0","02bb24da3d0fb0793f4918c7599f973cc402f0912ec3fb530470f1fc08bdd6ecb5","03efccf2c383d7bf340da9a3f02e2c23104a0e4fe8ac1a880c8e2dc92fbdacd9df","0217890e3aad8d35bc054f43acc00084b25229ecff0ab68debd82883ad65ee8266","0383494542d2e21cafc46d80ae9d2a0bd6b55db4b50721ac3703315c59b9ec27b3"]'
{
   "route": [
      {
         "id": "022c260f9ad58196af280c80a96ec9eabf6404df59ff1a7553b0f381c875a29ba0",
         "channel": "554745x2295x1",
         "direction": 1,
         "msatoshi": 2431,
         "amount_msat": "2431msat",
         "dealy": 239,
         "style": "tlv"
      },
      {
         "id": "02bb24da3d0fb0793f4918c7599f973cc402f0912ec3fb530470f1fc08bdd6ecb5",
         "channel": "574084x2058x1",
         "direction": 0,
         "msatoshi": 2431,
         "amount_msat": "2431msat",
         "dealy": 235,
         "style": "tlv"
      },
      {
         "id": "0390b5d4492dc2f5318e5233ab2cebf6d48914881a33ef6a9c6bcdbb433ad986d0",
         "channel": "567217x1362x0",
         "direction": 0,
         "msatoshi": 2435,
         "amount_msat": "2435msat",
         "delay": 231,
         "style": "tlv"
      },
      {
         "id": "03efccf2c383d7bf340da9a3f02e2c23104a0e4fe8ac1a880c8e2dc92fbdacd9df",
         "channel": "550103x2322x0",
         "direction": 0,
         "msatoshi": 2431,
         "amount_msat": "2431msat",
         "delay": 201,
         "style": "legacy"
      },
      {
         "id": "032679fec1213e5b0a23e066c019d7b991b95c6e4d28806b9ebd1362f9e32775cf",
         "channel": "558577x633x1",
         "direction": 1,
         "msatoshi": 2004,
         "amount_msat": "2004msat",
         "delay": 187,
         "style": "tlv"
      },
      {
         "id": "030995c0c0217d763c2274aa6ed69a0bb85fa2f7d118f93631550f3b6219a577f5",
         "channel": "574084x2092x1",
         "direction": 1,
         "msatoshi": 2004,
         "amount_msat": "2004msat",
         "delay": 183,
         "style": "tlv"
      },
      {
         "id": "0217890e3aad8d35bc054f43acc00084b25229ecff0ab68debd82883ad65ee8266",
         "channel": "573935x1387x1",
         "direction": 1,
         "msatoshi": 2000,
         "amount_msat": "2000msat",
         "delay": 153,
         "style": "tlv"
      },
      {
         "id": "0383494542d2e21cafc46d80ae9d2a0bd6b55db4b50721ac3703315c59b9ec27b3",
         "channel": "554391x1396x1",
         "direction": 0,
         "msatoshi": 1000,
         "amount_msat": "1000msat",
         "dealy": 9,
         "style": "tlv"
      }
   ]
}

Copy link
Contributor

@cdecker cdecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice idea. I was thinking about implementing something like this and call it waypoint but fixedroute also works :-)

Comment on lines 26 to 27
d = {}
n = {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can attach these globals to plugin instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I just realized I should also have renamed them as channelidx and nodeidx I did not set them up in init in the beginning but I thought it would be better to not parse through the json everyone time plugin is called

amount = amount + fees
key = "{}:{}".format(src, dest)
if key not in d:
route = plugin.rpc.getroute(dest, amount, 1, delay, src)["route"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to add error handling here, something like:

try:
    route = plugin.rpc.getroute(dest, amount, 1,  delay, src)["route"]
except RpcError as e:
    # TODO: narrow down error types we catch
    print("No route found:", e)
    return {"route": None}

(Requires an include: from pyln.client import RpcError).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually quite fine already since Exceptions are bubbled up through the RPC passthrough interface. I'll fix this up by adding some more context, about which leg failed, but re-raising the exception.

@cdecker
Copy link
Contributor

cdecker commented Sep 6, 2020

Clean rebase on top of master

@cdecker
Copy link
Contributor

cdecker commented Sep 6, 2020

Fixed up and cleaned up.

cdecker and others added 2 commits September 7, 2020 11:11
Users often use virtualenvs to confine the dependencies and use a different
interpreter. This uses whatever they specified.
@chrisguida
Copy link
Collaborator

Needs rebase

@chrisguida
Copy link
Collaborator

This plugin, fixroute, has been archived here https://github.com/lightningd/plugins/blob/master/archived.md#archived-plugins

Feel free to reopen this PR if you want to continue working on it!

@chrisguida chrisguida closed this Sep 27, 2024
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.

5 participants