{"action":"created","issue":{"url":"https://api.github.com/repos/bitcoinj/bitcoinj/issues/1222","repository_url":"https://api.github.com/repos/bitcoinj/bitcoinj","labels_url":"https://api.github.com/repos/bitcoinj/bitcoinj/issues/1222/labels{/name}","comments_url":"https://api.github.com/repos/bitcoinj/bitcoinj/issues/1222/comments","events_url":"https://api.github.com/repos/bitcoinj/bitcoinj/issues/1222/events","html_url":"https://github.com/bitcoinj/bitcoinj/pull/1222","id":140508276,"number":1222,"title":"complete SigHash enum and make updates to stop using ordinal","user":{"login":"mruddy","id":6440430,"avatar_url":"https://avatars.githubusercontent.com/u/6440430?v=3","gravatar_id":"","url":"https://api.github.com/users/mruddy","html_url":"https://github.com/mruddy","followers_url":"https://api.github.com/users/mruddy/followers","following_url":"https://api.github.com/users/mruddy/following{/other_user}","gists_url":"https://api.github.com/users/mruddy/gists{/gist_id}","starred_url":"https://api.github.com/users/mruddy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mruddy/subscriptions","organizations_url":"https://api.github.com/users/mruddy/orgs","repos_url":"https://api.github.com/users/mruddy/repos","events_url":"https://api.github.com/users/mruddy/events{/privacy}","received_events_url":"https://api.github.com/users/mruddy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-13T17:26:05Z","updated_at":"2016-03-23T12:17:58Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/bitcoinj/bitcoinj/pulls/1222","html_url":"https://github.com/bitcoinj/bitcoinj/pull/1222","diff_url":"https://github.com/bitcoinj/bitcoinj/pull/1222.diff","patch_url":"https://github.com/bitcoinj/bitcoinj/pull/1222.patch"},"body":"Complete the SigHash enum and make updates to stop using the enum's ordinal while preserving the original ordinal value for any existing code that might use it.\r\n\r\nIn my own code, I found that I was using an enum defined like below. The changes in this PR, deviate slightly from my original code in order to preserve the ordinal values of the original bitcoinj enum should any external code depend on it still. All in all, I think these changes make the SigHash enum more complete and make the code a little easier to read (less brittle with the removal of the ordinal dependency in the core code) with fewer casts. Let me know if I missed something, but I think my references checks were pretty complete and all the bitcoinj projects still compile and pass tests.\r\n\r\n```\r\npublic enum Sighash {\r\n  UNSET(0), ALL(1), NONE(2), SINGLE(3), ANYONECANPAY(0x80), ANYONECANPAY_ALL(0x81), ANYONECANPAY_NONE(0x82), ANYONECANPAY_SINGLE(0x83);\r\n  private final int type;\r\n\r\n  /**\r\n   * @param type\r\n   */\r\n  private Sighash(final int type) {\r\n    this.type = type;\r\n  }\r\n\r\n  /**\r\n   * @return the type as a byte\r\n   */\r\n  public byte byteValue() {\r\n    return (byte) this.type;\r\n  }\r\n\r\n  /**\r\n   * @return the type\r\n   */\r\n  public int intValue() {\r\n    return this.type;\r\n  }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/bitcoinj/bitcoinj/issues/comments/200325840","html_url":"https://github.com/bitcoinj/bitcoinj/pull/1222#issuecomment-200325840","issue_url":"https://api.github.com/repos/bitcoinj/bitcoinj/issues/1222","id":200325840,"user":{"login":"schildbach","id":743306,"avatar_url":"https://avatars.githubusercontent.com/u/743306?v=3","gravatar_id":"","url":"https://api.github.com/users/schildbach","html_url":"https://github.com/schildbach","followers_url":"https://api.github.com/users/schildbach/followers","following_url":"https://api.github.com/users/schildbach/following{/other_user}","gists_url":"https://api.github.com/users/schildbach/gists{/gist_id}","starred_url":"https://api.github.com/users/schildbach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schildbach/subscriptions","organizations_url":"https://api.github.com/users/schildbach/orgs","repos_url":"https://api.github.com/users/schildbach/repos","events_url":"https://api.github.com/users/schildbach/events{/privacy}","received_events_url":"https://api.github.com/users/schildbach/received_events","type":"User","site_admin":false},"created_at":"2016-03-23T12:17:58Z","updated_at":"2016-03-23T12:17:58Z","body":"I'm fine with embedding the value into the enum. I'm not so sure about the new enum values, isn't ANYONECANPAY more like a flag? Finally, I'd make `private final int type;` public, so the `intValue()` method isn't needed."}}