{"action":"created","comment":{"url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments/228066709","pull_request_review_id":168247576,"id":228066709,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyODA2NjcwOQ==","diff_hunk":"@@ -1,24 +1,59 @@\n package sweep\n \n import (\n+\t\"errors\"\n+\t\"fmt\"\n \t\"github.com/btcsuite/btcd/blockchain\"\n+\t\"github.com/btcsuite/btcd/chaincfg/chainhash\"\n \t\"github.com/btcsuite/btcd/txscript\"\n \t\"github.com/btcsuite/btcd/wire\"\n \t\"github.com/btcsuite/btcutil\"\n+\t\"github.com/lightningnetwork/lnd/chainntnfs\"\n \t\"github.com/lightningnetwork/lnd/lnwallet\"\n+\t\"github.com/lightningnetwork/lnd/ticker\"\n+\t\"sync\"\n+\t\"sync/atomic\"\n+\t\"time\"\n )\n \n-// UtxoSweeper provides the functionality to generate sweep txes. The plan is\n-// to extend UtxoSweeper in the future to also manage the actual sweeping\n-// process by itself.\n+var (\n+\t// DefaultSweepCheckInterval specifies the time intervals between checks\n+\t// for inputs to sweep.\n+\tDefaultSweepCheckInterval = time.Second\n+\n+\t// DefaultBatchWindowSize specifies the number of sweep check intervals\n+\t// to pass without new inputs being added before the sweep is published.\n+\tDefaultBatchWindowSize = 30\n+\n+\t// ErrRemoteSpend is returned in case an output that we try to sweep is\n+\t// confirmed in a tx of the remote party.\n+\tErrRemoteSpend = errors.New(\"remote party swept utxo\")\n+\n+\t// sweeperTimeout is the maximum time a user of the sweeper is allowed\n+\t// to wait before reading the sweep result. This is limited to prevent\n+\t// blocking of the sweeper.\n+\tsweeperTimeout = 5 * time.Second\n+)\n+\n+// UtxoSweeper is responsible for sweeping outputs back into the wallet\n type UtxoSweeper struct {\n-\tcfg *UtxoSweeperConfig\n+\tcfg  *UtxoSweeperConfig\n+\tquit chan struct{}\n+\n+\twg      sync.WaitGroup\n+\tstopped uint32\n+\tstarted uint32\n+\n+\tnewInputs chan *sweeperInput\n+\tspendChan chan *chainntnfs.SpendDetail\n+\n+\tpendingInputs map[wire.OutPoint]*pendingInput","path":"sweep/sweeper.go","position":54,"original_position":54,"commit_id":"9ac4c0a7ce09b4023b1f11eb2af8f47a86d43b7a","original_commit_id":"6473a6e04fac3ec2a12a5f34923f8d7f41973e30","user":{"login":"joostjager","id":4638168,"node_id":"MDQ6VXNlcjQ2MzgxNjg=","avatar_url":"https://avatars2.githubusercontent.com/u/4638168?v=4","gravatar_id":"","url":"https://api.github.com/users/joostjager","html_url":"https://github.com/joostjager","followers_url":"https://api.github.com/users/joostjager/followers","following_url":"https://api.github.com/users/joostjager/following{/other_user}","gists_url":"https://api.github.com/users/joostjager/gists{/gist_id}","starred_url":"https://api.github.com/users/joostjager/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joostjager/subscriptions","organizations_url":"https://api.github.com/users/joostjager/orgs","repos_url":"https://api.github.com/users/joostjager/repos","events_url":"https://api.github.com/users/joostjager/events{/privacy}","received_events_url":"https://api.github.com/users/joostjager/received_events","type":"User","site_admin":false},"body":"My reasoning was to put the exposed types first. Is what you suggest the project convention?","created_at":"2018-10-25T07:51:20Z","updated_at":"2018-10-25T07:51:20Z","html_url":"https://github.com/lightningnetwork/lnd/pull/1960#discussion_r228066709","pull_request_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1960","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments/228066709"},"html":{"href":"https://github.com/lightningnetwork/lnd/pull/1960#discussion_r228066709"},"pull_request":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1960"}},"in_reply_to_id":228030836},"pull_request":{"url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1960","id":217363123,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE3MzYzMTIz","html_url":"https://github.com/lightningnetwork/lnd/pull/1960","diff_url":"https://github.com/lightningnetwork/lnd/pull/1960.diff","patch_url":"https://github.com/lightningnetwork/lnd/pull/1960.patch","issue_url":"https://api.github.com/repos/lightningnetwork/lnd/issues/1960","number":1960,"state":"open","locked":false,"title":"sweep: create sweeper","user":{"login":"joostjager","id":4638168,"node_id":"MDQ6VXNlcjQ2MzgxNjg=","avatar_url":"https://avatars2.githubusercontent.com/u/4638168?v=4","gravatar_id":"","url":"https://api.github.com/users/joostjager","html_url":"https://github.com/joostjager","followers_url":"https://api.github.com/users/joostjager/followers","following_url":"https://api.github.com/users/joostjager/following{/other_user}","gists_url":"https://api.github.com/users/joostjager/gists{/gist_id}","starred_url":"https://api.github.com/users/joostjager/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joostjager/subscriptions","organizations_url":"https://api.github.com/users/joostjager/orgs","repos_url":"https://api.github.com/users/joostjager/repos","events_url":"https://api.github.com/users/joostjager/events{/privacy}","received_events_url":"https://api.github.com/users/joostjager/received_events","type":"User","site_admin":false},"body":"This PR moves the sweeper logic from `utxonursery` into a separate sweeper struct.\r\n\r\nIt requires https://github.com/btcsuite/btcwallet/pull/561.\r\n\r\nA follow up PR is #2000, which will let resolvers use the sweeper directly instead of going through nursery. The end goal is to remove nursery completely.","created_at":"2018-09-21T18:19:23Z","updated_at":"2018-10-25T07:51:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"61795755e39ef10dd578cbeba1bf120b7a5a106c","assignee":null,"assignees":[],"requested_reviewers":[{"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}],"requested_teams":[],"labels":[{"id":990013523,"node_id":"MDU6TGFiZWw5OTAwMTM1MjM=","url":"https://api.github.com/repos/lightningnetwork/lnd/labels/P3","name":"P3","color":"0e8a16","default":false},{"id":778122277,"node_id":"MDU6TGFiZWw3NzgxMjIyNzc=","url":"https://api.github.com/repos/lightningnetwork/lnd/labels/channel%20management","name":"channel management","color":"5fa7bf","default":false},{"id":923266457,"node_id":"MDU6TGFiZWw5MjMyNjY0NTc=","url":"https://api.github.com/repos/lightningnetwork/lnd/labels/contracts","name":"contracts","color":"e09523","default":false},{"id":312148187,"node_id":"MDU6TGFiZWwzMTIxNDgxODc=","url":"https://api.github.com/repos/lightningnetwork/lnd/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":990053448,"node_id":"MDU6TGFiZWw5OTAwNTM0NDg=","url":"https://api.github.com/repos/lightningnetwork/lnd/labels/utxo%20sweeping","name":"utxo sweeping","color":"5df4e0","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1960/commits","review_comments_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1960/comments","review_comment_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lightningnetwork/lnd/issues/1960/comments","statuses_url":"https://api.github.com/repos/lightningnetwork/lnd/statuses/9ac4c0a7ce09b4023b1f11eb2af8f47a86d43b7a","head":{"label":"joostjager:sweeper","ref":"sweeper","sha":"9ac4c0a7ce09b4023b1f11eb2af8f47a86d43b7a","user":{"login":"joostjager","id":4638168,"node_id":"MDQ6VXNlcjQ2MzgxNjg=","avatar_url":"https://avatars2.githubusercontent.com/u/4638168?v=4","gravatar_id":"","url":"https://api.github.com/users/joostjager","html_url":"https://github.com/joostjager","followers_url":"https://api.github.com/users/joostjager/followers","following_url":"https://api.github.com/users/joostjager/following{/other_user}","gists_url":"https://api.github.com/users/joostjager/gists{/gist_id}","starred_url":"https://api.github.com/users/joostjager/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joostjager/subscriptions","organizations_url":"https://api.github.com/users/joostjager/orgs","repos_url":"https://api.github.com/users/joostjager/repos","events_url":"https://api.github.com/users/joostjager/events{/privacy}","received_events_url":"https://api.github.com/users/joostjager/received_events","type":"User","site_admin":false},"repo":{"id":133927509,"node_id":"MDEwOlJlcG9zaXRvcnkxMzM5Mjc1MDk=","name":"lnd","full_name":"joostjager/lnd","private":false,"owner":{"login":"joostjager","id":4638168,"node_id":"MDQ6VXNlcjQ2MzgxNjg=","avatar_url":"https://avatars2.githubusercontent.com/u/4638168?v=4","gravatar_id":"","url":"https://api.github.com/users/joostjager","html_url":"https://github.com/joostjager","followers_url":"https://api.github.com/users/joostjager/followers","following_url":"https://api.github.com/users/joostjager/following{/other_user}","gists_url":"https://api.github.com/users/joostjager/gists{/gist_id}","starred_url":"https://api.github.com/users/joostjager/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joostjager/subscriptions","organizations_url":"https://api.github.com/users/joostjager/orgs","repos_url":"https://api.github.com/users/joostjager/repos","events_url":"https://api.github.com/users/joostjager/events{/privacy}","received_events_url":"https://api.github.com/users/joostjager/received_events","type":"User","site_admin":false},"html_url":"https://github.com/joostjager/lnd","description":"Lightning Network Daemon ⚡️","fork":true,"url":"https://api.github.com/repos/joostjager/lnd","forks_url":"https://api.github.com/repos/joostjager/lnd/forks","keys_url":"https://api.github.com/repos/joostjager/lnd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/joostjager/lnd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/joostjager/lnd/teams","hooks_url":"https://api.github.com/repos/joostjager/lnd/hooks","issue_events_url":"https://api.github.com/repos/joostjager/lnd/issues/events{/number}","events_url":"https://api.github.com/repos/joostjager/lnd/events","assignees_url":"https://api.github.com/repos/joostjager/lnd/assignees{/user}","branches_url":"https://api.github.com/repos/joostjager/lnd/branches{/branch}","tags_url":"https://api.github.com/repos/joostjager/lnd/tags","blobs_url":"https://api.github.com/repos/joostjager/lnd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/joostjager/lnd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/joostjager/lnd/git/refs{/sha}","trees_url":"https://api.github.com/repos/joostjager/lnd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/joostjager/lnd/statuses/{sha}","languages_url":"https://api.github.com/repos/joostjager/lnd/languages","stargazers_url":"https://api.github.com/repos/joostjager/lnd/stargazers","contributors_url":"https://api.github.com/repos/joostjager/lnd/contributors","subscribers_url":"https://api.github.com/repos/joostjager/lnd/subscribers","subscription_url":"https://api.github.com/repos/joostjager/lnd/subscription","commits_url":"https://api.github.com/repos/joostjager/lnd/commits{/sha}","git_commits_url":"https://api.github.com/repos/joostjager/lnd/git/commits{/sha}","comments_url":"https://api.github.com/repos/joostjager/lnd/comments{/number}","issue_comment_url":"https://api.github.com/repos/joostjager/lnd/issues/comments{/number}","contents_url":"https://api.github.com/repos/joostjager/lnd/contents/{+path}","compare_url":"https://api.github.com/repos/joostjager/lnd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/joostjager/lnd/merges","archive_url":"https://api.github.com/repos/joostjager/lnd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/joostjager/lnd/downloads","issues_url":"https://api.github.com/repos/joostjager/lnd/issues{/number}","pulls_url":"https://api.github.com/repos/joostjager/lnd/pulls{/number}","milestones_url":"https://api.github.com/repos/joostjager/lnd/milestones{/number}","notifications_url":"https://api.github.com/repos/joostjager/lnd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/joostjager/lnd/labels{/name}","releases_url":"https://api.github.com/repos/joostjager/lnd/releases{/id}","deployments_url":"https://api.github.com/repos/joostjager/lnd/deployments","created_at":"2018-05-18T08:40:36Z","updated_at":"2018-10-08T12:26:51Z","pushed_at":"2018-10-25T07:39:34Z","git_url":"git://github.com/joostjager/lnd.git","ssh_url":"git@github.com:joostjager/lnd.git","clone_url":"https://github.com/joostjager/lnd.git","svn_url":"https://github.com/joostjager/lnd","homepage":"","size":32763,"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":2,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"lightningnetwork:master","ref":"master","sha":"5c6c9668916461536e15b5be11e06adee0cfa89d","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":"2018-10-25T04:43:35Z","pushed_at":"2018-10-25T07:39:34Z","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":21197,"stargazers_count":3153,"watchers_count":3153,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":796,"mirror_url":null,"archived":false,"open_issues_count":293,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":796,"open_issues":293,"watchers":3153,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1960"},"html":{"href":"https://github.com/lightningnetwork/lnd/pull/1960"},"issue":{"href":"https://api.github.com/repos/lightningnetwork/lnd/issues/1960"},"comments":{"href":"https://api.github.com/repos/lightningnetwork/lnd/issues/1960/comments"},"review_comments":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1960/comments"},"review_comment":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1960/commits"},"statuses":{"href":"https://api.github.com/repos/lightningnetwork/lnd/statuses/9ac4c0a7ce09b4023b1f11eb2af8f47a86d43b7a"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"joostjager"}}