{"action":"created","comment":{"url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/comments/63962959","id":63962959,"diff_hunk":"@@ -114,3 +114,116 @@ func verifyRecentRevision(conn net.Conn, contract Contract) error {\n \t// contract expiration (which was checked earlier).\n \treturn modules.VerifyFileContractRevisionTransactionSignatures(lastRevision, hostSignatures, contract.FileContract.WindowStart-1)\n }\n+\n+// negotiateRevision sends a revision and actions to the host for approval,\n+// completing one iteration of the revision loop.\n+func negotiateRevision(conn net.Conn, rev types.FileContractRevision, secretKey crypto.SecretKey) (types.Transaction, error) {\n+\t// create transaction containing the revision\n+\tsignedTxn := types.Transaction{\n+\t\tFileContractRevisions: []types.FileContractRevision{rev},\n+\t\tTransactionSignatures: []types.TransactionSignature{{\n+\t\t\tParentID:       crypto.Hash(rev.ParentID),\n+\t\t\tCoveredFields:  types.CoveredFields{FileContractRevisions: []uint64{0}},\n+\t\t\tPublicKeyIndex: 0, // renter key is always first -- see formContract\n+\t\t}},\n+\t}\n+\t// sign the transaction\n+\tencodedSig, _ := crypto.SignHash(signedTxn.SigHash(0), secretKey) // no error possible\n+\tsignedTxn.TransactionSignatures[0].Signature = encodedSig[:]\n+\n+\t// send the revision\n+\tif err := encoding.WriteObject(conn, rev); err != nil {\n+\t\treturn types.Transaction{}, errors.New(\"couldn't send revision: \" + err.Error())\n+\t}\n+\t// read acceptance\n+\tif err := modules.ReadNegotiationAcceptance(conn); err != nil {\n+\t\treturn types.Transaction{}, errors.New(\"host did not accept revision: \" + err.Error())\n+\t}\n+\n+\t// send the new transaction signature\n+\tif err := encoding.WriteObject(conn, signedTxn.TransactionSignatures[0]); err != nil {\n+\t\treturn types.Transaction{}, errors.New(\"couldn't send transaction signature: \" + err.Error())\n+\t}\n+\t// read the host's acceptance and transaction signature\n+\tif err := modules.ReadNegotiationAcceptance(conn); err != nil {\n+\t\treturn types.Transaction{}, errors.New(\"host did not accept transaction signature: \" + err.Error())\n+\t}\n+\tvar hostSig types.TransactionSignature\n+\tif err := encoding.ReadObject(conn, &hostSig, 16e3); err != nil {\n+\t\treturn types.Transaction{}, errors.New(\"couldn't read host's signature: \" + err.Error())\n+\t}\n+\n+\t// add the signature to the transaction and verify it\n+\t// NOTE: we can fake the blockheight here because it doesn't affect\n+\t// verification; it just needs to be above the fork height and below the\n+\t// contract expiration (which was checked earlier).","path":"modules/renter/proto/negotiate.go","position":114,"original_position":114,"commit_id":"8b2d49ad8961546b323733bca7dc4d91e798b5ab","original_commit_id":"8b2d49ad8961546b323733bca7dc4d91e798b5ab","user":{"login":"lukechampine","id":3344749,"avatar_url":"https://avatars.githubusercontent.com/u/3344749?v=3","gravatar_id":"","url":"https://api.github.com/users/lukechampine","html_url":"https://github.com/lukechampine","followers_url":"https://api.github.com/users/lukechampine/followers","following_url":"https://api.github.com/users/lukechampine/following{/other_user}","gists_url":"https://api.github.com/users/lukechampine/gists{/gist_id}","starred_url":"https://api.github.com/users/lukechampine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukechampine/subscriptions","organizations_url":"https://api.github.com/users/lukechampine/orgs","repos_url":"https://api.github.com/users/lukechampine/repos","events_url":"https://api.github.com/users/lukechampine/events{/privacy}","received_events_url":"https://api.github.com/users/lukechampine/received_events","type":"User","site_admin":false},"body":"cool, I was wondering about the testing constants as well","created_at":"2016-05-19T22:12:02Z","updated_at":"2016-05-19T22:12:02Z","html_url":"https://github.com/NebulousLabs/Sia/pull/1158#discussion_r63962959","pull_request_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/1158","_links":{"self":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/comments/63962959"},"html":{"href":"https://github.com/NebulousLabs/Sia/pull/1158#discussion_r63962959"},"pull_request":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/1158"}}},"pull_request":{"url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/1158","id":70762469,"html_url":"https://github.com/NebulousLabs/Sia/pull/1158","diff_url":"https://github.com/NebulousLabs/Sia/pull/1158.diff","patch_url":"https://github.com/NebulousLabs/Sia/pull/1158.patch","issue_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/1158","number":1158,"state":"open","locked":false,"title":"Add /renter/contracts route","user":{"login":"lukechampine","id":3344749,"avatar_url":"https://avatars.githubusercontent.com/u/3344749?v=3","gravatar_id":"","url":"https://api.github.com/users/lukechampine","html_url":"https://github.com/lukechampine","followers_url":"https://api.github.com/users/lukechampine/followers","following_url":"https://api.github.com/users/lukechampine/following{/other_user}","gists_url":"https://api.github.com/users/lukechampine/gists{/gist_id}","starred_url":"https://api.github.com/users/lukechampine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukechampine/subscriptions","organizations_url":"https://api.github.com/users/lukechampine/orgs","repos_url":"https://api.github.com/users/lukechampine/repos","events_url":"https://api.github.com/users/lukechampine/events{/privacy}","received_events_url":"https://api.github.com/users/lukechampine/received_events","type":"User","site_admin":false},"body":"To enable this, the `proto.Contract` type had to be moved to `modules`. This is an interesting side effect of requiring module interfaces. Since `proto` imports `modules`, the `Renter` interface cannot return a `proto` type. If the interface were not defined in `modules`, this circular import could be avoided. However, organizationally, I can see the benefit of defining all the module-related types in one place.\r\n\r\nThe `IP` field was also renamed to `NetAddress` for consistency. This will break existing contractor.json compatibility, but this seems excusable since contractor.json has only existed in RCs thus far.","created_at":"2016-05-19T20:47:39Z","updated_at":"2016-05-19T22:12:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2a1a5700536c0a4d1f5922c0d3f928d4b37a4525","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/1158/commits","review_comments_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/1158/comments","review_comment_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/1158/comments","statuses_url":"https://api.github.com/repos/NebulousLabs/Sia/statuses/8b2d49ad8961546b323733bca7dc4d91e798b5ab","head":{"label":"NebulousLabs:contracts","ref":"contracts","sha":"8b2d49ad8961546b323733bca7dc4d91e798b5ab","user":{"login":"NebulousLabs","id":7471422,"avatar_url":"https://avatars.githubusercontent.com/u/7471422?v=3","gravatar_id":"","url":"https://api.github.com/users/NebulousLabs","html_url":"https://github.com/NebulousLabs","followers_url":"https://api.github.com/users/NebulousLabs/followers","following_url":"https://api.github.com/users/NebulousLabs/following{/other_user}","gists_url":"https://api.github.com/users/NebulousLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/NebulousLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NebulousLabs/subscriptions","organizations_url":"https://api.github.com/users/NebulousLabs/orgs","repos_url":"https://api.github.com/users/NebulousLabs/repos","events_url":"https://api.github.com/users/NebulousLabs/events{/privacy}","received_events_url":"https://api.github.com/users/NebulousLabs/received_events","type":"Organization","site_admin":false},"repo":{"id":25370072,"name":"Sia","full_name":"NebulousLabs/Sia","owner":{"login":"NebulousLabs","id":7471422,"avatar_url":"https://avatars.githubusercontent.com/u/7471422?v=3","gravatar_id":"","url":"https://api.github.com/users/NebulousLabs","html_url":"https://github.com/NebulousLabs","followers_url":"https://api.github.com/users/NebulousLabs/followers","following_url":"https://api.github.com/users/NebulousLabs/following{/other_user}","gists_url":"https://api.github.com/users/NebulousLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/NebulousLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NebulousLabs/subscriptions","organizations_url":"https://api.github.com/users/NebulousLabs/orgs","repos_url":"https://api.github.com/users/NebulousLabs/repos","events_url":"https://api.github.com/users/NebulousLabs/events{/privacy}","received_events_url":"https://api.github.com/users/NebulousLabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NebulousLabs/Sia","description":"Blockchain-based marketplace for file storage","fork":false,"url":"https://api.github.com/repos/NebulousLabs/Sia","forks_url":"https://api.github.com/repos/NebulousLabs/Sia/forks","keys_url":"https://api.github.com/repos/NebulousLabs/Sia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NebulousLabs/Sia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NebulousLabs/Sia/teams","hooks_url":"https://api.github.com/repos/NebulousLabs/Sia/hooks","issue_events_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/events{/number}","events_url":"https://api.github.com/repos/NebulousLabs/Sia/events","assignees_url":"https://api.github.com/repos/NebulousLabs/Sia/assignees{/user}","branches_url":"https://api.github.com/repos/NebulousLabs/Sia/branches{/branch}","tags_url":"https://api.github.com/repos/NebulousLabs/Sia/tags","blobs_url":"https://api.github.com/repos/NebulousLabs/Sia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NebulousLabs/Sia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NebulousLabs/Sia/git/refs{/sha}","trees_url":"https://api.github.com/repos/NebulousLabs/Sia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NebulousLabs/Sia/statuses/{sha}","languages_url":"https://api.github.com/repos/NebulousLabs/Sia/languages","stargazers_url":"https://api.github.com/repos/NebulousLabs/Sia/stargazers","contributors_url":"https://api.github.com/repos/NebulousLabs/Sia/contributors","subscribers_url":"https://api.github.com/repos/NebulousLabs/Sia/subscribers","subscription_url":"https://api.github.com/repos/NebulousLabs/Sia/subscription","commits_url":"https://api.github.com/repos/NebulousLabs/Sia/commits{/sha}","git_commits_url":"https://api.github.com/repos/NebulousLabs/Sia/git/commits{/sha}","comments_url":"https://api.github.com/repos/NebulousLabs/Sia/comments{/number}","issue_comment_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/comments{/number}","contents_url":"https://api.github.com/repos/NebulousLabs/Sia/contents/{+path}","compare_url":"https://api.github.com/repos/NebulousLabs/Sia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NebulousLabs/Sia/merges","archive_url":"https://api.github.com/repos/NebulousLabs/Sia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NebulousLabs/Sia/downloads","issues_url":"https://api.github.com/repos/NebulousLabs/Sia/issues{/number}","pulls_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls{/number}","milestones_url":"https://api.github.com/repos/NebulousLabs/Sia/milestones{/number}","notifications_url":"https://api.github.com/repos/NebulousLabs/Sia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NebulousLabs/Sia/labels{/name}","releases_url":"https://api.github.com/repos/NebulousLabs/Sia/releases{/id}","deployments_url":"https://api.github.com/repos/NebulousLabs/Sia/deployments","created_at":"2014-10-17T17:50:25Z","updated_at":"2016-05-19T14:36:42Z","pushed_at":"2016-05-19T22:01:21Z","git_url":"git://github.com/NebulousLabs/Sia.git","ssh_url":"git@github.com:NebulousLabs/Sia.git","clone_url":"https://github.com/NebulousLabs/Sia.git","svn_url":"https://github.com/NebulousLabs/Sia","homepage":"https://sia.tech","size":28570,"stargazers_count":197,"watchers_count":197,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":34,"mirror_url":null,"open_issues_count":54,"forks":34,"open_issues":54,"watchers":197,"default_branch":"master"}},"base":{"label":"NebulousLabs:master","ref":"master","sha":"f39d894ad6cc2b0e545cc9d137ccc1becb17bb5b","user":{"login":"NebulousLabs","id":7471422,"avatar_url":"https://avatars.githubusercontent.com/u/7471422?v=3","gravatar_id":"","url":"https://api.github.com/users/NebulousLabs","html_url":"https://github.com/NebulousLabs","followers_url":"https://api.github.com/users/NebulousLabs/followers","following_url":"https://api.github.com/users/NebulousLabs/following{/other_user}","gists_url":"https://api.github.com/users/NebulousLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/NebulousLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NebulousLabs/subscriptions","organizations_url":"https://api.github.com/users/NebulousLabs/orgs","repos_url":"https://api.github.com/users/NebulousLabs/repos","events_url":"https://api.github.com/users/NebulousLabs/events{/privacy}","received_events_url":"https://api.github.com/users/NebulousLabs/received_events","type":"Organization","site_admin":false},"repo":{"id":25370072,"name":"Sia","full_name":"NebulousLabs/Sia","owner":{"login":"NebulousLabs","id":7471422,"avatar_url":"https://avatars.githubusercontent.com/u/7471422?v=3","gravatar_id":"","url":"https://api.github.com/users/NebulousLabs","html_url":"https://github.com/NebulousLabs","followers_url":"https://api.github.com/users/NebulousLabs/followers","following_url":"https://api.github.com/users/NebulousLabs/following{/other_user}","gists_url":"https://api.github.com/users/NebulousLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/NebulousLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NebulousLabs/subscriptions","organizations_url":"https://api.github.com/users/NebulousLabs/orgs","repos_url":"https://api.github.com/users/NebulousLabs/repos","events_url":"https://api.github.com/users/NebulousLabs/events{/privacy}","received_events_url":"https://api.github.com/users/NebulousLabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NebulousLabs/Sia","description":"Blockchain-based marketplace for file storage","fork":false,"url":"https://api.github.com/repos/NebulousLabs/Sia","forks_url":"https://api.github.com/repos/NebulousLabs/Sia/forks","keys_url":"https://api.github.com/repos/NebulousLabs/Sia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NebulousLabs/Sia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NebulousLabs/Sia/teams","hooks_url":"https://api.github.com/repos/NebulousLabs/Sia/hooks","issue_events_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/events{/number}","events_url":"https://api.github.com/repos/NebulousLabs/Sia/events","assignees_url":"https://api.github.com/repos/NebulousLabs/Sia/assignees{/user}","branches_url":"https://api.github.com/repos/NebulousLabs/Sia/branches{/branch}","tags_url":"https://api.github.com/repos/NebulousLabs/Sia/tags","blobs_url":"https://api.github.com/repos/NebulousLabs/Sia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NebulousLabs/Sia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NebulousLabs/Sia/git/refs{/sha}","trees_url":"https://api.github.com/repos/NebulousLabs/Sia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NebulousLabs/Sia/statuses/{sha}","languages_url":"https://api.github.com/repos/NebulousLabs/Sia/languages","stargazers_url":"https://api.github.com/repos/NebulousLabs/Sia/stargazers","contributors_url":"https://api.github.com/repos/NebulousLabs/Sia/contributors","subscribers_url":"https://api.github.com/repos/NebulousLabs/Sia/subscribers","subscription_url":"https://api.github.com/repos/NebulousLabs/Sia/subscription","commits_url":"https://api.github.com/repos/NebulousLabs/Sia/commits{/sha}","git_commits_url":"https://api.github.com/repos/NebulousLabs/Sia/git/commits{/sha}","comments_url":"https://api.github.com/repos/NebulousLabs/Sia/comments{/number}","issue_comment_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/comments{/number}","contents_url":"https://api.github.com/repos/NebulousLabs/Sia/contents/{+path}","compare_url":"https://api.github.com/repos/NebulousLabs/Sia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NebulousLabs/Sia/merges","archive_url":"https://api.github.com/repos/NebulousLabs/Sia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NebulousLabs/Sia/downloads","issues_url":"https://api.github.com/repos/NebulousLabs/Sia/issues{/number}","pulls_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls{/number}","milestones_url":"https://api.github.com/repos/NebulousLabs/Sia/milestones{/number}","notifications_url":"https://api.github.com/repos/NebulousLabs/Sia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NebulousLabs/Sia/labels{/name}","releases_url":"https://api.github.com/repos/NebulousLabs/Sia/releases{/id}","deployments_url":"https://api.github.com/repos/NebulousLabs/Sia/deployments","created_at":"2014-10-17T17:50:25Z","updated_at":"2016-05-19T14:36:42Z","pushed_at":"2016-05-19T22:01:21Z","git_url":"git://github.com/NebulousLabs/Sia.git","ssh_url":"git@github.com:NebulousLabs/Sia.git","clone_url":"https://github.com/NebulousLabs/Sia.git","svn_url":"https://github.com/NebulousLabs/Sia","homepage":"https://sia.tech","size":28570,"stargazers_count":197,"watchers_count":197,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":34,"mirror_url":null,"open_issues_count":54,"forks":34,"open_issues":54,"watchers":197,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/1158"},"html":{"href":"https://github.com/NebulousLabs/Sia/pull/1158"},"issue":{"href":"https://api.github.com/repos/NebulousLabs/Sia/issues/1158"},"comments":{"href":"https://api.github.com/repos/NebulousLabs/Sia/issues/1158/comments"},"review_comments":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/1158/comments"},"review_comment":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/1158/commits"},"statuses":{"href":"https://api.github.com/repos/NebulousLabs/Sia/statuses/8b2d49ad8961546b323733bca7dc4d91e798b5ab"}}}}
{"actor":{"display_login":"lukechampine"}}