{"action":"created","comment":{"url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments/201930350","pull_request_review_id":136523175,"id":201930350,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMTkzMDM1MA==","diff_hunk":"@@ -231,3 +231,73 @@ func migrateInvoiceTimeSeries(tx *bolt.Tx) error {\n \n \treturn nil\n }\n+\n+// migrateInvoiceTimeSeriesOutgoingPayments is a follow up to the\n+// migrateInvoiceTimeSeries migration. As at the time of writing, the\n+// OutgoingPayment struct embeddeds an instance of the Invoice struct. As a\n+// result, we also need to migrate the internal invoice to the new format.\n+func migrateInvoiceTimeSeriesOutgoingPayments(tx *bolt.Tx) error {\n+\tpayBucket := tx.Bucket(paymentBucket)\n+\tif payBucket == nil {\n+\t\treturn nil\n+\t}\n+\n+\tlog.Infof(\"Migrating invoice database to new outgoing payment format\")\n+\n+\terr := payBucket.ForEach(func(payID, paymentBytes []byte) error {\n+\t\tlog.Tracef(\"Migrating payment %x\", payID[:])\n+\n+\t\t// The internal invoices for each payment only contain a\n+\t\t// populated contract term, and creation date, as a result,\n+\t\t// most of the bytes will be \"empty\".\n+\n+\t\t// We'll calculate the end of the invoice index assuming a\n+\t\t// \"minimal\" index that's embedded within the greater\n+\t\t// OutgoingPayment. The breakdown is:\n+\t\t//  3 bytes empty var bytes, 16 bytes creation date, 16 bytes\n+\t\t//  settled date, 32 bytes payment pre-image, 8 bytes value, 1\n+\t\t//  byte settled.\n+\t\tendOfInvoiceIndex := 1 + 1 + 1 + 16 + 16 + 32 + 8 + 1\n+\n+\t\t// We'll now extract the prefix of the pure invoice emebdded\n+\t\t// within.\n+\t\tinvoiceBytes := paymentBytes[:endOfInvoiceIndex]\n+\n+\t\t// With the prefix extracted, we'll copy over the invoice, and\n+\t\t// also add padding for the new 24 bytes of fields, and finally\n+\t\t// append the remainder of the outoing payment.\n+\t\tpaymentCopy := make([]byte, len(invoiceBytes))\n+\t\tcopy(paymentCopy[:], invoiceBytes)\n+\n+\t\tpadding := bytes.Repeat([]byte{0}, 24)\n+\t\tpaymentCopy = append(paymentCopy, padding...)\n+\n+\t\tpaymentCopy = append(","path":"channeldb/migrations.go","position":54,"original_position":54,"commit_id":"6e0b05a20d3a57ecb93bf4c30d0929d2976f7edf","original_commit_id":"6e0b05a20d3a57ecb93bf4c30d0929d2976f7edf","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":"style nit: might be easier to read if written as\r\n```go\r\nvar paymentCopy []byte\r\npaymentCopy = append(paymentCopy, paymentBytes[:endOfInvoiceIndex]...)\r\npaymentCopy = append(paymentCopy, padding...)\r\npaymentCopy = append(paymentCopy, paymentBytes[endOfInvoiceIndex:]...)\r\n```","created_at":"2018-07-12T07:12:56Z","updated_at":"2018-07-12T07:14:04Z","html_url":"https://github.com/lightningnetwork/lnd/pull/1547#discussion_r201930350","pull_request_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1547","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments/201930350"},"html":{"href":"https://github.com/lightningnetwork/lnd/pull/1547#discussion_r201930350"},"pull_request":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1547"}}},"pull_request":{"url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1547","id":200880151,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAwODgwMTUx","html_url":"https://github.com/lightningnetwork/lnd/pull/1547","diff_url":"https://github.com/lightningnetwork/lnd/pull/1547.diff","patch_url":"https://github.com/lightningnetwork/lnd/pull/1547.patch","issue_url":"https://api.github.com/repos/lightningnetwork/lnd/issues/1547","number":1547,"state":"open","locked":false,"title":"channeldb: add new migration to finalize invoice migration for outgoi…","user":{"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},"body":"…ng payments\r\n\r\nIn this commit, we migrate the database away from a partially migrated\r\nstate. In a prior commit, we migrated the database in order to update\r\nthe Invoice struct with three new fields: add index, settle index, paid\r\namt.  However, it was overlooked that the OutgoingPayment struct also\r\nembedded an Invoice within it. As a result, nodes that upgraded to the\r\nfirst migration found themselves unable to start up, or call\r\nlistpayments, as the internal invoice within the OutgoignPayment hadn't\r\nyet been updated.  This would result in an OOM typically as we went to\r\nallocate a slice with a integer that should have been small, but may\r\nhave ended up actually being a set of random bytes, so a very large\r\nnumber.\r\n\r\nIn this commit, we finish the DB migration by also migrating the\r\ninternal invoice within each OutgoingPayment.\r\n\r\nFixes #1538.\r\nFixes #1546.","created_at":"2018-07-12T03:39:40Z","updated_at":"2018-07-12T07:14:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3cd21de0c223dc52287654314fed72290e1334a5","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":990012975,"node_id":"MDU6TGFiZWw5OTAwMTI5NzU=","url":"https://api.github.com/repos/lightningnetwork/lnd/labels/P1","name":"P1","color":"d93f0b","default":false},{"id":991321920,"node_id":"MDU6TGFiZWw5OTEzMjE5MjA=","url":"https://api.github.com/repos/lightningnetwork/lnd/labels/bug%20fix","name":"bug fix","color":"382d9b","default":false},{"id":465860350,"node_id":"MDU6TGFiZWw0NjU4NjAzNTA=","url":"https://api.github.com/repos/lightningnetwork/lnd/labels/database","name":"database","color":"bfd4f2","default":false},{"id":778128862,"node_id":"MDU6TGFiZWw3NzgxMjg4NjI=","url":"https://api.github.com/repos/lightningnetwork/lnd/labels/payments","name":"payments","color":"f754c6","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1547/commits","review_comments_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1547/comments","review_comment_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lightningnetwork/lnd/issues/1547/comments","statuses_url":"https://api.github.com/repos/lightningnetwork/lnd/statuses/6e0b05a20d3a57ecb93bf4c30d0929d2976f7edf","head":{"label":"Roasbeef:outgoing-payment-migration-invoice-series","ref":"outgoing-payment-migration-invoice-series","sha":"6e0b05a20d3a57ecb93bf4c30d0929d2976f7edf","user":{"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},"repo":{"id":112244823,"node_id":"MDEwOlJlcG9zaXRvcnkxMTIyNDQ4MjM=","name":"lnd","full_name":"Roasbeef/lnd","owner":{"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},"private":false,"html_url":"https://github.com/Roasbeef/lnd","description":"Lightning Network Daemon ⚡️","fork":true,"url":"https://api.github.com/repos/Roasbeef/lnd","forks_url":"https://api.github.com/repos/Roasbeef/lnd/forks","keys_url":"https://api.github.com/repos/Roasbeef/lnd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Roasbeef/lnd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Roasbeef/lnd/teams","hooks_url":"https://api.github.com/repos/Roasbeef/lnd/hooks","issue_events_url":"https://api.github.com/repos/Roasbeef/lnd/issues/events{/number}","events_url":"https://api.github.com/repos/Roasbeef/lnd/events","assignees_url":"https://api.github.com/repos/Roasbeef/lnd/assignees{/user}","branches_url":"https://api.github.com/repos/Roasbeef/lnd/branches{/branch}","tags_url":"https://api.github.com/repos/Roasbeef/lnd/tags","blobs_url":"https://api.github.com/repos/Roasbeef/lnd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Roasbeef/lnd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Roasbeef/lnd/git/refs{/sha}","trees_url":"https://api.github.com/repos/Roasbeef/lnd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Roasbeef/lnd/statuses/{sha}","languages_url":"https://api.github.com/repos/Roasbeef/lnd/languages","stargazers_url":"https://api.github.com/repos/Roasbeef/lnd/stargazers","contributors_url":"https://api.github.com/repos/Roasbeef/lnd/contributors","subscribers_url":"https://api.github.com/repos/Roasbeef/lnd/subscribers","subscription_url":"https://api.github.com/repos/Roasbeef/lnd/subscription","commits_url":"https://api.github.com/repos/Roasbeef/lnd/commits{/sha}","git_commits_url":"https://api.github.com/repos/Roasbeef/lnd/git/commits{/sha}","comments_url":"https://api.github.com/repos/Roasbeef/lnd/comments{/number}","issue_comment_url":"https://api.github.com/repos/Roasbeef/lnd/issues/comments{/number}","contents_url":"https://api.github.com/repos/Roasbeef/lnd/contents/{+path}","compare_url":"https://api.github.com/repos/Roasbeef/lnd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Roasbeef/lnd/merges","archive_url":"https://api.github.com/repos/Roasbeef/lnd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Roasbeef/lnd/downloads","issues_url":"https://api.github.com/repos/Roasbeef/lnd/issues{/number}","pulls_url":"https://api.github.com/repos/Roasbeef/lnd/pulls{/number}","milestones_url":"https://api.github.com/repos/Roasbeef/lnd/milestones{/number}","notifications_url":"https://api.github.com/repos/Roasbeef/lnd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Roasbeef/lnd/labels{/name}","releases_url":"https://api.github.com/repos/Roasbeef/lnd/releases{/id}","deployments_url":"https://api.github.com/repos/Roasbeef/lnd/deployments","created_at":"2017-11-27T20:26:47Z","updated_at":"2017-11-27T20:26:49Z","pushed_at":"2018-07-12T06:52:23Z","git_url":"git://github.com/Roasbeef/lnd.git","ssh_url":"git@github.com:Roasbeef/lnd.git","clone_url":"https://github.com/Roasbeef/lnd.git","svn_url":"https://github.com/Roasbeef/lnd","homepage":"","size":17511,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"lightningnetwork:master","ref":"master","sha":"515ba7a4d0164ad9264287f6589821a2765c8528","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","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},"private":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":"2018-07-12T02:14:46Z","pushed_at":"2018-07-12T06:52:25Z","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":16750,"stargazers_count":2773,"watchers_count":2773,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":678,"mirror_url":null,"archived":false,"open_issues_count":199,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":678,"open_issues":199,"watchers":2773,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1547"},"html":{"href":"https://github.com/lightningnetwork/lnd/pull/1547"},"issue":{"href":"https://api.github.com/repos/lightningnetwork/lnd/issues/1547"},"comments":{"href":"https://api.github.com/repos/lightningnetwork/lnd/issues/1547/comments"},"review_comments":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1547/comments"},"review_comment":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1547/commits"},"statuses":{"href":"https://api.github.com/repos/lightningnetwork/lnd/statuses/6e0b05a20d3a57ecb93bf4c30d0929d2976f7edf"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"halseth"}}