{"action":"created","comment":{"url":"https://api.github.com/repos/bitpay/bitcore/pulls/comments/26701073","id":26701073,"diff_hunk":"@@ -255,9 +254,16 @@ Address._transformScript = function(script, network){\n   } else if (script.isPublicKeyHashOut()) {\n     info.hashBuffer = script.getData();\n     info.type = Address.PayToPublicKeyHash;\n-  } else {\n-    info.hashBuffer = Hash.sha256ripemd160(script.toBuffer());\n+  } else if (script.isScriptHashIn()) {\n+    // hash the redeemscript found at the end of the scriptSig\n+    info.hashBuffer = Hash.sha256ripemd160(script.chunks[script.chunks.length - 1].buf);\n     info.type = Address.PayToScriptHash;\n+  } else if (script.isPublicKeyHashIn()) {\n+    // hash the publickey found in the scriptSig\n+    info.hashBuffer = Hash.sha256ripemd160(script.chunks[1].buf);\n+    info.type = Address.PayToPublicKeyHash;\n+  } else {\n+    throw new errors.Script.CantDeriveAddress(script);\n   }\n   info.network = Networks.get(network) || Networks.defaultNetwork;\n   return info;","path":"lib/address.js","position":101,"original_position":101,"commit_id":"62ea45a524b0f06546596a9d0221ca31a0ba7215","original_commit_id":"62ea45a524b0f06546596a9d0221ca31a0ba7215","user":{"login":"maraoz","id":287189,"avatar_url":"https://avatars.githubusercontent.com/u/287189?v=3","gravatar_id":"","url":"https://api.github.com/users/maraoz","html_url":"https://github.com/maraoz","followers_url":"https://api.github.com/users/maraoz/followers","following_url":"https://api.github.com/users/maraoz/following{/other_user}","gists_url":"https://api.github.com/users/maraoz/gists{/gist_id}","starred_url":"https://api.github.com/users/maraoz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maraoz/subscriptions","organizations_url":"https://api.github.com/users/maraoz/orgs","repos_url":"https://api.github.com/users/maraoz/repos","events_url":"https://api.github.com/users/maraoz/events{/privacy}","received_events_url":"https://api.github.com/users/maraoz/received_events","type":"User","site_admin":false},"body":"changes to `_transformScript` are the biggest change in the PR","created_at":"2015-03-18T19:59:59Z","updated_at":"2015-03-18T19:59:59Z","html_url":"https://github.com/bitpay/bitcore/pull/1151#discussion_r26701073","pull_request_url":"https://api.github.com/repos/bitpay/bitcore/pulls/1151","_links":{"self":{"href":"https://api.github.com/repos/bitpay/bitcore/pulls/comments/26701073"},"html":{"href":"https://github.com/bitpay/bitcore/pull/1151#discussion_r26701073"},"pull_request":{"href":"https://api.github.com/repos/bitpay/bitcore/pulls/1151"}}},"pull_request":{"url":"https://api.github.com/repos/bitpay/bitcore/pulls/1151","id":31465775,"html_url":"https://github.com/bitpay/bitcore/pull/1151","diff_url":"https://github.com/bitpay/bitcore/pull/1151.diff","patch_url":"https://github.com/bitpay/bitcore/pull/1151.patch","issue_url":"https://api.github.com/repos/bitpay/bitcore/issues/1151","number":1151,"state":"open","locked":false,"title":"refactor Address<->Script relation","user":{"login":"maraoz","id":287189,"avatar_url":"https://avatars.githubusercontent.com/u/287189?v=3","gravatar_id":"","url":"https://api.github.com/users/maraoz","html_url":"https://github.com/maraoz","followers_url":"https://api.github.com/users/maraoz/followers","following_url":"https://api.github.com/users/maraoz/following{/other_user}","gists_url":"https://api.github.com/users/maraoz/gists{/gist_id}","starred_url":"https://api.github.com/users/maraoz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maraoz/subscriptions","organizations_url":"https://api.github.com/users/maraoz/orgs","repos_url":"https://api.github.com/users/maraoz/repos","events_url":"https://api.github.com/users/maraoz/events{/privacy}","received_events_url":"https://api.github.com/users/maraoz/received_events","type":"User","site_admin":false},"body":"- adds `Address.payingTo(script)`, which returns a p2sh address paying to that script\r\n- Address.fromScript now works for p2sh in, p2sh out, p2pkh in, and p2pkh out, and returns the Address that can be found inside the script.\r\n- 100% coverage on Address","created_at":"2015-03-18T19:56:19Z","updated_at":"2015-03-18T19:59:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b08edcd9f13b07f680f70d9c3152c985eebd2cb0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bitpay/bitcore/pulls/1151/commits","review_comments_url":"https://api.github.com/repos/bitpay/bitcore/pulls/1151/comments","review_comment_url":"https://api.github.com/repos/bitpay/bitcore/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bitpay/bitcore/issues/1151/comments","statuses_url":"https://api.github.com/repos/bitpay/bitcore/statuses/62ea45a524b0f06546596a9d0221ca31a0ba7215","head":{"label":"maraoz:address/script","ref":"address/script","sha":"62ea45a524b0f06546596a9d0221ca31a0ba7215","user":{"login":"maraoz","id":287189,"avatar_url":"https://avatars.githubusercontent.com/u/287189?v=3","gravatar_id":"","url":"https://api.github.com/users/maraoz","html_url":"https://github.com/maraoz","followers_url":"https://api.github.com/users/maraoz/followers","following_url":"https://api.github.com/users/maraoz/following{/other_user}","gists_url":"https://api.github.com/users/maraoz/gists{/gist_id}","starred_url":"https://api.github.com/users/maraoz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maraoz/subscriptions","organizations_url":"https://api.github.com/users/maraoz/orgs","repos_url":"https://api.github.com/users/maraoz/repos","events_url":"https://api.github.com/users/maraoz/events{/privacy}","received_events_url":"https://api.github.com/users/maraoz/received_events","type":"User","site_admin":false},"repo":{"id":15574334,"name":"bitcore","full_name":"maraoz/bitcore","owner":{"login":"maraoz","id":287189,"avatar_url":"https://avatars.githubusercontent.com/u/287189?v=3","gravatar_id":"","url":"https://api.github.com/users/maraoz","html_url":"https://github.com/maraoz","followers_url":"https://api.github.com/users/maraoz/followers","following_url":"https://api.github.com/users/maraoz/following{/other_user}","gists_url":"https://api.github.com/users/maraoz/gists{/gist_id}","starred_url":"https://api.github.com/users/maraoz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maraoz/subscriptions","organizations_url":"https://api.github.com/users/maraoz/orgs","repos_url":"https://api.github.com/users/maraoz/repos","events_url":"https://api.github.com/users/maraoz/events{/privacy}","received_events_url":"https://api.github.com/users/maraoz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/maraoz/bitcore","description":"Nodejs Bitcoin Library","fork":true,"url":"https://api.github.com/repos/maraoz/bitcore","forks_url":"https://api.github.com/repos/maraoz/bitcore/forks","keys_url":"https://api.github.com/repos/maraoz/bitcore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/maraoz/bitcore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/maraoz/bitcore/teams","hooks_url":"https://api.github.com/repos/maraoz/bitcore/hooks","issue_events_url":"https://api.github.com/repos/maraoz/bitcore/issues/events{/number}","events_url":"https://api.github.com/repos/maraoz/bitcore/events","assignees_url":"https://api.github.com/repos/maraoz/bitcore/assignees{/user}","branches_url":"https://api.github.com/repos/maraoz/bitcore/branches{/branch}","tags_url":"https://api.github.com/repos/maraoz/bitcore/tags","blobs_url":"https://api.github.com/repos/maraoz/bitcore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/maraoz/bitcore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/maraoz/bitcore/git/refs{/sha}","trees_url":"https://api.github.com/repos/maraoz/bitcore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/maraoz/bitcore/statuses/{sha}","languages_url":"https://api.github.com/repos/maraoz/bitcore/languages","stargazers_url":"https://api.github.com/repos/maraoz/bitcore/stargazers","contributors_url":"https://api.github.com/repos/maraoz/bitcore/contributors","subscribers_url":"https://api.github.com/repos/maraoz/bitcore/subscribers","subscription_url":"https://api.github.com/repos/maraoz/bitcore/subscription","commits_url":"https://api.github.com/repos/maraoz/bitcore/commits{/sha}","git_commits_url":"https://api.github.com/repos/maraoz/bitcore/git/commits{/sha}","comments_url":"https://api.github.com/repos/maraoz/bitcore/comments{/number}","issue_comment_url":"https://api.github.com/repos/maraoz/bitcore/issues/comments{/number}","contents_url":"https://api.github.com/repos/maraoz/bitcore/contents/{+path}","compare_url":"https://api.github.com/repos/maraoz/bitcore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/maraoz/bitcore/merges","archive_url":"https://api.github.com/repos/maraoz/bitcore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/maraoz/bitcore/downloads","issues_url":"https://api.github.com/repos/maraoz/bitcore/issues{/number}","pulls_url":"https://api.github.com/repos/maraoz/bitcore/pulls{/number}","milestones_url":"https://api.github.com/repos/maraoz/bitcore/milestones{/number}","notifications_url":"https://api.github.com/repos/maraoz/bitcore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/maraoz/bitcore/labels{/name}","releases_url":"https://api.github.com/repos/maraoz/bitcore/releases{/id}","created_at":"2014-01-02T02:45:43Z","updated_at":"2015-03-13T15:35:39Z","pushed_at":"2015-03-18T19:54:29Z","git_url":"git://github.com/maraoz/bitcore.git","ssh_url":"git@github.com:maraoz/bitcore.git","clone_url":"https://github.com/maraoz/bitcore.git","svn_url":"https://github.com/maraoz/bitcore","homepage":null,"size":10505,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","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":1,"default_branch":"master"}},"base":{"label":"bitpay:master","ref":"master","sha":"f2ef86f31a4da639dc8fa0fdf47621f168078882","user":{"login":"bitpay","id":2554930,"avatar_url":"https://avatars.githubusercontent.com/u/2554930?v=3","gravatar_id":"","url":"https://api.github.com/users/bitpay","html_url":"https://github.com/bitpay","followers_url":"https://api.github.com/users/bitpay/followers","following_url":"https://api.github.com/users/bitpay/following{/other_user}","gists_url":"https://api.github.com/users/bitpay/gists{/gist_id}","starred_url":"https://api.github.com/users/bitpay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitpay/subscriptions","organizations_url":"https://api.github.com/users/bitpay/orgs","repos_url":"https://api.github.com/users/bitpay/repos","events_url":"https://api.github.com/users/bitpay/events{/privacy}","received_events_url":"https://api.github.com/users/bitpay/received_events","type":"Organization","site_admin":false},"repo":{"id":15259244,"name":"bitcore","full_name":"bitpay/bitcore","owner":{"login":"bitpay","id":2554930,"avatar_url":"https://avatars.githubusercontent.com/u/2554930?v=3","gravatar_id":"","url":"https://api.github.com/users/bitpay","html_url":"https://github.com/bitpay","followers_url":"https://api.github.com/users/bitpay/followers","following_url":"https://api.github.com/users/bitpay/following{/other_user}","gists_url":"https://api.github.com/users/bitpay/gists{/gist_id}","starred_url":"https://api.github.com/users/bitpay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitpay/subscriptions","organizations_url":"https://api.github.com/users/bitpay/orgs","repos_url":"https://api.github.com/users/bitpay/repos","events_url":"https://api.github.com/users/bitpay/events{/privacy}","received_events_url":"https://api.github.com/users/bitpay/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bitpay/bitcore","description":"A pure and powerful JavaScript Bitcoin library","fork":false,"url":"https://api.github.com/repos/bitpay/bitcore","forks_url":"https://api.github.com/repos/bitpay/bitcore/forks","keys_url":"https://api.github.com/repos/bitpay/bitcore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bitpay/bitcore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bitpay/bitcore/teams","hooks_url":"https://api.github.com/repos/bitpay/bitcore/hooks","issue_events_url":"https://api.github.com/repos/bitpay/bitcore/issues/events{/number}","events_url":"https://api.github.com/repos/bitpay/bitcore/events","assignees_url":"https://api.github.com/repos/bitpay/bitcore/assignees{/user}","branches_url":"https://api.github.com/repos/bitpay/bitcore/branches{/branch}","tags_url":"https://api.github.com/repos/bitpay/bitcore/tags","blobs_url":"https://api.github.com/repos/bitpay/bitcore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bitpay/bitcore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bitpay/bitcore/git/refs{/sha}","trees_url":"https://api.github.com/repos/bitpay/bitcore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bitpay/bitcore/statuses/{sha}","languages_url":"https://api.github.com/repos/bitpay/bitcore/languages","stargazers_url":"https://api.github.com/repos/bitpay/bitcore/stargazers","contributors_url":"https://api.github.com/repos/bitpay/bitcore/contributors","subscribers_url":"https://api.github.com/repos/bitpay/bitcore/subscribers","subscription_url":"https://api.github.com/repos/bitpay/bitcore/subscription","commits_url":"https://api.github.com/repos/bitpay/bitcore/commits{/sha}","git_commits_url":"https://api.github.com/repos/bitpay/bitcore/git/commits{/sha}","comments_url":"https://api.github.com/repos/bitpay/bitcore/comments{/number}","issue_comment_url":"https://api.github.com/repos/bitpay/bitcore/issues/comments{/number}","contents_url":"https://api.github.com/repos/bitpay/bitcore/contents/{+path}","compare_url":"https://api.github.com/repos/bitpay/bitcore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bitpay/bitcore/merges","archive_url":"https://api.github.com/repos/bitpay/bitcore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bitpay/bitcore/downloads","issues_url":"https://api.github.com/repos/bitpay/bitcore/issues{/number}","pulls_url":"https://api.github.com/repos/bitpay/bitcore/pulls{/number}","milestones_url":"https://api.github.com/repos/bitpay/bitcore/milestones{/number}","notifications_url":"https://api.github.com/repos/bitpay/bitcore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bitpay/bitcore/labels{/name}","releases_url":"https://api.github.com/repos/bitpay/bitcore/releases{/id}","created_at":"2013-12-17T16:10:28Z","updated_at":"2015-03-18T19:45:03Z","pushed_at":"2015-03-13T19:35:24Z","git_url":"git://github.com/bitpay/bitcore.git","ssh_url":"git@github.com:bitpay/bitcore.git","clone_url":"https://github.com/bitpay/bitcore.git","svn_url":"https://github.com/bitpay/bitcore","homepage":"","size":23042,"stargazers_count":1471,"watchers_count":1471,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":334,"mirror_url":null,"open_issues_count":69,"forks":334,"open_issues":69,"watchers":1471,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bitpay/bitcore/pulls/1151"},"html":{"href":"https://github.com/bitpay/bitcore/pull/1151"},"issue":{"href":"https://api.github.com/repos/bitpay/bitcore/issues/1151"},"comments":{"href":"https://api.github.com/repos/bitpay/bitcore/issues/1151/comments"},"review_comments":{"href":"https://api.github.com/repos/bitpay/bitcore/pulls/1151/comments"},"review_comment":{"href":"https://api.github.com/repos/bitpay/bitcore/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bitpay/bitcore/pulls/1151/commits"},"statuses":{"href":"https://api.github.com/repos/bitpay/bitcore/statuses/62ea45a524b0f06546596a9d0221ca31a0ba7215"}}}}