{"action":"created","comment":{"url":"https://api.github.com/repos/ElementsProject/lightning/pulls/comments/170908313","pull_request_review_id":99666535,"id":170908313,"diff_hunk":"@@ -200,6 +200,10 @@ char *dbmigrations[] = {\n     \"DELETE FROM peers WHERE id NOT IN (SELECT peer_id FROM channels);\",\n     /* The ONCHAIND_CHEATED/THEIR_UNILATERAL/OUR_UNILATERAL/MUTUAL are now one */\n     \"UPDATE channels SET STATE = 8 WHERE state > 8;\",\n+    /* What do we think the head of the blockchain looks like? Used\n+     * primarily to track confirmations across restarts and making\n+     * sure we handle reorgs correctly. */\n+    \"CREATE TABLE blocks (height INT, hash BLOB, prev_hash BLOB, UNIQUE(height));\",","path":"wallet/db.c","position":7,"original_position":7,"commit_id":"76efeed90c27b2b1d88c941c13a278ebfd9e9558","original_commit_id":"6a969d24897acce0ed5c7d243017d5c5bad05563","user":{"login":"cdecker","id":120117,"avatar_url":"https://avatars2.githubusercontent.com/u/120117?v=4","gravatar_id":"","url":"https://api.github.com/users/cdecker","html_url":"https://github.com/cdecker","followers_url":"https://api.github.com/users/cdecker/followers","following_url":"https://api.github.com/users/cdecker/following{/other_user}","gists_url":"https://api.github.com/users/cdecker/gists{/gist_id}","starred_url":"https://api.github.com/users/cdecker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdecker/subscriptions","organizations_url":"https://api.github.com/users/cdecker/orgs","repos_url":"https://api.github.com/users/cdecker/repos","events_url":"https://api.github.com/users/cdecker/events{/privacy}","received_events_url":"https://api.github.com/users/cdecker/received_events","type":"User","site_admin":false},"body":"It does, yes, and it's also what I'm using to set `spend_height` and `confirmation_height` to `NULL` in case of a reorg.","created_at":"2018-02-27T12:39:31Z","updated_at":"2018-02-27T12:39:31Z","html_url":"https://github.com/ElementsProject/lightning/pull/1117#discussion_r170908313","pull_request_url":"https://api.github.com/repos/ElementsProject/lightning/pulls/1117","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/ElementsProject/lightning/pulls/comments/170908313"},"html":{"href":"https://github.com/ElementsProject/lightning/pull/1117#discussion_r170908313"},"pull_request":{"href":"https://api.github.com/repos/ElementsProject/lightning/pulls/1117"}},"in_reply_to_id":170903340},"pull_request":{"url":"https://api.github.com/repos/ElementsProject/lightning/pulls/1117","id":171641303,"html_url":"https://github.com/ElementsProject/lightning/pull/1117","diff_url":"https://github.com/ElementsProject/lightning/pull/1117.diff","patch_url":"https://github.com/ElementsProject/lightning/pull/1117.patch","issue_url":"https://api.github.com/repos/ElementsProject/lightning/issues/1117","number":1117,"state":"open","locked":false,"title":"WIP: Track output confirmations, spends and maintain an internal UTXO set","user":{"login":"cdecker","id":120117,"avatar_url":"https://avatars2.githubusercontent.com/u/120117?v=4","gravatar_id":"","url":"https://api.github.com/users/cdecker","html_url":"https://github.com/cdecker","followers_url":"https://api.github.com/users/cdecker/followers","following_url":"https://api.github.com/users/cdecker/following{/other_user}","gists_url":"https://api.github.com/users/cdecker/gists{/gist_id}","starred_url":"https://api.github.com/users/cdecker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdecker/subscriptions","organizations_url":"https://api.github.com/users/cdecker/orgs","repos_url":"https://api.github.com/users/cdecker/repos","events_url":"https://api.github.com/users/cdecker/events{/privacy}","received_events_url":"https://api.github.com/users/cdecker/received_events","type":"User","site_admin":false},"body":"This PR aims to provide better tracking of the blockchain and internalizing some of the information which is now being fetched on demand. A number of use-cases should be improved with it:\r\n\r\n - Owned funds now receive a confirmation height and a spend height in order to reduce the chances of running out of sync with the bitcoin UTXO\r\n - Adds an `outpointfilter` that can be used to filter outpoint spends that we are interested in, so that we can be notified when our owned outputs are being spent, or when a P2WSH UTXO has been spent\r\n - Tracks P2WSH UTXOs in the wallet to avoid calling out to `bitcoin-cli` for each channel we learn about. Should allow us to reduce the sync time and is needed if we want to persist gossip announcement across restarts.\r\n - Allows us not to rescan the entire blockchain from the first channel, instead starting to scan from the last known height - overlap.\r\n\r\nI'm currently planning to have the sync start at `last_sync_height - 432` which should cover the cases in which we have an active close and some HTLCs waiting to be redeemed as well, i.e., starting `onchaind` when seeing the funding spend, without additional state to be persisted.","created_at":"2018-02-27T11:57:29Z","updated_at":"2018-02-27T12:39:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4ff1554bdde66fdfb0ca730f6e6a9d869cf49579","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":669479200,"url":"https://api.github.com/repos/ElementsProject/lightning/labels/Work%20in%20Progress","name":"Work in Progress","color":"5319e7","default":false},{"id":826097823,"url":"https://api.github.com/repos/ElementsProject/lightning/labels/bitcoind","name":"bitcoind","color":"ff5bbd","default":false},{"id":223861687,"url":"https://api.github.com/repos/ElementsProject/lightning/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":682240613,"url":"https://api.github.com/repos/ElementsProject/lightning/labels/gossip","name":"gossip","color":"d93f0b","default":false},{"id":766524483,"url":"https://api.github.com/repos/ElementsProject/lightning/labels/masterd","name":"masterd","color":"0970a3","default":false},{"id":682240597,"url":"https://api.github.com/repos/ElementsProject/lightning/labels/wallet","name":"wallet","color":"b60205","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/ElementsProject/lightning/pulls/1117/commits","review_comments_url":"https://api.github.com/repos/ElementsProject/lightning/pulls/1117/comments","review_comment_url":"https://api.github.com/repos/ElementsProject/lightning/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ElementsProject/lightning/issues/1117/comments","statuses_url":"https://api.github.com/repos/ElementsProject/lightning/statuses/76efeed90c27b2b1d88c941c13a278ebfd9e9558","head":{"label":"cdecker:trackblocks","ref":"trackblocks","sha":"76efeed90c27b2b1d88c941c13a278ebfd9e9558","user":{"login":"cdecker","id":120117,"avatar_url":"https://avatars2.githubusercontent.com/u/120117?v=4","gravatar_id":"","url":"https://api.github.com/users/cdecker","html_url":"https://github.com/cdecker","followers_url":"https://api.github.com/users/cdecker/followers","following_url":"https://api.github.com/users/cdecker/following{/other_user}","gists_url":"https://api.github.com/users/cdecker/gists{/gist_id}","starred_url":"https://api.github.com/users/cdecker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdecker/subscriptions","organizations_url":"https://api.github.com/users/cdecker/orgs","repos_url":"https://api.github.com/users/cdecker/repos","events_url":"https://api.github.com/users/cdecker/events{/privacy}","received_events_url":"https://api.github.com/users/cdecker/received_events","type":"User","site_admin":false},"repo":{"id":62466348,"name":"lightning","full_name":"cdecker/lightning","owner":{"login":"cdecker","id":120117,"avatar_url":"https://avatars2.githubusercontent.com/u/120117?v=4","gravatar_id":"","url":"https://api.github.com/users/cdecker","html_url":"https://github.com/cdecker","followers_url":"https://api.github.com/users/cdecker/followers","following_url":"https://api.github.com/users/cdecker/following{/other_user}","gists_url":"https://api.github.com/users/cdecker/gists{/gist_id}","starred_url":"https://api.github.com/users/cdecker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdecker/subscriptions","organizations_url":"https://api.github.com/users/cdecker/orgs","repos_url":"https://api.github.com/users/cdecker/repos","events_url":"https://api.github.com/users/cdecker/events{/privacy}","received_events_url":"https://api.github.com/users/cdecker/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cdecker/lightning","description":"Lightning network","fork":true,"url":"https://api.github.com/repos/cdecker/lightning","forks_url":"https://api.github.com/repos/cdecker/lightning/forks","keys_url":"https://api.github.com/repos/cdecker/lightning/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cdecker/lightning/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cdecker/lightning/teams","hooks_url":"https://api.github.com/repos/cdecker/lightning/hooks","issue_events_url":"https://api.github.com/repos/cdecker/lightning/issues/events{/number}","events_url":"https://api.github.com/repos/cdecker/lightning/events","assignees_url":"https://api.github.com/repos/cdecker/lightning/assignees{/user}","branches_url":"https://api.github.com/repos/cdecker/lightning/branches{/branch}","tags_url":"https://api.github.com/repos/cdecker/lightning/tags","blobs_url":"https://api.github.com/repos/cdecker/lightning/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cdecker/lightning/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cdecker/lightning/git/refs{/sha}","trees_url":"https://api.github.com/repos/cdecker/lightning/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cdecker/lightning/statuses/{sha}","languages_url":"https://api.github.com/repos/cdecker/lightning/languages","stargazers_url":"https://api.github.com/repos/cdecker/lightning/stargazers","contributors_url":"https://api.github.com/repos/cdecker/lightning/contributors","subscribers_url":"https://api.github.com/repos/cdecker/lightning/subscribers","subscription_url":"https://api.github.com/repos/cdecker/lightning/subscription","commits_url":"https://api.github.com/repos/cdecker/lightning/commits{/sha}","git_commits_url":"https://api.github.com/repos/cdecker/lightning/git/commits{/sha}","comments_url":"https://api.github.com/repos/cdecker/lightning/comments{/number}","issue_comment_url":"https://api.github.com/repos/cdecker/lightning/issues/comments{/number}","contents_url":"https://api.github.com/repos/cdecker/lightning/contents/{+path}","compare_url":"https://api.github.com/repos/cdecker/lightning/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cdecker/lightning/merges","archive_url":"https://api.github.com/repos/cdecker/lightning/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cdecker/lightning/downloads","issues_url":"https://api.github.com/repos/cdecker/lightning/issues{/number}","pulls_url":"https://api.github.com/repos/cdecker/lightning/pulls{/number}","milestones_url":"https://api.github.com/repos/cdecker/lightning/milestones{/number}","notifications_url":"https://api.github.com/repos/cdecker/lightning/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cdecker/lightning/labels{/name}","releases_url":"https://api.github.com/repos/cdecker/lightning/releases{/id}","deployments_url":"https://api.github.com/repos/cdecker/lightning/deployments","created_at":"2016-07-02T19:17:14Z","updated_at":"2017-12-07T17:14:38Z","pushed_at":"2018-02-27T11:43:13Z","git_url":"git://github.com/cdecker/lightning.git","ssh_url":"git@github.com:cdecker/lightning.git","clone_url":"https://github.com/cdecker/lightning.git","svn_url":"https://github.com/cdecker/lightning","homepage":null,"size":13435,"stargazers_count":4,"watchers_count":4,"language":"C","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":1,"open_issues":0,"watchers":4,"default_branch":"master"}},"base":{"label":"ElementsProject:master","ref":"master","sha":"b7ed5670d59dec49622d1fb7fd404ba3d2caac0a","user":{"login":"ElementsProject","id":12729539,"avatar_url":"https://avatars2.githubusercontent.com/u/12729539?v=4","gravatar_id":"","url":"https://api.github.com/users/ElementsProject","html_url":"https://github.com/ElementsProject","followers_url":"https://api.github.com/users/ElementsProject/followers","following_url":"https://api.github.com/users/ElementsProject/following{/other_user}","gists_url":"https://api.github.com/users/ElementsProject/gists{/gist_id}","starred_url":"https://api.github.com/users/ElementsProject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElementsProject/subscriptions","organizations_url":"https://api.github.com/users/ElementsProject/orgs","repos_url":"https://api.github.com/users/ElementsProject/repos","events_url":"https://api.github.com/users/ElementsProject/events{/privacy}","received_events_url":"https://api.github.com/users/ElementsProject/received_events","type":"Organization","site_admin":false},"repo":{"id":37350472,"name":"lightning","full_name":"ElementsProject/lightning","owner":{"login":"ElementsProject","id":12729539,"avatar_url":"https://avatars2.githubusercontent.com/u/12729539?v=4","gravatar_id":"","url":"https://api.github.com/users/ElementsProject","html_url":"https://github.com/ElementsProject","followers_url":"https://api.github.com/users/ElementsProject/followers","following_url":"https://api.github.com/users/ElementsProject/following{/other_user}","gists_url":"https://api.github.com/users/ElementsProject/gists{/gist_id}","starred_url":"https://api.github.com/users/ElementsProject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElementsProject/subscriptions","organizations_url":"https://api.github.com/users/ElementsProject/orgs","repos_url":"https://api.github.com/users/ElementsProject/repos","events_url":"https://api.github.com/users/ElementsProject/events{/privacy}","received_events_url":"https://api.github.com/users/ElementsProject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ElementsProject/lightning","description":"c-lightning — a Lightning Network implementation in C","fork":false,"url":"https://api.github.com/repos/ElementsProject/lightning","forks_url":"https://api.github.com/repos/ElementsProject/lightning/forks","keys_url":"https://api.github.com/repos/ElementsProject/lightning/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ElementsProject/lightning/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ElementsProject/lightning/teams","hooks_url":"https://api.github.com/repos/ElementsProject/lightning/hooks","issue_events_url":"https://api.github.com/repos/ElementsProject/lightning/issues/events{/number}","events_url":"https://api.github.com/repos/ElementsProject/lightning/events","assignees_url":"https://api.github.com/repos/ElementsProject/lightning/assignees{/user}","branches_url":"https://api.github.com/repos/ElementsProject/lightning/branches{/branch}","tags_url":"https://api.github.com/repos/ElementsProject/lightning/tags","blobs_url":"https://api.github.com/repos/ElementsProject/lightning/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ElementsProject/lightning/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ElementsProject/lightning/git/refs{/sha}","trees_url":"https://api.github.com/repos/ElementsProject/lightning/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ElementsProject/lightning/statuses/{sha}","languages_url":"https://api.github.com/repos/ElementsProject/lightning/languages","stargazers_url":"https://api.github.com/repos/ElementsProject/lightning/stargazers","contributors_url":"https://api.github.com/repos/ElementsProject/lightning/contributors","subscribers_url":"https://api.github.com/repos/ElementsProject/lightning/subscribers","subscription_url":"https://api.github.com/repos/ElementsProject/lightning/subscription","commits_url":"https://api.github.com/repos/ElementsProject/lightning/commits{/sha}","git_commits_url":"https://api.github.com/repos/ElementsProject/lightning/git/commits{/sha}","comments_url":"https://api.github.com/repos/ElementsProject/lightning/comments{/number}","issue_comment_url":"https://api.github.com/repos/ElementsProject/lightning/issues/comments{/number}","contents_url":"https://api.github.com/repos/ElementsProject/lightning/contents/{+path}","compare_url":"https://api.github.com/repos/ElementsProject/lightning/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ElementsProject/lightning/merges","archive_url":"https://api.github.com/repos/ElementsProject/lightning/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ElementsProject/lightning/downloads","issues_url":"https://api.github.com/repos/ElementsProject/lightning/issues{/number}","pulls_url":"https://api.github.com/repos/ElementsProject/lightning/pulls{/number}","milestones_url":"https://api.github.com/repos/ElementsProject/lightning/milestones{/number}","notifications_url":"https://api.github.com/repos/ElementsProject/lightning/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ElementsProject/lightning/labels{/name}","releases_url":"https://api.github.com/repos/ElementsProject/lightning/releases{/id}","deployments_url":"https://api.github.com/repos/ElementsProject/lightning/deployments","created_at":"2015-06-13T00:04:22Z","updated_at":"2018-02-27T11:28:14Z","pushed_at":"2018-02-27T12:38:33Z","git_url":"git://github.com/ElementsProject/lightning.git","ssh_url":"git@github.com:ElementsProject/lightning.git","clone_url":"https://github.com/ElementsProject/lightning.git","svn_url":"https://github.com/ElementsProject/lightning","homepage":"","size":13148,"stargazers_count":783,"watchers_count":783,"language":"C","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":205,"mirror_url":null,"archived":false,"open_issues_count":115,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":205,"open_issues":115,"watchers":783,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ElementsProject/lightning/pulls/1117"},"html":{"href":"https://github.com/ElementsProject/lightning/pull/1117"},"issue":{"href":"https://api.github.com/repos/ElementsProject/lightning/issues/1117"},"comments":{"href":"https://api.github.com/repos/ElementsProject/lightning/issues/1117/comments"},"review_comments":{"href":"https://api.github.com/repos/ElementsProject/lightning/pulls/1117/comments"},"review_comment":{"href":"https://api.github.com/repos/ElementsProject/lightning/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ElementsProject/lightning/pulls/1117/commits"},"statuses":{"href":"https://api.github.com/repos/ElementsProject/lightning/statuses/76efeed90c27b2b1d88c941c13a278ebfd9e9558"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"cdecker"}}