{"action":"created","comment":{"url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments/287270878","pull_request_review_id":241623395,"id":287270878,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI4NzI3MDg3OA==","diff_hunk":"@@ -1,6 +1,13 @@\n package channeldb\n \n-import \"io\"\n+import (","path":"channeldb/legacy_serialization.go","position":4,"original_position":4,"commit_id":"111d4a89c84991648c75a0183b80e338e5168e9a","original_commit_id":"d987c982de97fe5d653c61ffb6cd05fc2c583c03","user":{"login":"halseth","id":3765732,"node_id":"MDQ6VXNlcjM3NjU3MzI=","avatar_url":"https://avatars1.githubusercontent.com/u/3765732?v=4","gravatar_id":"","url":"https://api.github.com/users/halseth","html_url":"https://github.com/halseth","followers_url":"https://api.github.com/users/halseth/followers","following_url":"https://api.github.com/users/halseth/following{/other_user}","gists_url":"https://api.github.com/users/halseth/gists{/gist_id}","starred_url":"https://api.github.com/users/halseth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/halseth/subscriptions","organizations_url":"https://api.github.com/users/halseth/orgs","repos_url":"https://api.github.com/users/halseth/repos","events_url":"https://api.github.com/users/halseth/events{/privacy}","received_events_url":"https://api.github.com/users/halseth/received_events","type":"User","site_admin":false},"body":"Done.","created_at":"2019-05-24T08:51:36Z","updated_at":"2019-05-24T08:51:37Z","html_url":"https://github.com/lightningnetwork/lnd/pull/2761#discussion_r287270878","pull_request_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/2761","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments/287270878"},"html":{"href":"https://github.com/lightningnetwork/lnd/pull/2761#discussion_r287270878"},"pull_request":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/2761"}},"in_reply_to_id":285951245},"pull_request":{"url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/2761","id":260361475,"node_id":"MDExOlB1bGxSZXF1ZXN0MjYwMzYxNDc1","html_url":"https://github.com/lightningnetwork/lnd/pull/2761","diff_url":"https://github.com/lightningnetwork/lnd/pull/2761.diff","patch_url":"https://github.com/lightningnetwork/lnd/pull/2761.patch","issue_url":"https://api.github.com/repos/lightningnetwork/lnd/issues/2761","number":2761,"state":"open","locked":false,"title":"[reliable payments] router payment state machine","user":{"login":"halseth","id":3765732,"node_id":"MDQ6VXNlcjM3NjU3MzI=","avatar_url":"https://avatars1.githubusercontent.com/u/3765732?v=4","gravatar_id":"","url":"https://api.github.com/users/halseth","html_url":"https://github.com/halseth","followers_url":"https://api.github.com/users/halseth/followers","following_url":"https://api.github.com/users/halseth/following{/other_user}","gists_url":"https://api.github.com/users/halseth/gists{/gist_id}","starred_url":"https://api.github.com/users/halseth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/halseth/subscriptions","organizations_url":"https://api.github.com/users/halseth/orgs","repos_url":"https://api.github.com/users/halseth/repos","events_url":"https://api.github.com/users/halseth/events{/privacy}","received_events_url":"https://api.github.com/users/halseth/received_events","type":"User","site_admin":false},"body":"This PR introduces a persistent state machine to the `ChannelRouter`'s payment flow, ensuring we can handle payment results that are received after a restart. It also paves they way for adding cancellation of payments, and resuming payment sessions across restarts.\r\n\r\n### Problem\r\n`lnd` currently runs into problems if it is restarted while an HTLC is in flight on the network. The primary reason for this is the way the `router` hands the HTLC to the `switch`.  The `router` persist no information about the payment, so when a result eventually comes back, we risk the information needed to properly populate the `OutgoingPayment` in the database is lost.\r\n\r\n### Solution\r\nWith the `paymentStateMachine` introduced in this PR, we store two pieces of key information:\r\n1. The HTLC `paymentID`. This is used to query the `Switch` whether the HTLC is still active. If not active we know that we can safely retry the payment attempt. If active the `router` will wait for the result to be available, and store the result to the DB.\r\n2. The HTLC's `route`.  This is added to the DB  together with the preimage when the payment succeeds. \r\n\r\n#### Note\r\nThe `Switch` does not currently persist the pending payment attempts across restarts. This will be added in a follow-up PR.\r\n\r\nReplaces #2475\r\n\r\nBuilds on \r\n- [x] #3065 \r\n- [x] #3064 \r\n- [x] #3063 ","created_at":"2019-03-12T13:25:29Z","updated_at":"2019-05-24T08:51:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b2bfcd8c7a2f9482c9762911f1946e58ee2ca66d","assignee":{"login":"Roasbeef","id":998190,"node_id":"MDQ6VXNlcjk5ODE5MA==","avatar_url":"https://avatars3.githubusercontent.com/u/998190?v=4","gravatar_id":"","url":"https://api.github.com/users/Roasbeef","html_url":"https://github.com/Roasbeef","followers_url":"https://api.github.com/users/Roasbeef/followers","following_url":"https://api.github.com/users/Roasbeef/following{/other_user}","gists_url":"https://api.github.com/users/Roasbeef/gists{/gist_id}","starred_url":"https://api.github.com/users/Roasbeef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Roasbeef/subscriptions","organizations_url":"https://api.github.com/users/Roasbeef/orgs","repos_url":"https://api.github.com/users/Roasbeef/repos","events_url":"https://api.github.com/users/Roasbeef/events{/privacy}","received_events_url":"https://api.github.com/users/Roasbeef/received_events","type":"User","site_admin":false},"assignees":[{"login":"Roasbeef","id":998190,"node_id":"MDQ6VXNlcjk5ODE5MA==","avatar_url":"https://avatars3.githubusercontent.com/u/998190?v=4","gravatar_id":"","url":"https://api.github.com/users/Roasbeef","html_url":"https://github.com/Roasbeef","followers_url":"https://api.github.com/users/Roasbeef/followers","following_url":"https://api.github.com/users/Roasbeef/following{/other_user}","gists_url":"https://api.github.com/users/Roasbeef/gists{/gist_id}","starred_url":"https://api.github.com/users/Roasbeef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Roasbeef/subscriptions","organizations_url":"https://api.github.com/users/Roasbeef/orgs","repos_url":"https://api.github.com/users/Roasbeef/repos","events_url":"https://api.github.com/users/Roasbeef/events{/privacy}","received_events_url":"https://api.github.com/users/Roasbeef/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":778128862,"node_id":"MDU6TGFiZWw3NzgxMjg4NjI=","url":"https://api.github.com/repos/lightningnetwork/lnd/labels/payments","name":"payments","color":"f754c6","default":false}],"milestone":{"url":"https://api.github.com/repos/lightningnetwork/lnd/milestones/12","html_url":"https://github.com/lightningnetwork/lnd/milestone/12","labels_url":"https://api.github.com/repos/lightningnetwork/lnd/milestones/12/labels","id":4219681,"node_id":"MDk6TWlsZXN0b25lNDIxOTY4MQ==","number":12,"title":"0.7","description":"","creator":{"login":"cfromknecht","id":2013993,"node_id":"MDQ6VXNlcjIwMTM5OTM=","avatar_url":"https://avatars1.githubusercontent.com/u/2013993?v=4","gravatar_id":"","url":"https://api.github.com/users/cfromknecht","html_url":"https://github.com/cfromknecht","followers_url":"https://api.github.com/users/cfromknecht/followers","following_url":"https://api.github.com/users/cfromknecht/following{/other_user}","gists_url":"https://api.github.com/users/cfromknecht/gists{/gist_id}","starred_url":"https://api.github.com/users/cfromknecht/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfromknecht/subscriptions","organizations_url":"https://api.github.com/users/cfromknecht/orgs","repos_url":"https://api.github.com/users/cfromknecht/repos","events_url":"https://api.github.com/users/cfromknecht/events{/privacy}","received_events_url":"https://api.github.com/users/cfromknecht/received_events","type":"User","site_admin":false},"open_issues":20,"closed_issues":11,"state":"open","created_at":"2019-04-11T02:26:39Z","updated_at":"2019-05-24T01:30:37Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/2761/commits","review_comments_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/2761/comments","review_comment_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lightningnetwork/lnd/issues/2761/comments","statuses_url":"https://api.github.com/repos/lightningnetwork/lnd/statuses/111d4a89c84991648c75a0183b80e338e5168e9a","head":{"label":"halseth:reliable-payments-router-state-machine","ref":"reliable-payments-router-state-machine","sha":"111d4a89c84991648c75a0183b80e338e5168e9a","user":{"login":"halseth","id":3765732,"node_id":"MDQ6VXNlcjM3NjU3MzI=","avatar_url":"https://avatars1.githubusercontent.com/u/3765732?v=4","gravatar_id":"","url":"https://api.github.com/users/halseth","html_url":"https://github.com/halseth","followers_url":"https://api.github.com/users/halseth/followers","following_url":"https://api.github.com/users/halseth/following{/other_user}","gists_url":"https://api.github.com/users/halseth/gists{/gist_id}","starred_url":"https://api.github.com/users/halseth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/halseth/subscriptions","organizations_url":"https://api.github.com/users/halseth/orgs","repos_url":"https://api.github.com/users/halseth/repos","events_url":"https://api.github.com/users/halseth/events{/privacy}","received_events_url":"https://api.github.com/users/halseth/received_events","type":"User","site_admin":false},"repo":{"id":86519132,"node_id":"MDEwOlJlcG9zaXRvcnk4NjUxOTEzMg==","name":"lnd","full_name":"halseth/lnd","private":false,"owner":{"login":"halseth","id":3765732,"node_id":"MDQ6VXNlcjM3NjU3MzI=","avatar_url":"https://avatars1.githubusercontent.com/u/3765732?v=4","gravatar_id":"","url":"https://api.github.com/users/halseth","html_url":"https://github.com/halseth","followers_url":"https://api.github.com/users/halseth/followers","following_url":"https://api.github.com/users/halseth/following{/other_user}","gists_url":"https://api.github.com/users/halseth/gists{/gist_id}","starred_url":"https://api.github.com/users/halseth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/halseth/subscriptions","organizations_url":"https://api.github.com/users/halseth/orgs","repos_url":"https://api.github.com/users/halseth/repos","events_url":"https://api.github.com/users/halseth/events{/privacy}","received_events_url":"https://api.github.com/users/halseth/received_events","type":"User","site_admin":false},"html_url":"https://github.com/halseth/lnd","description":"Lightning Network Daemon ⚡️","fork":true,"url":"https://api.github.com/repos/halseth/lnd","forks_url":"https://api.github.com/repos/halseth/lnd/forks","keys_url":"https://api.github.com/repos/halseth/lnd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/halseth/lnd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/halseth/lnd/teams","hooks_url":"https://api.github.com/repos/halseth/lnd/hooks","issue_events_url":"https://api.github.com/repos/halseth/lnd/issues/events{/number}","events_url":"https://api.github.com/repos/halseth/lnd/events","assignees_url":"https://api.github.com/repos/halseth/lnd/assignees{/user}","branches_url":"https://api.github.com/repos/halseth/lnd/branches{/branch}","tags_url":"https://api.github.com/repos/halseth/lnd/tags","blobs_url":"https://api.github.com/repos/halseth/lnd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/halseth/lnd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/halseth/lnd/git/refs{/sha}","trees_url":"https://api.github.com/repos/halseth/lnd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/halseth/lnd/statuses/{sha}","languages_url":"https://api.github.com/repos/halseth/lnd/languages","stargazers_url":"https://api.github.com/repos/halseth/lnd/stargazers","contributors_url":"https://api.github.com/repos/halseth/lnd/contributors","subscribers_url":"https://api.github.com/repos/halseth/lnd/subscribers","subscription_url":"https://api.github.com/repos/halseth/lnd/subscription","commits_url":"https://api.github.com/repos/halseth/lnd/commits{/sha}","git_commits_url":"https://api.github.com/repos/halseth/lnd/git/commits{/sha}","comments_url":"https://api.github.com/repos/halseth/lnd/comments{/number}","issue_comment_url":"https://api.github.com/repos/halseth/lnd/issues/comments{/number}","contents_url":"https://api.github.com/repos/halseth/lnd/contents/{+path}","compare_url":"https://api.github.com/repos/halseth/lnd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/halseth/lnd/merges","archive_url":"https://api.github.com/repos/halseth/lnd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/halseth/lnd/downloads","issues_url":"https://api.github.com/repos/halseth/lnd/issues{/number}","pulls_url":"https://api.github.com/repos/halseth/lnd/pulls{/number}","milestones_url":"https://api.github.com/repos/halseth/lnd/milestones{/number}","notifications_url":"https://api.github.com/repos/halseth/lnd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/halseth/lnd/labels{/name}","releases_url":"https://api.github.com/repos/halseth/lnd/releases{/id}","deployments_url":"https://api.github.com/repos/halseth/lnd/deployments","created_at":"2017-03-29T00:00:37Z","updated_at":"2019-05-22T07:39:35Z","pushed_at":"2019-05-24T08:44:31Z","git_url":"git://github.com/halseth/lnd.git","ssh_url":"git@github.com:halseth/lnd.git","clone_url":"https://github.com/halseth/lnd.git","svn_url":"https://github.com/halseth/lnd","homepage":"","size":32031,"stargazers_count":3,"watchers_count":3,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":4,"open_issues":1,"watchers":3,"default_branch":"master"}},"base":{"label":"lightningnetwork:master","ref":"master","sha":"6e0084fec90d16ecf9e61d6754251d5a29b4d986","user":{"login":"lightningnetwork","id":13424735,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDI0NzM1","avatar_url":"https://avatars0.githubusercontent.com/u/13424735?v=4","gravatar_id":"","url":"https://api.github.com/users/lightningnetwork","html_url":"https://github.com/lightningnetwork","followers_url":"https://api.github.com/users/lightningnetwork/followers","following_url":"https://api.github.com/users/lightningnetwork/following{/other_user}","gists_url":"https://api.github.com/users/lightningnetwork/gists{/gist_id}","starred_url":"https://api.github.com/users/lightningnetwork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lightningnetwork/subscriptions","organizations_url":"https://api.github.com/users/lightningnetwork/orgs","repos_url":"https://api.github.com/users/lightningnetwork/repos","events_url":"https://api.github.com/users/lightningnetwork/events{/privacy}","received_events_url":"https://api.github.com/users/lightningnetwork/received_events","type":"Organization","site_admin":false},"repo":{"id":49765480,"node_id":"MDEwOlJlcG9zaXRvcnk0OTc2NTQ4MA==","name":"lnd","full_name":"lightningnetwork/lnd","private":false,"owner":{"login":"lightningnetwork","id":13424735,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDI0NzM1","avatar_url":"https://avatars0.githubusercontent.com/u/13424735?v=4","gravatar_id":"","url":"https://api.github.com/users/lightningnetwork","html_url":"https://github.com/lightningnetwork","followers_url":"https://api.github.com/users/lightningnetwork/followers","following_url":"https://api.github.com/users/lightningnetwork/following{/other_user}","gists_url":"https://api.github.com/users/lightningnetwork/gists{/gist_id}","starred_url":"https://api.github.com/users/lightningnetwork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lightningnetwork/subscriptions","organizations_url":"https://api.github.com/users/lightningnetwork/orgs","repos_url":"https://api.github.com/users/lightningnetwork/repos","events_url":"https://api.github.com/users/lightningnetwork/events{/privacy}","received_events_url":"https://api.github.com/users/lightningnetwork/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/lightningnetwork/lnd","description":"Lightning Network Daemon ⚡️","fork":false,"url":"https://api.github.com/repos/lightningnetwork/lnd","forks_url":"https://api.github.com/repos/lightningnetwork/lnd/forks","keys_url":"https://api.github.com/repos/lightningnetwork/lnd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lightningnetwork/lnd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lightningnetwork/lnd/teams","hooks_url":"https://api.github.com/repos/lightningnetwork/lnd/hooks","issue_events_url":"https://api.github.com/repos/lightningnetwork/lnd/issues/events{/number}","events_url":"https://api.github.com/repos/lightningnetwork/lnd/events","assignees_url":"https://api.github.com/repos/lightningnetwork/lnd/assignees{/user}","branches_url":"https://api.github.com/repos/lightningnetwork/lnd/branches{/branch}","tags_url":"https://api.github.com/repos/lightningnetwork/lnd/tags","blobs_url":"https://api.github.com/repos/lightningnetwork/lnd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lightningnetwork/lnd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lightningnetwork/lnd/git/refs{/sha}","trees_url":"https://api.github.com/repos/lightningnetwork/lnd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lightningnetwork/lnd/statuses/{sha}","languages_url":"https://api.github.com/repos/lightningnetwork/lnd/languages","stargazers_url":"https://api.github.com/repos/lightningnetwork/lnd/stargazers","contributors_url":"https://api.github.com/repos/lightningnetwork/lnd/contributors","subscribers_url":"https://api.github.com/repos/lightningnetwork/lnd/subscribers","subscription_url":"https://api.github.com/repos/lightningnetwork/lnd/subscription","commits_url":"https://api.github.com/repos/lightningnetwork/lnd/commits{/sha}","git_commits_url":"https://api.github.com/repos/lightningnetwork/lnd/git/commits{/sha}","comments_url":"https://api.github.com/repos/lightningnetwork/lnd/comments{/number}","issue_comment_url":"https://api.github.com/repos/lightningnetwork/lnd/issues/comments{/number}","contents_url":"https://api.github.com/repos/lightningnetwork/lnd/contents/{+path}","compare_url":"https://api.github.com/repos/lightningnetwork/lnd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lightningnetwork/lnd/merges","archive_url":"https://api.github.com/repos/lightningnetwork/lnd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lightningnetwork/lnd/downloads","issues_url":"https://api.github.com/repos/lightningnetwork/lnd/issues{/number}","pulls_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls{/number}","milestones_url":"https://api.github.com/repos/lightningnetwork/lnd/milestones{/number}","notifications_url":"https://api.github.com/repos/lightningnetwork/lnd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lightningnetwork/lnd/labels{/name}","releases_url":"https://api.github.com/repos/lightningnetwork/lnd/releases{/id}","deployments_url":"https://api.github.com/repos/lightningnetwork/lnd/deployments","created_at":"2016-01-16T08:19:33Z","updated_at":"2019-05-24T04:31:07Z","pushed_at":"2019-05-24T08:44:36Z","git_url":"git://github.com/lightningnetwork/lnd.git","ssh_url":"git@github.com:lightningnetwork/lnd.git","clone_url":"https://github.com/lightningnetwork/lnd.git","svn_url":"https://github.com/lightningnetwork/lnd","homepage":"","size":27914,"stargazers_count":3893,"watchers_count":3893,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1055,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":364,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1055,"open_issues":364,"watchers":3893,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/2761"},"html":{"href":"https://github.com/lightningnetwork/lnd/pull/2761"},"issue":{"href":"https://api.github.com/repos/lightningnetwork/lnd/issues/2761"},"comments":{"href":"https://api.github.com/repos/lightningnetwork/lnd/issues/2761/comments"},"review_comments":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/2761/comments"},"review_comment":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/2761/commits"},"statuses":{"href":"https://api.github.com/repos/lightningnetwork/lnd/statuses/111d4a89c84991648c75a0183b80e338e5168e9a"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"halseth"}}