{"action":"created","comment":{"url":"https://api.github.com/repos/decred/dcrwallet/pulls/comments/84307652","pull_request_review_id":5093267,"id":84307652,"diff_hunk":"@@ -129,11 +131,70 @@ func (w *Wallet) TicketHashesForVotingAddress(votingAddr dcrutil.Address) ([]cha\n \treturn ticketHashes, err\n }\n \n+// updateStakePoolInvalidTicket properly updates a previously marked Invalid pool ticket,\n+// it then creates a new entry in the validly tracked pool ticket db.\n+func (w *Wallet) updateStakePoolInvalidTicket(stakemgrNs walletdb.ReadWriteBucket, addrmgrNs walletdb.ReadBucket,\n+\taddr dcrutil.Address, ticket *chainhash.Hash, ticketHeight int64) error {\n+\terr := w.StakeMgr.RemoveStakePoolUserInvalTickets(stakemgrNs, addr, ticket)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\tpoolTicket := &wstakemgr.PoolTicket{\n+\t\tTicket:       *ticket,\n+\t\tHeightTicket: uint32(ticketHeight),\n+\t\tStatus:       wstakemgr.TSImmatureOrLive,\n+\t}\n+\n+\terr = w.StakeMgr.UpdateStakePoolUserTickets(stakemgrNs, addrmgrNs, addr, poolTicket)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\n+\treturn nil\n+}\n+\n // AddTicket adds a ticket transaction to the wallet.\n func (w *Wallet) AddTicket(ticket *dcrutil.Tx) error {\n \treturn walletdb.Update(w.db, func(tx walletdb.ReadWriteTx) error {\n \t\tstakemgrNs := tx.ReadWriteBucket(wstakemgrNamespaceKey)\n-\t\treturn w.StakeMgr.InsertSStx(stakemgrNs, ticket, w.VoteBits)\n+\n+\t\t// Insert the ticket to be tracked and voted\n+\t\terr := w.StakeMgr.InsertSStx(stakemgrNs, ticket, w.VoteBits)\n+\t\tif err != nil {\n+\t\t\treturn err\n+\t\t}\n+\n+\t\tif w.stakePoolEnabled {\n+\t\t\taddrmgrNs := tx.ReadWriteBucket(waddrmgrNamespaceKey)\n+\n+\t\t\t// Pluck the ticketaddress to indentify the stakepool user\n+\t\t\tpkVersion := ticket.MsgTx().TxOut[0].Version\n+\t\t\tpkScript := ticket.MsgTx().TxOut[0].PkScript\n+\t\t\t_, addrs, _, err := txscript.ExtractPkScriptAddrs(pkVersion,\n+\t\t\t\tpkScript, w.ChainParams())\n+\t\t\tif err != nil {\n+\t\t\t\treturn err\n+\t\t\t}\n+\n+\t\t\tticketHash := ticket.MsgTx().TxSha()\n+\n+\t\t\tchainClient, err := w.requireChainClient()\n+\t\t\tif err != nil {\n+\t\t\t\treturn err\n+\t\t\t}\n+\t\t\trawTx, err := chainClient.GetRawTransactionVerbose(&ticketHash)\n+\t\t\tif err != nil {\n+\t\t\t\treturn err\n+\t\t\t}\n+\n+\t\t\t// Update the pool ticket stake. This will include removing it from the\n+\t\t\t// invalid slice and adding a ImmatureOrLive ticket to the valid ones","path":"wallet/tickets.go","position":75,"original_position":75,"commit_id":"b8d9980be6a9909f57a47af110117545b97c7017","original_commit_id":"b8d9980be6a9909f57a47af110117545b97c7017","user":{"login":"cjepson","id":10604806,"avatar_url":"https://avatars.githubusercontent.com/u/10604806?v=3","gravatar_id":"","url":"https://api.github.com/users/cjepson","html_url":"https://github.com/cjepson","followers_url":"https://api.github.com/users/cjepson/followers","following_url":"https://api.github.com/users/cjepson/following{/other_user}","gists_url":"https://api.github.com/users/cjepson/gists{/gist_id}","starred_url":"https://api.github.com/users/cjepson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjepson/subscriptions","organizations_url":"https://api.github.com/users/cjepson/orgs","repos_url":"https://api.github.com/users/cjepson/repos","events_url":"https://api.github.com/users/cjepson/events{/privacy}","received_events_url":"https://api.github.com/users/cjepson/received_events","type":"User","site_admin":false},"body":"period","created_at":"2016-10-20T15:22:02Z","updated_at":"2016-10-20T15:22:02Z","html_url":"https://github.com/decred/dcrwallet/pull/365#discussion_r84307652","pull_request_url":"https://api.github.com/repos/decred/dcrwallet/pulls/365","_links":{"self":{"href":"https://api.github.com/repos/decred/dcrwallet/pulls/comments/84307652"},"html":{"href":"https://github.com/decred/dcrwallet/pull/365#discussion_r84307652"},"pull_request":{"href":"https://api.github.com/repos/decred/dcrwallet/pulls/365"}}},"pull_request":{"url":"https://api.github.com/repos/decred/dcrwallet/pulls/365","id":89699997,"html_url":"https://github.com/decred/dcrwallet/pull/365","diff_url":"https://github.com/decred/dcrwallet/pull/365.diff","patch_url":"https://github.com/decred/dcrwallet/pull/365.patch","issue_url":"https://api.github.com/repos/decred/dcrwallet/issues/365","number":365,"state":"open","locked":false,"title":"Fully update PoolTickets when using AddTicket rpc","user":{"login":"alexlyp","id":4388501,"avatar_url":"https://avatars.githubusercontent.com/u/4388501?v=3","gravatar_id":"","url":"https://api.github.com/users/alexlyp","html_url":"https://github.com/alexlyp","followers_url":"https://api.github.com/users/alexlyp/followers","following_url":"https://api.github.com/users/alexlyp/following{/other_user}","gists_url":"https://api.github.com/users/alexlyp/gists{/gist_id}","starred_url":"https://api.github.com/users/alexlyp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexlyp/subscriptions","organizations_url":"https://api.github.com/users/alexlyp/orgs","repos_url":"https://api.github.com/users/alexlyp/repos","events_url":"https://api.github.com/users/alexlyp/events{/privacy}","received_events_url":"https://api.github.com/users/alexlyp/received_events","type":"User","site_admin":false},"body":"Prior to this there was no updating of PoolTicket state when manually using AddTicket for formerly invalid tickets.  Now they are properly removed from the invalid slice and a new PoolTicket is added to the valid slice.  This along with some more upgrades will help stakepool operators ensure that all of their wallets are in sync with one another.","created_at":"2016-10-17T20:48:27Z","updated_at":"2016-10-20T15:22:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"673c2934f11b1244d814ee017deedaee4ce1733c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/decred/dcrwallet/pulls/365/commits","review_comments_url":"https://api.github.com/repos/decred/dcrwallet/pulls/365/comments","review_comment_url":"https://api.github.com/repos/decred/dcrwallet/pulls/comments{/number}","comments_url":"https://api.github.com/repos/decred/dcrwallet/issues/365/comments","statuses_url":"https://api.github.com/repos/decred/dcrwallet/statuses/b8d9980be6a9909f57a47af110117545b97c7017","head":{"label":"alexlyp:ayp_stakepooltickets","ref":"ayp_stakepooltickets","sha":"b8d9980be6a9909f57a47af110117545b97c7017","user":{"login":"alexlyp","id":4388501,"avatar_url":"https://avatars.githubusercontent.com/u/4388501?v=3","gravatar_id":"","url":"https://api.github.com/users/alexlyp","html_url":"https://github.com/alexlyp","followers_url":"https://api.github.com/users/alexlyp/followers","following_url":"https://api.github.com/users/alexlyp/following{/other_user}","gists_url":"https://api.github.com/users/alexlyp/gists{/gist_id}","starred_url":"https://api.github.com/users/alexlyp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexlyp/subscriptions","organizations_url":"https://api.github.com/users/alexlyp/orgs","repos_url":"https://api.github.com/users/alexlyp/repos","events_url":"https://api.github.com/users/alexlyp/events{/privacy}","received_events_url":"https://api.github.com/users/alexlyp/received_events","type":"User","site_admin":false},"repo":{"id":37477881,"name":"btcwallet","full_name":"alexlyp/btcwallet","owner":{"login":"alexlyp","id":4388501,"avatar_url":"https://avatars.githubusercontent.com/u/4388501?v=3","gravatar_id":"","url":"https://api.github.com/users/alexlyp","html_url":"https://github.com/alexlyp","followers_url":"https://api.github.com/users/alexlyp/followers","following_url":"https://api.github.com/users/alexlyp/following{/other_user}","gists_url":"https://api.github.com/users/alexlyp/gists{/gist_id}","starred_url":"https://api.github.com/users/alexlyp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexlyp/subscriptions","organizations_url":"https://api.github.com/users/alexlyp/orgs","repos_url":"https://api.github.com/users/alexlyp/repos","events_url":"https://api.github.com/users/alexlyp/events{/privacy}","received_events_url":"https://api.github.com/users/alexlyp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alexlyp/btcwallet","description":"A secure bitcoin wallet daemon written in Go (golang)","fork":true,"url":"https://api.github.com/repos/alexlyp/btcwallet","forks_url":"https://api.github.com/repos/alexlyp/btcwallet/forks","keys_url":"https://api.github.com/repos/alexlyp/btcwallet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alexlyp/btcwallet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alexlyp/btcwallet/teams","hooks_url":"https://api.github.com/repos/alexlyp/btcwallet/hooks","issue_events_url":"https://api.github.com/repos/alexlyp/btcwallet/issues/events{/number}","events_url":"https://api.github.com/repos/alexlyp/btcwallet/events","assignees_url":"https://api.github.com/repos/alexlyp/btcwallet/assignees{/user}","branches_url":"https://api.github.com/repos/alexlyp/btcwallet/branches{/branch}","tags_url":"https://api.github.com/repos/alexlyp/btcwallet/tags","blobs_url":"https://api.github.com/repos/alexlyp/btcwallet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alexlyp/btcwallet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alexlyp/btcwallet/git/refs{/sha}","trees_url":"https://api.github.com/repos/alexlyp/btcwallet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alexlyp/btcwallet/statuses/{sha}","languages_url":"https://api.github.com/repos/alexlyp/btcwallet/languages","stargazers_url":"https://api.github.com/repos/alexlyp/btcwallet/stargazers","contributors_url":"https://api.github.com/repos/alexlyp/btcwallet/contributors","subscribers_url":"https://api.github.com/repos/alexlyp/btcwallet/subscribers","subscription_url":"https://api.github.com/repos/alexlyp/btcwallet/subscription","commits_url":"https://api.github.com/repos/alexlyp/btcwallet/commits{/sha}","git_commits_url":"https://api.github.com/repos/alexlyp/btcwallet/git/commits{/sha}","comments_url":"https://api.github.com/repos/alexlyp/btcwallet/comments{/number}","issue_comment_url":"https://api.github.com/repos/alexlyp/btcwallet/issues/comments{/number}","contents_url":"https://api.github.com/repos/alexlyp/btcwallet/contents/{+path}","compare_url":"https://api.github.com/repos/alexlyp/btcwallet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alexlyp/btcwallet/merges","archive_url":"https://api.github.com/repos/alexlyp/btcwallet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alexlyp/btcwallet/downloads","issues_url":"https://api.github.com/repos/alexlyp/btcwallet/issues{/number}","pulls_url":"https://api.github.com/repos/alexlyp/btcwallet/pulls{/number}","milestones_url":"https://api.github.com/repos/alexlyp/btcwallet/milestones{/number}","notifications_url":"https://api.github.com/repos/alexlyp/btcwallet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alexlyp/btcwallet/labels{/name}","releases_url":"https://api.github.com/repos/alexlyp/btcwallet/releases{/id}","deployments_url":"https://api.github.com/repos/alexlyp/btcwallet/deployments","created_at":"2015-06-15T16:44:13Z","updated_at":"2015-06-15T16:44:14Z","pushed_at":"2016-10-20T15:15:22Z","git_url":"git://github.com/alexlyp/btcwallet.git","ssh_url":"git@github.com:alexlyp/btcwallet.git","clone_url":"https://github.com/alexlyp/btcwallet.git","svn_url":"https://github.com/alexlyp/btcwallet","homepage":"","size":4749,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"decred:master","ref":"master","sha":"95cd3b826c69e0fece5c4541486146b48d5e794d","user":{"login":"decred","id":16297194,"avatar_url":"https://avatars.githubusercontent.com/u/16297194?v=3","gravatar_id":"","url":"https://api.github.com/users/decred","html_url":"https://github.com/decred","followers_url":"https://api.github.com/users/decred/followers","following_url":"https://api.github.com/users/decred/following{/other_user}","gists_url":"https://api.github.com/users/decred/gists{/gist_id}","starred_url":"https://api.github.com/users/decred/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/decred/subscriptions","organizations_url":"https://api.github.com/users/decred/orgs","repos_url":"https://api.github.com/users/decred/repos","events_url":"https://api.github.com/users/decred/events{/privacy}","received_events_url":"https://api.github.com/users/decred/received_events","type":"Organization","site_admin":false},"repo":{"id":50457727,"name":"dcrwallet","full_name":"decred/dcrwallet","owner":{"login":"decred","id":16297194,"avatar_url":"https://avatars.githubusercontent.com/u/16297194?v=3","gravatar_id":"","url":"https://api.github.com/users/decred","html_url":"https://github.com/decred","followers_url":"https://api.github.com/users/decred/followers","following_url":"https://api.github.com/users/decred/following{/other_user}","gists_url":"https://api.github.com/users/decred/gists{/gist_id}","starred_url":"https://api.github.com/users/decred/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/decred/subscriptions","organizations_url":"https://api.github.com/users/decred/orgs","repos_url":"https://api.github.com/users/decred/repos","events_url":"https://api.github.com/users/decred/events{/privacy}","received_events_url":"https://api.github.com/users/decred/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/decred/dcrwallet","description":"A secure decred wallet daemon written in Go (golang)","fork":true,"url":"https://api.github.com/repos/decred/dcrwallet","forks_url":"https://api.github.com/repos/decred/dcrwallet/forks","keys_url":"https://api.github.com/repos/decred/dcrwallet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/decred/dcrwallet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/decred/dcrwallet/teams","hooks_url":"https://api.github.com/repos/decred/dcrwallet/hooks","issue_events_url":"https://api.github.com/repos/decred/dcrwallet/issues/events{/number}","events_url":"https://api.github.com/repos/decred/dcrwallet/events","assignees_url":"https://api.github.com/repos/decred/dcrwallet/assignees{/user}","branches_url":"https://api.github.com/repos/decred/dcrwallet/branches{/branch}","tags_url":"https://api.github.com/repos/decred/dcrwallet/tags","blobs_url":"https://api.github.com/repos/decred/dcrwallet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/decred/dcrwallet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/decred/dcrwallet/git/refs{/sha}","trees_url":"https://api.github.com/repos/decred/dcrwallet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/decred/dcrwallet/statuses/{sha}","languages_url":"https://api.github.com/repos/decred/dcrwallet/languages","stargazers_url":"https://api.github.com/repos/decred/dcrwallet/stargazers","contributors_url":"https://api.github.com/repos/decred/dcrwallet/contributors","subscribers_url":"https://api.github.com/repos/decred/dcrwallet/subscribers","subscription_url":"https://api.github.com/repos/decred/dcrwallet/subscription","commits_url":"https://api.github.com/repos/decred/dcrwallet/commits{/sha}","git_commits_url":"https://api.github.com/repos/decred/dcrwallet/git/commits{/sha}","comments_url":"https://api.github.com/repos/decred/dcrwallet/comments{/number}","issue_comment_url":"https://api.github.com/repos/decred/dcrwallet/issues/comments{/number}","contents_url":"https://api.github.com/repos/decred/dcrwallet/contents/{+path}","compare_url":"https://api.github.com/repos/decred/dcrwallet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/decred/dcrwallet/merges","archive_url":"https://api.github.com/repos/decred/dcrwallet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/decred/dcrwallet/downloads","issues_url":"https://api.github.com/repos/decred/dcrwallet/issues{/number}","pulls_url":"https://api.github.com/repos/decred/dcrwallet/pulls{/number}","milestones_url":"https://api.github.com/repos/decred/dcrwallet/milestones{/number}","notifications_url":"https://api.github.com/repos/decred/dcrwallet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/decred/dcrwallet/labels{/name}","releases_url":"https://api.github.com/repos/decred/dcrwallet/releases{/id}","deployments_url":"https://api.github.com/repos/decred/dcrwallet/deployments","created_at":"2016-01-26T20:40:34Z","updated_at":"2016-09-15T18:29:13Z","pushed_at":"2016-10-20T15:15:23Z","git_url":"git://github.com/decred/dcrwallet.git","ssh_url":"git@github.com:decred/dcrwallet.git","clone_url":"https://github.com/decred/dcrwallet.git","svn_url":"https://github.com/decred/dcrwallet","homepage":"https://decred.org","size":5181,"stargazers_count":26,"watchers_count":26,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"open_issues_count":50,"forks":13,"open_issues":50,"watchers":26,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/decred/dcrwallet/pulls/365"},"html":{"href":"https://github.com/decred/dcrwallet/pull/365"},"issue":{"href":"https://api.github.com/repos/decred/dcrwallet/issues/365"},"comments":{"href":"https://api.github.com/repos/decred/dcrwallet/issues/365/comments"},"review_comments":{"href":"https://api.github.com/repos/decred/dcrwallet/pulls/365/comments"},"review_comment":{"href":"https://api.github.com/repos/decred/dcrwallet/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/decred/dcrwallet/pulls/365/commits"},"statuses":{"href":"https://api.github.com/repos/decred/dcrwallet/statuses/b8d9980be6a9909f57a47af110117545b97c7017"}}}}
{"actor":{"display_login":"cjepson"}}