{"action":"created","comment":{"url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments/172638839","pull_request_review_id":101690866,"id":172638839,"diff_hunk":"@@ -2139,10 +2139,19 @@ func (lc *LightningChannel) createCommitmentTx(c *commitment,\n \n \t// Currently, within the protocol, the initiator always pays the fees.\n \t// So we'll subtract the fee amount from the balance of the current\n-\t// initiator.\n-\tif lc.channelState.IsInitiator {\n+\t// initiator. If the initiator is unable to pay the fee fully, then\n+\t// their entire output is consumed.\n+\tswitch {\n+\tcase lc.channelState.IsInitiator && commitFee > ourBalance.ToSatoshis():\n+\t\tourBalance = 0\n+\n+\tcase lc.channelState.IsInitiator:\n \t\tourBalance -= lnwire.NewMSatFromSatoshis(commitFee)","path":"lnwallet/channel.go","position":null,"original_position":13,"commit_id":"6e69442511b866b56bc713b08fb9e32ddbfc6cba","original_commit_id":"868228ebb7be8f778f5acae44d77e5467e8a752e","user":{"login":"Roasbeef","id":998190,"avatar_url":"https://avatars3.githubusercontent.com/u/998190?v=4","gravatar_id":"","url":"https://api.github.com/users/Roasbeef","html_url":"https://github.com/Roasbeef","followers_url":"https://api.github.com/users/Roasbeef/followers","following_url":"https://api.github.com/users/Roasbeef/following{/other_user}","gists_url":"https://api.github.com/users/Roasbeef/gists{/gist_id}","starred_url":"https://api.github.com/users/Roasbeef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Roasbeef/subscriptions","organizations_url":"https://api.github.com/users/Roasbeef/orgs","repos_url":"https://api.github.com/users/Roasbeef/repos","events_url":"https://api.github.com/users/Roasbeef/events{/privacy}","received_events_url":"https://api.github.com/users/Roasbeef/received_events","type":"User","site_admin":false},"body":"Added. \r\n\r\nWe want to still compare in satoshis IMO as this is what will actually be manifested on the commitment transaction. ","created_at":"2018-03-06T19:50:37Z","updated_at":"2018-03-06T19:50:37Z","html_url":"https://github.com/lightningnetwork/lnd/pull/779#discussion_r172638839","pull_request_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/779","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments/172638839"},"html":{"href":"https://github.com/lightningnetwork/lnd/pull/779#discussion_r172638839"},"pull_request":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/779"}},"in_reply_to_id":171829700},"pull_request":{"url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/779","id":171210551,"html_url":"https://github.com/lightningnetwork/lnd/pull/779","diff_url":"https://github.com/lightningnetwork/lnd/pull/779.diff","patch_url":"https://github.com/lightningnetwork/lnd/pull/779.patch","issue_url":"https://api.github.com/repos/lightningnetwork/lnd/issues/779","number":779,"state":"open","locked":false,"title":"lnwire+lnwallet+htlcswitch: modify lnwire.MilliSatoshi to be unsigned, fix fee related bugs that emerged","user":{"login":"Roasbeef","id":998190,"avatar_url":"https://avatars3.githubusercontent.com/u/998190?v=4","gravatar_id":"","url":"https://api.github.com/users/Roasbeef","html_url":"https://github.com/Roasbeef","followers_url":"https://api.github.com/users/Roasbeef/followers","following_url":"https://api.github.com/users/Roasbeef/following{/other_user}","gists_url":"https://api.github.com/users/Roasbeef/gists{/gist_id}","starred_url":"https://api.github.com/users/Roasbeef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Roasbeef/subscriptions","organizations_url":"https://api.github.com/users/Roasbeef/orgs","repos_url":"https://api.github.com/users/Roasbeef/repos","events_url":"https://api.github.com/users/Roasbeef/events{/privacy}","received_events_url":"https://api.github.com/users/Roasbeef/received_events","type":"User","site_admin":false},"body":"In this PR, we correct a _minor_ deviation (with tangible ramifications) of our implementation from the specification. In the spec, all integers are unsigned unless otherwise state. However, our definition of `lnwire.MilliSatoshi` was an `int64`. As many of the other implementations used the equivalent of an `uint64`, users have been reporting certain compatibility issues due to this divergence. \r\n\r\nTo remedy this, we'll now properly use:\r\n```go\r\ntype MilliSatoshi uint64\r\n```\r\n\r\nOnce this initial change was made, a number of bugs emerged. Many of these weren't bugs under the existing logic as negative integers were possible, and the checks assumed so. Once we moved to unsigned integers, integer underflow went silently undetected. As a result, we've tightened up several consistency checks through the wallet, and the switch in order to ensure the same (at times even stronger) behavior is kept in place. \r\n\r\nFixes https://github.com/cdecker/lightning-integration/issues/11. ","created_at":"2018-02-25T03:26:16Z","updated_at":"2018-03-06T19:50:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"31e5ef536be13bee6ac78108ffdd4e4c4f2e7821","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":312148185,"url":"https://api.github.com/repos/lightningnetwork/lnd/labels/bug","name":"bug","color":"fc2929","default":true},{"id":431221659,"url":"https://api.github.com/repos/lightningnetwork/lnd/labels/wallet","name":"wallet","color":"5319e7","default":false},{"id":431221742,"url":"https://api.github.com/repos/lightningnetwork/lnd/labels/wire%20protocol","name":"wire protocol","color":"1d76db","default":false}],"milestone":{"url":"https://api.github.com/repos/lightningnetwork/lnd/milestones/5","html_url":"https://github.com/lightningnetwork/lnd/milestone/5","labels_url":"https://api.github.com/repos/lightningnetwork/lnd/milestones/5/labels","id":2725537,"number":5,"title":"v0.4-beta","description":"","creator":{"login":"Roasbeef","id":998190,"avatar_url":"https://avatars3.githubusercontent.com/u/998190?v=4","gravatar_id":"","url":"https://api.github.com/users/Roasbeef","html_url":"https://github.com/Roasbeef","followers_url":"https://api.github.com/users/Roasbeef/followers","following_url":"https://api.github.com/users/Roasbeef/following{/other_user}","gists_url":"https://api.github.com/users/Roasbeef/gists{/gist_id}","starred_url":"https://api.github.com/users/Roasbeef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Roasbeef/subscriptions","organizations_url":"https://api.github.com/users/Roasbeef/orgs","repos_url":"https://api.github.com/users/Roasbeef/repos","events_url":"https://api.github.com/users/Roasbeef/events{/privacy}","received_events_url":"https://api.github.com/users/Roasbeef/received_events","type":"User","site_admin":false},"open_issues":15,"closed_issues":15,"state":"open","created_at":"2017-08-27T22:11:13Z","updated_at":"2018-03-05T20:56:43Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/779/commits","review_comments_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/779/comments","review_comment_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lightningnetwork/lnd/issues/779/comments","statuses_url":"https://api.github.com/repos/lightningnetwork/lnd/statuses/6e69442511b866b56bc713b08fb9e32ddbfc6cba","head":{"label":"Roasbeef:unsigned-msat-and-fee-fixes","ref":"unsigned-msat-and-fee-fixes","sha":"6e69442511b866b56bc713b08fb9e32ddbfc6cba","user":{"login":"Roasbeef","id":998190,"avatar_url":"https://avatars3.githubusercontent.com/u/998190?v=4","gravatar_id":"","url":"https://api.github.com/users/Roasbeef","html_url":"https://github.com/Roasbeef","followers_url":"https://api.github.com/users/Roasbeef/followers","following_url":"https://api.github.com/users/Roasbeef/following{/other_user}","gists_url":"https://api.github.com/users/Roasbeef/gists{/gist_id}","starred_url":"https://api.github.com/users/Roasbeef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Roasbeef/subscriptions","organizations_url":"https://api.github.com/users/Roasbeef/orgs","repos_url":"https://api.github.com/users/Roasbeef/repos","events_url":"https://api.github.com/users/Roasbeef/events{/privacy}","received_events_url":"https://api.github.com/users/Roasbeef/received_events","type":"User","site_admin":false},"repo":{"id":112244823,"name":"lnd","full_name":"Roasbeef/lnd","owner":{"login":"Roasbeef","id":998190,"avatar_url":"https://avatars3.githubusercontent.com/u/998190?v=4","gravatar_id":"","url":"https://api.github.com/users/Roasbeef","html_url":"https://github.com/Roasbeef","followers_url":"https://api.github.com/users/Roasbeef/followers","following_url":"https://api.github.com/users/Roasbeef/following{/other_user}","gists_url":"https://api.github.com/users/Roasbeef/gists{/gist_id}","starred_url":"https://api.github.com/users/Roasbeef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Roasbeef/subscriptions","organizations_url":"https://api.github.com/users/Roasbeef/orgs","repos_url":"https://api.github.com/users/Roasbeef/repos","events_url":"https://api.github.com/users/Roasbeef/events{/privacy}","received_events_url":"https://api.github.com/users/Roasbeef/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Roasbeef/lnd","description":"Lightning Network Daemon ⚡️","fork":true,"url":"https://api.github.com/repos/Roasbeef/lnd","forks_url":"https://api.github.com/repos/Roasbeef/lnd/forks","keys_url":"https://api.github.com/repos/Roasbeef/lnd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Roasbeef/lnd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Roasbeef/lnd/teams","hooks_url":"https://api.github.com/repos/Roasbeef/lnd/hooks","issue_events_url":"https://api.github.com/repos/Roasbeef/lnd/issues/events{/number}","events_url":"https://api.github.com/repos/Roasbeef/lnd/events","assignees_url":"https://api.github.com/repos/Roasbeef/lnd/assignees{/user}","branches_url":"https://api.github.com/repos/Roasbeef/lnd/branches{/branch}","tags_url":"https://api.github.com/repos/Roasbeef/lnd/tags","blobs_url":"https://api.github.com/repos/Roasbeef/lnd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Roasbeef/lnd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Roasbeef/lnd/git/refs{/sha}","trees_url":"https://api.github.com/repos/Roasbeef/lnd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Roasbeef/lnd/statuses/{sha}","languages_url":"https://api.github.com/repos/Roasbeef/lnd/languages","stargazers_url":"https://api.github.com/repos/Roasbeef/lnd/stargazers","contributors_url":"https://api.github.com/repos/Roasbeef/lnd/contributors","subscribers_url":"https://api.github.com/repos/Roasbeef/lnd/subscribers","subscription_url":"https://api.github.com/repos/Roasbeef/lnd/subscription","commits_url":"https://api.github.com/repos/Roasbeef/lnd/commits{/sha}","git_commits_url":"https://api.github.com/repos/Roasbeef/lnd/git/commits{/sha}","comments_url":"https://api.github.com/repos/Roasbeef/lnd/comments{/number}","issue_comment_url":"https://api.github.com/repos/Roasbeef/lnd/issues/comments{/number}","contents_url":"https://api.github.com/repos/Roasbeef/lnd/contents/{+path}","compare_url":"https://api.github.com/repos/Roasbeef/lnd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Roasbeef/lnd/merges","archive_url":"https://api.github.com/repos/Roasbeef/lnd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Roasbeef/lnd/downloads","issues_url":"https://api.github.com/repos/Roasbeef/lnd/issues{/number}","pulls_url":"https://api.github.com/repos/Roasbeef/lnd/pulls{/number}","milestones_url":"https://api.github.com/repos/Roasbeef/lnd/milestones{/number}","notifications_url":"https://api.github.com/repos/Roasbeef/lnd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Roasbeef/lnd/labels{/name}","releases_url":"https://api.github.com/repos/Roasbeef/lnd/releases{/id}","deployments_url":"https://api.github.com/repos/Roasbeef/lnd/deployments","created_at":"2017-11-27T20:26:47Z","updated_at":"2017-11-27T20:26:49Z","pushed_at":"2018-03-06T19:49:48Z","git_url":"git://github.com/Roasbeef/lnd.git","ssh_url":"git@github.com:Roasbeef/lnd.git","clone_url":"https://github.com/Roasbeef/lnd.git","svn_url":"https://github.com/Roasbeef/lnd","homepage":"","size":12635,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"lightningnetwork:master","ref":"master","sha":"a1fb22eb8da4ffe2fa6e10169ede6758aca8d08a","user":{"login":"lightningnetwork","id":13424735,"avatar_url":"https://avatars0.githubusercontent.com/u/13424735?v=4","gravatar_id":"","url":"https://api.github.com/users/lightningnetwork","html_url":"https://github.com/lightningnetwork","followers_url":"https://api.github.com/users/lightningnetwork/followers","following_url":"https://api.github.com/users/lightningnetwork/following{/other_user}","gists_url":"https://api.github.com/users/lightningnetwork/gists{/gist_id}","starred_url":"https://api.github.com/users/lightningnetwork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lightningnetwork/subscriptions","organizations_url":"https://api.github.com/users/lightningnetwork/orgs","repos_url":"https://api.github.com/users/lightningnetwork/repos","events_url":"https://api.github.com/users/lightningnetwork/events{/privacy}","received_events_url":"https://api.github.com/users/lightningnetwork/received_events","type":"Organization","site_admin":false},"repo":{"id":49765480,"name":"lnd","full_name":"lightningnetwork/lnd","owner":{"login":"lightningnetwork","id":13424735,"avatar_url":"https://avatars0.githubusercontent.com/u/13424735?v=4","gravatar_id":"","url":"https://api.github.com/users/lightningnetwork","html_url":"https://github.com/lightningnetwork","followers_url":"https://api.github.com/users/lightningnetwork/followers","following_url":"https://api.github.com/users/lightningnetwork/following{/other_user}","gists_url":"https://api.github.com/users/lightningnetwork/gists{/gist_id}","starred_url":"https://api.github.com/users/lightningnetwork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lightningnetwork/subscriptions","organizations_url":"https://api.github.com/users/lightningnetwork/orgs","repos_url":"https://api.github.com/users/lightningnetwork/repos","events_url":"https://api.github.com/users/lightningnetwork/events{/privacy}","received_events_url":"https://api.github.com/users/lightningnetwork/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lightningnetwork/lnd","description":"Lightning Network Daemon ⚡️","fork":false,"url":"https://api.github.com/repos/lightningnetwork/lnd","forks_url":"https://api.github.com/repos/lightningnetwork/lnd/forks","keys_url":"https://api.github.com/repos/lightningnetwork/lnd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lightningnetwork/lnd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lightningnetwork/lnd/teams","hooks_url":"https://api.github.com/repos/lightningnetwork/lnd/hooks","issue_events_url":"https://api.github.com/repos/lightningnetwork/lnd/issues/events{/number}","events_url":"https://api.github.com/repos/lightningnetwork/lnd/events","assignees_url":"https://api.github.com/repos/lightningnetwork/lnd/assignees{/user}","branches_url":"https://api.github.com/repos/lightningnetwork/lnd/branches{/branch}","tags_url":"https://api.github.com/repos/lightningnetwork/lnd/tags","blobs_url":"https://api.github.com/repos/lightningnetwork/lnd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lightningnetwork/lnd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lightningnetwork/lnd/git/refs{/sha}","trees_url":"https://api.github.com/repos/lightningnetwork/lnd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lightningnetwork/lnd/statuses/{sha}","languages_url":"https://api.github.com/repos/lightningnetwork/lnd/languages","stargazers_url":"https://api.github.com/repos/lightningnetwork/lnd/stargazers","contributors_url":"https://api.github.com/repos/lightningnetwork/lnd/contributors","subscribers_url":"https://api.github.com/repos/lightningnetwork/lnd/subscribers","subscription_url":"https://api.github.com/repos/lightningnetwork/lnd/subscription","commits_url":"https://api.github.com/repos/lightningnetwork/lnd/commits{/sha}","git_commits_url":"https://api.github.com/repos/lightningnetwork/lnd/git/commits{/sha}","comments_url":"https://api.github.com/repos/lightningnetwork/lnd/comments{/number}","issue_comment_url":"https://api.github.com/repos/lightningnetwork/lnd/issues/comments{/number}","contents_url":"https://api.github.com/repos/lightningnetwork/lnd/contents/{+path}","compare_url":"https://api.github.com/repos/lightningnetwork/lnd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lightningnetwork/lnd/merges","archive_url":"https://api.github.com/repos/lightningnetwork/lnd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lightningnetwork/lnd/downloads","issues_url":"https://api.github.com/repos/lightningnetwork/lnd/issues{/number}","pulls_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls{/number}","milestones_url":"https://api.github.com/repos/lightningnetwork/lnd/milestones{/number}","notifications_url":"https://api.github.com/repos/lightningnetwork/lnd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lightningnetwork/lnd/labels{/name}","releases_url":"https://api.github.com/repos/lightningnetwork/lnd/releases{/id}","deployments_url":"https://api.github.com/repos/lightningnetwork/lnd/deployments","created_at":"2016-01-16T08:19:33Z","updated_at":"2018-03-06T14:55:15Z","pushed_at":"2018-03-06T19:49:50Z","git_url":"git://github.com/lightningnetwork/lnd.git","ssh_url":"git@github.com:lightningnetwork/lnd.git","clone_url":"https://github.com/lightningnetwork/lnd.git","svn_url":"https://github.com/lightningnetwork/lnd","homepage":"","size":11834,"stargazers_count":2084,"watchers_count":2084,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":437,"mirror_url":null,"archived":false,"open_issues_count":130,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":437,"open_issues":130,"watchers":2084,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/779"},"html":{"href":"https://github.com/lightningnetwork/lnd/pull/779"},"issue":{"href":"https://api.github.com/repos/lightningnetwork/lnd/issues/779"},"comments":{"href":"https://api.github.com/repos/lightningnetwork/lnd/issues/779/comments"},"review_comments":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/779/comments"},"review_comment":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/779/commits"},"statuses":{"href":"https://api.github.com/repos/lightningnetwork/lnd/statuses/6e69442511b866b56bc713b08fb9e32ddbfc6cba"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"Roasbeef"}}