{"action":"created","comment":{"url":"https://api.github.com/repos/input-output-hk/cardano-sl/pulls/comments/129939634","pull_request_review_id":52764079,"id":129939634,"diff_hunk":"@@ -207,52 +207,43 @@ mkCTxs\n     -> TxHistoryEntry     -- ^ Tx history entry\n     -> CTxMeta            -- ^ Transaction metadata\n     -> [CWAddressMeta]    -- ^ Addresses of wallet\n-    -> Bool               -- ^ Workaround for redemption txs (introduced in CSM-330)\n     -> Either Text CTxs\n-mkCTxs diff THEntry {..} meta wAddrMetas isRedemptionTx = do\n+mkCTxs diff THEntry {..} meta wAddrMetas = do\n     ctInputAddrsNe <-\n         nonEmpty ctInputAddrs\n         `whenNothing` throwError \"No input addresses in tx!\"\n     let isLocalAddr = isTxLocalAddress wAddrMetas ctInputAddrsNe\n         isLocalTxOutput = isLocalAddr . addressToCId . txOutAddress\n-        -- We check against `wAddrsSet` instead of using `isLocalAddr` here\n-        -- because of the redeem transactions. `isLocalAddr` checks whether\n-        -- the address belongs to the same _wallet_ as the _inputs_ of the\n-        -- current transaction, which is never the case for redeem txs.\n-        -- TODO(thatguy): since there is only one special case, perhaps we\n-        -- want to consider it separately and use `isLocalAddr` in other cases.\n-        -- [CSM-309] Bad for multiple-destinations transactions\n-        allOutputsBelongToUs = all (`S.member` wAddrsSet) ctOutputAddrs\n-        outputsForAmountCalc =\n-            outputs &\n-            if isRedemptionTx then identity else filter (not . isLocalTxOutput)\n-        ctAmount =\n-            mkCCoin . unsafeIntegerToCoin . sumCoins . map txOutValue $\n-            outputsForAmountCalc\n-        mkCTx isOutgoing mbSignificantAddrs = do  -- Maybe monad starts here\n-            -- Return `Nothing` if none of the significantAddrs belong to us.\n-            guard $\n-                maybe True\n-                (\\significantAddrs ->\n-                    not . null $ wAddrsSet `S.intersection` S.fromList significantAddrs)\n-                mbSignificantAddrs\n-            return CTx {ctIsOutgoing = isOutgoing, ..}\n-        -- Output addresses whose presence makes us display the transaction\n-        -- (incoming half, i.e. one with 'isOutgoing' set to @false@).\n-        ctSignificantOutputAddrs =\n-            ctOutputAddrs &\n-            if allOutputsBelongToUs then identity else filter (not . isLocalAddr)\n-        ctsOutgoing = mkCTx True $ Just ctInputAddrs\n-        ctsIncoming = mkCTx False $ if isRedemptionTx then Nothing else Just ctSignificantOutputAddrs\n+\n+        ownInputs = filter isLocalTxOutput inputs\n+        ownOutputs = filter isLocalTxOutput outputs\n+\n+    when (null ownInputs && null ownOutputs) $\n+        throwError \"Transaction is irrelevant to given wallet!\"\n+\n+    let sumMoney = sumCoins . map txOutValue\n+        outgoingMoney = sumMoney ownInputs\n+        incomingMoney = sumMoney ownOutputs\n+        isOutgoing = outgoingMoney >= incomingMoney\n+        isIncoming = incomingMoney >= outgoingMoney\n+\n+        ctAmount = mkCCoin . unsafeIntegerToCoin $\n+            if | isOutgoing && isIncoming -> outgoingMoney\n+               | isOutgoing -> outgoingMoney - incomingMoney\n+               | isIncoming -> incomingMoney - outgoingMoney\n+\n+        mkCTx ctIsOutgoing cond = guard cond >> pure CTx {..}\n+        ctsOutgoing = mkCTx True isOutgoing\n+        ctsIncoming = mkCTx False isIncoming","path":"src/Pos/Wallet/Web/ClientTypes.hs","position":62,"original_position":62,"commit_id":"d938704d06a0a595a498503b311ff00d16abba4f","original_commit_id":"d938704d06a0a595a498503b311ff00d16abba4f","user":{"login":"Martoon-00","id":5394217,"avatar_url":"https://avatars3.githubusercontent.com/u/5394217?v=4","gravatar_id":"","url":"https://api.github.com/users/Martoon-00","html_url":"https://github.com/Martoon-00","followers_url":"https://api.github.com/users/Martoon-00/followers","following_url":"https://api.github.com/users/Martoon-00/following{/other_user}","gists_url":"https://api.github.com/users/Martoon-00/gists{/gist_id}","starred_url":"https://api.github.com/users/Martoon-00/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Martoon-00/subscriptions","organizations_url":"https://api.github.com/users/Martoon-00/orgs","repos_url":"https://api.github.com/users/Martoon-00/repos","events_url":"https://api.github.com/users/Martoon-00/events{/privacy}","received_events_url":"https://api.github.com/users/Martoon-00/received_events","type":"User","site_admin":false},"body":"In case of redeeming transaction only outgoing part remains, which redeeming expects incoming one and thus fails","created_at":"2017-07-27T19:40:26Z","updated_at":"2017-07-27T19:40:26Z","html_url":"https://github.com/input-output-hk/cardano-sl/pull/1238#discussion_r129939634","pull_request_url":"https://api.github.com/repos/input-output-hk/cardano-sl/pulls/1238","_links":{"self":{"href":"https://api.github.com/repos/input-output-hk/cardano-sl/pulls/comments/129939634"},"html":{"href":"https://github.com/input-output-hk/cardano-sl/pull/1238#discussion_r129939634"},"pull_request":{"href":"https://api.github.com/repos/input-output-hk/cardano-sl/pulls/1238"}}},"pull_request":{"url":"https://api.github.com/repos/input-output-hk/cardano-sl/pulls/1238","id":132814973,"html_url":"https://github.com/input-output-hk/cardano-sl/pull/1238","diff_url":"https://github.com/input-output-hk/cardano-sl/pull/1238.diff","patch_url":"https://github.com/input-output-hk/cardano-sl/pull/1238.patch","issue_url":"https://api.github.com/repos/input-output-hk/cardano-sl/issues/1238","number":1238,"state":"open","locked":false,"title":"[CSM-352] Rewrite `mkCTxs` without `isRedemptionTx` flag","user":{"login":"Martoon-00","id":5394217,"avatar_url":"https://avatars3.githubusercontent.com/u/5394217?v=4","gravatar_id":"","url":"https://api.github.com/users/Martoon-00","html_url":"https://github.com/Martoon-00","followers_url":"https://api.github.com/users/Martoon-00/followers","following_url":"https://api.github.com/users/Martoon-00/following{/other_user}","gists_url":"https://api.github.com/users/Martoon-00/gists{/gist_id}","starred_url":"https://api.github.com/users/Martoon-00/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Martoon-00/subscriptions","organizations_url":"https://api.github.com/users/Martoon-00/orgs","repos_url":"https://api.github.com/users/Martoon-00/repos","events_url":"https://api.github.com/users/Martoon-00/events{/privacy}","received_events_url":"https://api.github.com/users/Martoon-00/received_events","type":"User","site_admin":false},"body":"This is crucial fix since it fixes CSM-392 as well","created_at":"2017-07-27T18:27:43Z","updated_at":"2017-07-27T19:40:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"03f5fc2d284d755717bdf4f3162cef80dc6759c8","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/input-output-hk/cardano-sl/pulls/1238/commits","review_comments_url":"https://api.github.com/repos/input-output-hk/cardano-sl/pulls/1238/comments","review_comment_url":"https://api.github.com/repos/input-output-hk/cardano-sl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/input-output-hk/cardano-sl/issues/1238/comments","statuses_url":"https://api.github.com/repos/input-output-hk/cardano-sl/statuses/d938704d06a0a595a498503b311ff00d16abba4f","head":{"label":"input-output-hk:bug/csm352-redeeming-misbehaviour-0.5","ref":"bug/csm352-redeeming-misbehaviour-0.5","sha":"d938704d06a0a595a498503b311ff00d16abba4f","user":{"login":"input-output-hk","id":12909177,"avatar_url":"https://avatars3.githubusercontent.com/u/12909177?v=4","gravatar_id":"","url":"https://api.github.com/users/input-output-hk","html_url":"https://github.com/input-output-hk","followers_url":"https://api.github.com/users/input-output-hk/followers","following_url":"https://api.github.com/users/input-output-hk/following{/other_user}","gists_url":"https://api.github.com/users/input-output-hk/gists{/gist_id}","starred_url":"https://api.github.com/users/input-output-hk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/input-output-hk/subscriptions","organizations_url":"https://api.github.com/users/input-output-hk/orgs","repos_url":"https://api.github.com/users/input-output-hk/repos","events_url":"https://api.github.com/users/input-output-hk/events{/privacy}","received_events_url":"https://api.github.com/users/input-output-hk/received_events","type":"Organization","site_admin":false},"repo":{"id":70913997,"name":"cardano-sl","full_name":"input-output-hk/cardano-sl","owner":{"login":"input-output-hk","id":12909177,"avatar_url":"https://avatars3.githubusercontent.com/u/12909177?v=4","gravatar_id":"","url":"https://api.github.com/users/input-output-hk","html_url":"https://github.com/input-output-hk","followers_url":"https://api.github.com/users/input-output-hk/followers","following_url":"https://api.github.com/users/input-output-hk/following{/other_user}","gists_url":"https://api.github.com/users/input-output-hk/gists{/gist_id}","starred_url":"https://api.github.com/users/input-output-hk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/input-output-hk/subscriptions","organizations_url":"https://api.github.com/users/input-output-hk/orgs","repos_url":"https://api.github.com/users/input-output-hk/repos","events_url":"https://api.github.com/users/input-output-hk/events{/privacy}","received_events_url":"https://api.github.com/users/input-output-hk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/input-output-hk/cardano-sl","description":"Cryptographic currency implementing Ouroboros PoS protocol","fork":false,"url":"https://api.github.com/repos/input-output-hk/cardano-sl","forks_url":"https://api.github.com/repos/input-output-hk/cardano-sl/forks","keys_url":"https://api.github.com/repos/input-output-hk/cardano-sl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/input-output-hk/cardano-sl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/input-output-hk/cardano-sl/teams","hooks_url":"https://api.github.com/repos/input-output-hk/cardano-sl/hooks","issue_events_url":"https://api.github.com/repos/input-output-hk/cardano-sl/issues/events{/number}","events_url":"https://api.github.com/repos/input-output-hk/cardano-sl/events","assignees_url":"https://api.github.com/repos/input-output-hk/cardano-sl/assignees{/user}","branches_url":"https://api.github.com/repos/input-output-hk/cardano-sl/branches{/branch}","tags_url":"https://api.github.com/repos/input-output-hk/cardano-sl/tags","blobs_url":"https://api.github.com/repos/input-output-hk/cardano-sl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/input-output-hk/cardano-sl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/input-output-hk/cardano-sl/git/refs{/sha}","trees_url":"https://api.github.com/repos/input-output-hk/cardano-sl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/input-output-hk/cardano-sl/statuses/{sha}","languages_url":"https://api.github.com/repos/input-output-hk/cardano-sl/languages","stargazers_url":"https://api.github.com/repos/input-output-hk/cardano-sl/stargazers","contributors_url":"https://api.github.com/repos/input-output-hk/cardano-sl/contributors","subscribers_url":"https://api.github.com/repos/input-output-hk/cardano-sl/subscribers","subscription_url":"https://api.github.com/repos/input-output-hk/cardano-sl/subscription","commits_url":"https://api.github.com/repos/input-output-hk/cardano-sl/commits{/sha}","git_commits_url":"https://api.github.com/repos/input-output-hk/cardano-sl/git/commits{/sha}","comments_url":"https://api.github.com/repos/input-output-hk/cardano-sl/comments{/number}","issue_comment_url":"https://api.github.com/repos/input-output-hk/cardano-sl/issues/comments{/number}","contents_url":"https://api.github.com/repos/input-output-hk/cardano-sl/contents/{+path}","compare_url":"https://api.github.com/repos/input-output-hk/cardano-sl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/input-output-hk/cardano-sl/merges","archive_url":"https://api.github.com/repos/input-output-hk/cardano-sl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/input-output-hk/cardano-sl/downloads","issues_url":"https://api.github.com/repos/input-output-hk/cardano-sl/issues{/number}","pulls_url":"https://api.github.com/repos/input-output-hk/cardano-sl/pulls{/number}","milestones_url":"https://api.github.com/repos/input-output-hk/cardano-sl/milestones{/number}","notifications_url":"https://api.github.com/repos/input-output-hk/cardano-sl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/input-output-hk/cardano-sl/labels{/name}","releases_url":"https://api.github.com/repos/input-output-hk/cardano-sl/releases{/id}","deployments_url":"https://api.github.com/repos/input-output-hk/cardano-sl/deployments","created_at":"2016-10-14T13:44:38Z","updated_at":"2017-07-24T21:30:09Z","pushed_at":"2017-07-27T19:34:47Z","git_url":"git://github.com/input-output-hk/cardano-sl.git","ssh_url":"git@github.com:input-output-hk/cardano-sl.git","clone_url":"https://github.com/input-output-hk/cardano-sl.git","svn_url":"https://github.com/input-output-hk/cardano-sl","homepage":"","size":57318,"stargazers_count":208,"watchers_count":208,"language":"Haskell","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"open_issues_count":94,"forks":23,"open_issues":94,"watchers":208,"default_branch":"master"}},"base":{"label":"input-output-hk:cardano-sl-0.5","ref":"cardano-sl-0.5","sha":"6bfc9267db3f749e26caf19e50e9716d01241a6c","user":{"login":"input-output-hk","id":12909177,"avatar_url":"https://avatars3.githubusercontent.com/u/12909177?v=4","gravatar_id":"","url":"https://api.github.com/users/input-output-hk","html_url":"https://github.com/input-output-hk","followers_url":"https://api.github.com/users/input-output-hk/followers","following_url":"https://api.github.com/users/input-output-hk/following{/other_user}","gists_url":"https://api.github.com/users/input-output-hk/gists{/gist_id}","starred_url":"https://api.github.com/users/input-output-hk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/input-output-hk/subscriptions","organizations_url":"https://api.github.com/users/input-output-hk/orgs","repos_url":"https://api.github.com/users/input-output-hk/repos","events_url":"https://api.github.com/users/input-output-hk/events{/privacy}","received_events_url":"https://api.github.com/users/input-output-hk/received_events","type":"Organization","site_admin":false},"repo":{"id":70913997,"name":"cardano-sl","full_name":"input-output-hk/cardano-sl","owner":{"login":"input-output-hk","id":12909177,"avatar_url":"https://avatars3.githubusercontent.com/u/12909177?v=4","gravatar_id":"","url":"https://api.github.com/users/input-output-hk","html_url":"https://github.com/input-output-hk","followers_url":"https://api.github.com/users/input-output-hk/followers","following_url":"https://api.github.com/users/input-output-hk/following{/other_user}","gists_url":"https://api.github.com/users/input-output-hk/gists{/gist_id}","starred_url":"https://api.github.com/users/input-output-hk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/input-output-hk/subscriptions","organizations_url":"https://api.github.com/users/input-output-hk/orgs","repos_url":"https://api.github.com/users/input-output-hk/repos","events_url":"https://api.github.com/users/input-output-hk/events{/privacy}","received_events_url":"https://api.github.com/users/input-output-hk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/input-output-hk/cardano-sl","description":"Cryptographic currency implementing Ouroboros PoS protocol","fork":false,"url":"https://api.github.com/repos/input-output-hk/cardano-sl","forks_url":"https://api.github.com/repos/input-output-hk/cardano-sl/forks","keys_url":"https://api.github.com/repos/input-output-hk/cardano-sl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/input-output-hk/cardano-sl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/input-output-hk/cardano-sl/teams","hooks_url":"https://api.github.com/repos/input-output-hk/cardano-sl/hooks","issue_events_url":"https://api.github.com/repos/input-output-hk/cardano-sl/issues/events{/number}","events_url":"https://api.github.com/repos/input-output-hk/cardano-sl/events","assignees_url":"https://api.github.com/repos/input-output-hk/cardano-sl/assignees{/user}","branches_url":"https://api.github.com/repos/input-output-hk/cardano-sl/branches{/branch}","tags_url":"https://api.github.com/repos/input-output-hk/cardano-sl/tags","blobs_url":"https://api.github.com/repos/input-output-hk/cardano-sl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/input-output-hk/cardano-sl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/input-output-hk/cardano-sl/git/refs{/sha}","trees_url":"https://api.github.com/repos/input-output-hk/cardano-sl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/input-output-hk/cardano-sl/statuses/{sha}","languages_url":"https://api.github.com/repos/input-output-hk/cardano-sl/languages","stargazers_url":"https://api.github.com/repos/input-output-hk/cardano-sl/stargazers","contributors_url":"https://api.github.com/repos/input-output-hk/cardano-sl/contributors","subscribers_url":"https://api.github.com/repos/input-output-hk/cardano-sl/subscribers","subscription_url":"https://api.github.com/repos/input-output-hk/cardano-sl/subscription","commits_url":"https://api.github.com/repos/input-output-hk/cardano-sl/commits{/sha}","git_commits_url":"https://api.github.com/repos/input-output-hk/cardano-sl/git/commits{/sha}","comments_url":"https://api.github.com/repos/input-output-hk/cardano-sl/comments{/number}","issue_comment_url":"https://api.github.com/repos/input-output-hk/cardano-sl/issues/comments{/number}","contents_url":"https://api.github.com/repos/input-output-hk/cardano-sl/contents/{+path}","compare_url":"https://api.github.com/repos/input-output-hk/cardano-sl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/input-output-hk/cardano-sl/merges","archive_url":"https://api.github.com/repos/input-output-hk/cardano-sl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/input-output-hk/cardano-sl/downloads","issues_url":"https://api.github.com/repos/input-output-hk/cardano-sl/issues{/number}","pulls_url":"https://api.github.com/repos/input-output-hk/cardano-sl/pulls{/number}","milestones_url":"https://api.github.com/repos/input-output-hk/cardano-sl/milestones{/number}","notifications_url":"https://api.github.com/repos/input-output-hk/cardano-sl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/input-output-hk/cardano-sl/labels{/name}","releases_url":"https://api.github.com/repos/input-output-hk/cardano-sl/releases{/id}","deployments_url":"https://api.github.com/repos/input-output-hk/cardano-sl/deployments","created_at":"2016-10-14T13:44:38Z","updated_at":"2017-07-24T21:30:09Z","pushed_at":"2017-07-27T19:34:47Z","git_url":"git://github.com/input-output-hk/cardano-sl.git","ssh_url":"git@github.com:input-output-hk/cardano-sl.git","clone_url":"https://github.com/input-output-hk/cardano-sl.git","svn_url":"https://github.com/input-output-hk/cardano-sl","homepage":"","size":57318,"stargazers_count":208,"watchers_count":208,"language":"Haskell","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"open_issues_count":94,"forks":23,"open_issues":94,"watchers":208,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/input-output-hk/cardano-sl/pulls/1238"},"html":{"href":"https://github.com/input-output-hk/cardano-sl/pull/1238"},"issue":{"href":"https://api.github.com/repos/input-output-hk/cardano-sl/issues/1238"},"comments":{"href":"https://api.github.com/repos/input-output-hk/cardano-sl/issues/1238/comments"},"review_comments":{"href":"https://api.github.com/repos/input-output-hk/cardano-sl/pulls/1238/comments"},"review_comment":{"href":"https://api.github.com/repos/input-output-hk/cardano-sl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/input-output-hk/cardano-sl/pulls/1238/commits"},"statuses":{"href":"https://api.github.com/repos/input-output-hk/cardano-sl/statuses/d938704d06a0a595a498503b311ff00d16abba4f"}}}}
{"actor":{"display_login":"Martoon-00"}}