{"action":"created","issue":{"url":"https://api.github.com/repos/bitcoinj/bitcoinj/issues/1075","labels_url":"https://api.github.com/repos/bitcoinj/bitcoinj/issues/1075/labels{/name}","comments_url":"https://api.github.com/repos/bitcoinj/bitcoinj/issues/1075/comments","events_url":"https://api.github.com/repos/bitcoinj/bitcoinj/issues/1075/events","html_url":"https://github.com/bitcoinj/bitcoinj/pull/1075","id":103844874,"number":1075,"title":"Close increasePaymentFuture when receiving an ERROR from the server.","user":{"login":"ollekullberg","id":201249,"avatar_url":"https://avatars.githubusercontent.com/u/201249?v=3","gravatar_id":"","url":"https://api.github.com/users/ollekullberg","html_url":"https://github.com/ollekullberg","followers_url":"https://api.github.com/users/ollekullberg/followers","following_url":"https://api.github.com/users/ollekullberg/following{/other_user}","gists_url":"https://api.github.com/users/ollekullberg/gists{/gist_id}","starred_url":"https://api.github.com/users/ollekullberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ollekullberg/subscriptions","organizations_url":"https://api.github.com/users/ollekullberg/orgs","repos_url":"https://api.github.com/users/ollekullberg/repos","events_url":"https://api.github.com/users/ollekullberg/events{/privacy}","received_events_url":"https://api.github.com/users/ollekullberg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-29T10:57:37Z","updated_at":"2015-09-08T08:46:04Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/bitcoinj/bitcoinj/pulls/1075","html_url":"https://github.com/bitcoinj/bitcoinj/pull/1075","diff_url":"https://github.com/bitcoinj/bitcoinj/pull/1075.diff","patch_url":"https://github.com/bitcoinj/bitcoinj/pull/1075.patch"},"body":"In PaymentChannelClient we have a future:\r\n\r\n   @GuardedBy(\"lock\") SettableFuture<PaymentIncrementAck> increasePaymentFuture;\r\n\r\n... and this future is used by incrementPayment(). When PAYMENT_ACK is returned from the serve the increasePaymentFuture is updated correctly. This PR makes sure the increasePaymentFuture is set even if the server returns an error."},"comment":{"url":"https://api.github.com/repos/bitcoinj/bitcoinj/issues/comments/138481667","html_url":"https://github.com/bitcoinj/bitcoinj/pull/1075#issuecomment-138481667","issue_url":"https://api.github.com/repos/bitcoinj/bitcoinj/issues/1075","id":138481667,"user":{"login":"ollekullberg","id":201249,"avatar_url":"https://avatars.githubusercontent.com/u/201249?v=3","gravatar_id":"","url":"https://api.github.com/users/ollekullberg","html_url":"https://github.com/ollekullberg","followers_url":"https://api.github.com/users/ollekullberg/followers","following_url":"https://api.github.com/users/ollekullberg/following{/other_user}","gists_url":"https://api.github.com/users/ollekullberg/gists{/gist_id}","starred_url":"https://api.github.com/users/ollekullberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ollekullberg/subscriptions","organizations_url":"https://api.github.com/users/ollekullberg/orgs","repos_url":"https://api.github.com/users/ollekullberg/repos","events_url":"https://api.github.com/users/ollekullberg/events{/privacy}","received_events_url":"https://api.github.com/users/ollekullberg/received_events","type":"User","site_admin":false},"created_at":"2015-09-08T08:46:03Z","updated_at":"2015-09-08T08:46:03Z","body":"Strange, works for me. I even did this TDD style, began with a failing test and got it to work by adding the fix. Now when re-reading the code I can only find one error, and that's that I should have used lock when updating the future: \r\n\r\n    private void setIncreasePaymentFutureIfNeeded(PaymentChannelCloseException.CloseReason reason, String message) {\r\n        if (increasePaymentFuture != null && !increasePaymentFuture.isDone()) {\r\n            lock.lock();\r\n            try {\r\n                increasePaymentFuture.setException(new PaymentChannelCloseException(message, reason));\r\n            } finally {\r\n                lock.unlock();\r\n            }\r\n        }\r\n    }\r\n\r\nI will add the lock, but I don't think it's the problem you're facing. When I run the test I get the following output at the end. The last log is telling me that bitcoinj actually received the ERROR. Do you get the same logs?\r\n \r\n    10:37:03 1 PaymentChannelClientState.incrementPaymentBy: Signing new payment tx   eb9784450b91bf34f135dd6455df609f36df11d422b146a70c00be6bf8709361: Unknown confidence level.\r\n     in    1.00 BTC\r\n          outpoint:a7ac3929b3fd0d5f3d1aca8f52268ff87973e6081782eb64c8b9cb9528f0e314:0\r\n     out  DUP HASH160 PUSHDATA(20)[8a1bb17e580ae94e631aa145e855dd4e81f04cd4] EQUALVERIFY CHECKSIG 0.98999 BTC\r\n     fee  0.01001 BTC\r\n\r\n    10:37:03 1 StoredPaymentChannelClientStates.updatedChannel: Stored client channel 31959752 was updated\r\n    10:37:03 1 PaymentChannelClient.receiveMessage: Server sent ERROR CHANNEL_VALUE_TOO_LARGE with explanation "}}