{"action":"created","comment":{"url":"https://api.github.com/repos/btcsuite/btcwallet/pulls/comments/27458450","id":27458450,"diff_hunk":"@@ -502,68 +569,138 @@ func (vp *Pool) DepositScript(seriesID, branch, index uint32) ([]byte, error) {\n \n \tpks := make([]*btcutil.AddressPubKey, len(pubKeys))\n \tfor i, key := range pubKeys {\n-\t\tchild, err := key.Child(index)\n+\t\tchild, err := key.Child(uint32(index))\n \t\t// TODO: implement getting the next index until we find a valid one,\n \t\t// in case there is a hdkeychain.ErrInvalidChild.\n \t\tif err != nil {\n \t\t\tstr := fmt.Sprintf(\"child #%d for this pubkey %d does not exist\", index, i)\n-\t\t\treturn nil, managerError(waddrmgr.ErrKeyChain, str, err)\n+\t\t\treturn nil, newError(ErrKeyChain, str, err)\n \t\t}\n \t\tpubkey, err := child.ECPubKey()\n \t\tif err != nil {\n \t\t\tstr := fmt.Sprintf(\"child #%d for this pubkey %d does not exist\", index, i)\n-\t\t\treturn nil, managerError(waddrmgr.ErrKeyChain, str, err)\n+\t\t\treturn nil, newError(ErrKeyChain, str, err)\n \t\t}\n \t\tpks[i], err = btcutil.NewAddressPubKey(pubkey.SerializeCompressed(),\n-\t\t\tvp.manager.ChainParams())\n+\t\t\tp.manager.ChainParams())\n \t\tif err != nil {\n \t\t\tstr := fmt.Sprintf(\n \t\t\t\t\"child #%d for this pubkey %d could not be converted to an address\",\n \t\t\t\tindex, i)\n-\t\t\treturn nil, managerError(waddrmgr.ErrKeyChain, str, err)\n+\t\t\treturn nil, newError(ErrKeyChain, str, err)\n \t\t}\n \t}\n \n \tscript, err := txscript.MultiSigScript(pks, int(series.reqSigs))\n \tif err != nil {\n \t\tstr := fmt.Sprintf(\"error while making multisig script hash, %d\", len(pks))\n-\t\treturn nil, managerError(waddrmgr.ErrScriptCreation, str, err)\n+\t\treturn nil, newError(ErrScriptCreation, str, err)\n \t}\n \n \treturn script, nil\n }\n \n+// ChangeAddress returns a new votingpool address for the given seriesID and\n+// index, on the 0th branch (which is reserved for change addresses). The series\n+// with the given ID must be active.\n+func (p *Pool) ChangeAddress(seriesID uint32, index Index) (*ChangeAddress, error) {\n+\tseries := p.Series(seriesID)\n+\tif series == nil {\n+\t\treturn nil, newError(\n+\t\t\tErrSeriesNotExists, fmt.Sprintf(\"series %d does not exist\", seriesID), nil)\n+\t}\n+\tif !series.active {\n+\t\tstr := fmt.Sprintf(\"ChangeAddress must be on active series; series #%d is not\", seriesID)\n+\t\treturn nil, newError(ErrSeriesNotActive, str, nil)\n+\t}\n+\n+\tscript, err := p.DepositScript(seriesID, Branch(0), index)\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\tpAddr, err := p.poolAddress(seriesID, Branch(0), index, script)\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\treturn &ChangeAddress{poolAddress: pAddr}, nil\n+}\n+\n+// WithdrawalAddress queries the address manager for the P2SH address\n+// of the redeem script generated with the given series/branch/index and uses\n+// that to populate the returned WithdrawalAddress. This is done because we\n+// should only withdraw from previously used addresses but also because when\n+// processing withdrawals we may iterate over a huge number of addresses and\n+// it'd be too expensive to re-generate the redeem script for all of them.\n+// This method must be called with the manager unlocked.\n+func (p *Pool) WithdrawalAddress(\n+\tseriesID uint32, branch Branch, index Index) (*WithdrawalAddress, error) {\n+\t// TODO: Ensure the given series is hot.","path":"votingpool/pool.go","position":604,"original_position":604,"commit_id":"516706a4b907c5c24809fb617238a1e670fa51dd","original_commit_id":"516706a4b907c5c24809fb617238a1e670fa51dd","user":{"login":"gsalgado","id":412274,"avatar_url":"https://avatars.githubusercontent.com/u/412274?v=3","gravatar_id":"","url":"https://api.github.com/users/gsalgado","html_url":"https://github.com/gsalgado","followers_url":"https://api.github.com/users/gsalgado/followers","following_url":"https://api.github.com/users/gsalgado/following{/other_user}","gists_url":"https://api.github.com/users/gsalgado/gists{/gist_id}","starred_url":"https://api.github.com/users/gsalgado/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gsalgado/subscriptions","organizations_url":"https://api.github.com/users/gsalgado/orgs","repos_url":"https://api.github.com/users/gsalgado/repos","events_url":"https://api.github.com/users/gsalgado/events{/privacy}","received_events_url":"https://api.github.com/users/gsalgado/received_events","type":"User","site_admin":false},"body":"It's missing infrastructure, yes","created_at":"2015-03-31T07:49:36Z","updated_at":"2015-03-31T07:49:36Z","html_url":"https://github.com/btcsuite/btcwallet/pull/178#discussion_r27458450","pull_request_url":"https://api.github.com/repos/btcsuite/btcwallet/pulls/178","_links":{"self":{"href":"https://api.github.com/repos/btcsuite/btcwallet/pulls/comments/27458450"},"html":{"href":"https://github.com/btcsuite/btcwallet/pull/178#discussion_r27458450"},"pull_request":{"href":"https://api.github.com/repos/btcsuite/btcwallet/pulls/178"}}},"pull_request":{"url":"https://api.github.com/repos/btcsuite/btcwallet/pulls/178","id":28357408,"html_url":"https://github.com/btcsuite/btcwallet/pull/178","diff_url":"https://github.com/btcsuite/btcwallet/pull/178.diff","patch_url":"https://github.com/btcsuite/btcwallet/pull/178.patch","issue_url":"https://api.github.com/repos/btcsuite/btcwallet/issues/178","number":178,"state":"open","locked":false,"title":"Implement votingpool's startwithdrawal","user":{"login":"gsalgado","id":412274,"avatar_url":"https://avatars.githubusercontent.com/u/412274?v=3","gravatar_id":"","url":"https://api.github.com/users/gsalgado","html_url":"https://github.com/gsalgado","followers_url":"https://api.github.com/users/gsalgado/followers","following_url":"https://api.github.com/users/gsalgado/following{/other_user}","gists_url":"https://api.github.com/users/gsalgado/gists{/gist_id}","starred_url":"https://api.github.com/users/gsalgado/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gsalgado/subscriptions","organizations_url":"https://api.github.com/users/gsalgado/orgs","repos_url":"https://api.github.com/users/gsalgado/repos","events_url":"https://api.github.com/users/gsalgado/events{/privacy}","received_events_url":"https://api.github.com/users/gsalgado/received_events","type":"User","site_admin":false},"body":"http://opentransactions.org/wiki/index.php/Startwithdrawal is basically what\r\nthis implements.  The interesting bits are in withdrawal.go and\r\ninput_selection.go. The former has the implementation of http://goo.gl/iUrQ3s\r\nand the latter implements http://goo.gl/znOECm.\r\n\r\nThere are a lot of mechanical changes (e.g. votingPool -> pool in variables,\r\nvp -> p in method receivers) and moving of some tests (e.g.  serialization) to\r\npool_wb_test.go\r\n\r\nIt also includes a couple functions to construct sigscripts using the raw\r\nsignatures returned by Pool.StartWithdrawal(). These are going to be used in\r\nthe implementation of\r\nhttp://opentransactions.org/wiki/index.php/Updatewithdrawal but right now\r\nthey're used in tests to make sure the signatures returned by startwithdrawal\r\nare correct.\r\n\r\nSome of our test files have a _wb_ infix, which stands for whitebox. These are\r\nin the same package (votingpool) as the actual code they test, so that they\r\ncan access the internal bits. We decided to use this approach because\r\nthere are too many internal bits (including data types) we wanted to test\r\nthoroughly and it'd be annoying to use internal_test.go to expose them all for\r\ntests.","created_at":"2015-01-30T12:19:38Z","updated_at":"2015-03-31T07:49:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6d75dcc5423c2a663cfce4cc78465243f7250568","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/btcsuite/btcwallet/pulls/178/commits","review_comments_url":"https://api.github.com/repos/btcsuite/btcwallet/pulls/178/comments","review_comment_url":"https://api.github.com/repos/btcsuite/btcwallet/pulls/comments{/number}","comments_url":"https://api.github.com/repos/btcsuite/btcwallet/issues/178/comments","statuses_url":"https://api.github.com/repos/btcsuite/btcwallet/statuses/516706a4b907c5c24809fb617238a1e670fa51dd","head":{"label":"gsalgado:vp-withdrawal","ref":"vp-withdrawal","sha":"516706a4b907c5c24809fb617238a1e670fa51dd","user":{"login":"gsalgado","id":412274,"avatar_url":"https://avatars.githubusercontent.com/u/412274?v=3","gravatar_id":"","url":"https://api.github.com/users/gsalgado","html_url":"https://github.com/gsalgado","followers_url":"https://api.github.com/users/gsalgado/followers","following_url":"https://api.github.com/users/gsalgado/following{/other_user}","gists_url":"https://api.github.com/users/gsalgado/gists{/gist_id}","starred_url":"https://api.github.com/users/gsalgado/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gsalgado/subscriptions","organizations_url":"https://api.github.com/users/gsalgado/orgs","repos_url":"https://api.github.com/users/gsalgado/repos","events_url":"https://api.github.com/users/gsalgado/events{/privacy}","received_events_url":"https://api.github.com/users/gsalgado/received_events","type":"User","site_admin":false},"repo":{"id":23590062,"name":"btcwallet","full_name":"gsalgado/btcwallet","owner":{"login":"gsalgado","id":412274,"avatar_url":"https://avatars.githubusercontent.com/u/412274?v=3","gravatar_id":"","url":"https://api.github.com/users/gsalgado","html_url":"https://github.com/gsalgado","followers_url":"https://api.github.com/users/gsalgado/followers","following_url":"https://api.github.com/users/gsalgado/following{/other_user}","gists_url":"https://api.github.com/users/gsalgado/gists{/gist_id}","starred_url":"https://api.github.com/users/gsalgado/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gsalgado/subscriptions","organizations_url":"https://api.github.com/users/gsalgado/orgs","repos_url":"https://api.github.com/users/gsalgado/repos","events_url":"https://api.github.com/users/gsalgado/events{/privacy}","received_events_url":"https://api.github.com/users/gsalgado/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gsalgado/btcwallet","description":"","fork":true,"url":"https://api.github.com/repos/gsalgado/btcwallet","forks_url":"https://api.github.com/repos/gsalgado/btcwallet/forks","keys_url":"https://api.github.com/repos/gsalgado/btcwallet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gsalgado/btcwallet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gsalgado/btcwallet/teams","hooks_url":"https://api.github.com/repos/gsalgado/btcwallet/hooks","issue_events_url":"https://api.github.com/repos/gsalgado/btcwallet/issues/events{/number}","events_url":"https://api.github.com/repos/gsalgado/btcwallet/events","assignees_url":"https://api.github.com/repos/gsalgado/btcwallet/assignees{/user}","branches_url":"https://api.github.com/repos/gsalgado/btcwallet/branches{/branch}","tags_url":"https://api.github.com/repos/gsalgado/btcwallet/tags","blobs_url":"https://api.github.com/repos/gsalgado/btcwallet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gsalgado/btcwallet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gsalgado/btcwallet/git/refs{/sha}","trees_url":"https://api.github.com/repos/gsalgado/btcwallet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gsalgado/btcwallet/statuses/{sha}","languages_url":"https://api.github.com/repos/gsalgado/btcwallet/languages","stargazers_url":"https://api.github.com/repos/gsalgado/btcwallet/stargazers","contributors_url":"https://api.github.com/repos/gsalgado/btcwallet/contributors","subscribers_url":"https://api.github.com/repos/gsalgado/btcwallet/subscribers","subscription_url":"https://api.github.com/repos/gsalgado/btcwallet/subscription","commits_url":"https://api.github.com/repos/gsalgado/btcwallet/commits{/sha}","git_commits_url":"https://api.github.com/repos/gsalgado/btcwallet/git/commits{/sha}","comments_url":"https://api.github.com/repos/gsalgado/btcwallet/comments{/number}","issue_comment_url":"https://api.github.com/repos/gsalgado/btcwallet/issues/comments{/number}","contents_url":"https://api.github.com/repos/gsalgado/btcwallet/contents/{+path}","compare_url":"https://api.github.com/repos/gsalgado/btcwallet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gsalgado/btcwallet/merges","archive_url":"https://api.github.com/repos/gsalgado/btcwallet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gsalgado/btcwallet/downloads","issues_url":"https://api.github.com/repos/gsalgado/btcwallet/issues{/number}","pulls_url":"https://api.github.com/repos/gsalgado/btcwallet/pulls{/number}","milestones_url":"https://api.github.com/repos/gsalgado/btcwallet/milestones{/number}","notifications_url":"https://api.github.com/repos/gsalgado/btcwallet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gsalgado/btcwallet/labels{/name}","releases_url":"https://api.github.com/repos/gsalgado/btcwallet/releases{/id}","created_at":"2014-09-02T18:16:22Z","updated_at":"2015-03-19T10:27:33Z","pushed_at":"2015-03-26T11:02:35Z","git_url":"git://github.com/gsalgado/btcwallet.git","ssh_url":"git@github.com:gsalgado/btcwallet.git","clone_url":"https://github.com/gsalgado/btcwallet.git","svn_url":"https://github.com/gsalgado/btcwallet","homepage":null,"size":3604,"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":"btcsuite:master","ref":"master","sha":"68a9168d9e127c77138d2954a80470ea6113c67e","user":{"login":"btcsuite","id":10235229,"avatar_url":"https://avatars.githubusercontent.com/u/10235229?v=3","gravatar_id":"","url":"https://api.github.com/users/btcsuite","html_url":"https://github.com/btcsuite","followers_url":"https://api.github.com/users/btcsuite/followers","following_url":"https://api.github.com/users/btcsuite/following{/other_user}","gists_url":"https://api.github.com/users/btcsuite/gists{/gist_id}","starred_url":"https://api.github.com/users/btcsuite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/btcsuite/subscriptions","organizations_url":"https://api.github.com/users/btcsuite/orgs","repos_url":"https://api.github.com/users/btcsuite/repos","events_url":"https://api.github.com/users/btcsuite/events{/privacy}","received_events_url":"https://api.github.com/users/btcsuite/received_events","type":"Organization","site_admin":false},"repo":{"id":12136863,"name":"btcwallet","full_name":"btcsuite/btcwallet","owner":{"login":"btcsuite","id":10235229,"avatar_url":"https://avatars.githubusercontent.com/u/10235229?v=3","gravatar_id":"","url":"https://api.github.com/users/btcsuite","html_url":"https://github.com/btcsuite","followers_url":"https://api.github.com/users/btcsuite/followers","following_url":"https://api.github.com/users/btcsuite/following{/other_user}","gists_url":"https://api.github.com/users/btcsuite/gists{/gist_id}","starred_url":"https://api.github.com/users/btcsuite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/btcsuite/subscriptions","organizations_url":"https://api.github.com/users/btcsuite/orgs","repos_url":"https://api.github.com/users/btcsuite/repos","events_url":"https://api.github.com/users/btcsuite/events{/privacy}","received_events_url":"https://api.github.com/users/btcsuite/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/btcsuite/btcwallet","description":"","fork":false,"url":"https://api.github.com/repos/btcsuite/btcwallet","forks_url":"https://api.github.com/repos/btcsuite/btcwallet/forks","keys_url":"https://api.github.com/repos/btcsuite/btcwallet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/btcsuite/btcwallet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/btcsuite/btcwallet/teams","hooks_url":"https://api.github.com/repos/btcsuite/btcwallet/hooks","issue_events_url":"https://api.github.com/repos/btcsuite/btcwallet/issues/events{/number}","events_url":"https://api.github.com/repos/btcsuite/btcwallet/events","assignees_url":"https://api.github.com/repos/btcsuite/btcwallet/assignees{/user}","branches_url":"https://api.github.com/repos/btcsuite/btcwallet/branches{/branch}","tags_url":"https://api.github.com/repos/btcsuite/btcwallet/tags","blobs_url":"https://api.github.com/repos/btcsuite/btcwallet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/btcsuite/btcwallet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/btcsuite/btcwallet/git/refs{/sha}","trees_url":"https://api.github.com/repos/btcsuite/btcwallet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/btcsuite/btcwallet/statuses/{sha}","languages_url":"https://api.github.com/repos/btcsuite/btcwallet/languages","stargazers_url":"https://api.github.com/repos/btcsuite/btcwallet/stargazers","contributors_url":"https://api.github.com/repos/btcsuite/btcwallet/contributors","subscribers_url":"https://api.github.com/repos/btcsuite/btcwallet/subscribers","subscription_url":"https://api.github.com/repos/btcsuite/btcwallet/subscription","commits_url":"https://api.github.com/repos/btcsuite/btcwallet/commits{/sha}","git_commits_url":"https://api.github.com/repos/btcsuite/btcwallet/git/commits{/sha}","comments_url":"https://api.github.com/repos/btcsuite/btcwallet/comments{/number}","issue_comment_url":"https://api.github.com/repos/btcsuite/btcwallet/issues/comments{/number}","contents_url":"https://api.github.com/repos/btcsuite/btcwallet/contents/{+path}","compare_url":"https://api.github.com/repos/btcsuite/btcwallet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/btcsuite/btcwallet/merges","archive_url":"https://api.github.com/repos/btcsuite/btcwallet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/btcsuite/btcwallet/downloads","issues_url":"https://api.github.com/repos/btcsuite/btcwallet/issues{/number}","pulls_url":"https://api.github.com/repos/btcsuite/btcwallet/pulls{/number}","milestones_url":"https://api.github.com/repos/btcsuite/btcwallet/milestones{/number}","notifications_url":"https://api.github.com/repos/btcsuite/btcwallet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/btcsuite/btcwallet/labels{/name}","releases_url":"https://api.github.com/repos/btcsuite/btcwallet/releases{/id}","created_at":"2013-08-15T14:53:57Z","updated_at":"2015-03-31T07:46:33Z","pushed_at":"2015-03-31T06:12:06Z","git_url":"git://github.com/btcsuite/btcwallet.git","ssh_url":"git@github.com:btcsuite/btcwallet.git","clone_url":"https://github.com/btcsuite/btcwallet.git","svn_url":"https://github.com/btcsuite/btcwallet","homepage":null,"size":7026,"stargazers_count":62,"watchers_count":62,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":36,"mirror_url":null,"open_issues_count":27,"forks":36,"open_issues":27,"watchers":62,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/btcsuite/btcwallet/pulls/178"},"html":{"href":"https://github.com/btcsuite/btcwallet/pull/178"},"issue":{"href":"https://api.github.com/repos/btcsuite/btcwallet/issues/178"},"comments":{"href":"https://api.github.com/repos/btcsuite/btcwallet/issues/178/comments"},"review_comments":{"href":"https://api.github.com/repos/btcsuite/btcwallet/pulls/178/comments"},"review_comment":{"href":"https://api.github.com/repos/btcsuite/btcwallet/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/btcsuite/btcwallet/pulls/178/commits"},"statuses":{"href":"https://api.github.com/repos/btcsuite/btcwallet/statuses/516706a4b907c5c24809fb617238a1e670fa51dd"}}}}