{"action":"created","comment":{"url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments/167388445","pull_request_review_id":95611718,"id":167388445,"diff_hunk":"@@ -1012,3 +1026,46 @@ func uint64ToBase32(num uint64) []byte {\n \t// We only return non-zero leading groups.\n \treturn arr[i:]\n }\n+\n+// LtcToBtcParams applies the relevant chain configuration parameters that\n+// differ for litecoin similar to chainparams.applyLiteCoinParams(). This\n+// function is used in place of an interface to abstract over which chain\n+// the parameters are for.\n+func LtcToBtcParams(params *litecoinCfg.Params) *chaincfg.Params {","path":"zpay32/invoice.go","position":59,"original_position":59,"commit_id":"86ee8178c05609bdeb0490357b530abea7354f21","original_commit_id":"86ee8178c05609bdeb0490357b530abea7354f21","user":{"login":"halseth","id":3765732,"avatar_url":"https://avatars1.githubusercontent.com/u/3765732?v=4","gravatar_id":"","url":"https://api.github.com/users/halseth","html_url":"https://github.com/halseth","followers_url":"https://api.github.com/users/halseth/followers","following_url":"https://api.github.com/users/halseth/following{/other_user}","gists_url":"https://api.github.com/users/halseth/gists{/gist_id}","starred_url":"https://api.github.com/users/halseth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/halseth/subscriptions","organizations_url":"https://api.github.com/users/halseth/orgs","repos_url":"https://api.github.com/users/halseth/repos","events_url":"https://api.github.com/users/halseth/events{/privacy}","received_events_url":"https://api.github.com/users/halseth/received_events","type":"User","site_admin":false},"body":"The problem with decoding without passing in the known networks, is that you need to add a new entry (possibly more: mainnet, simnet, testnet, regtest etc) to the switch statement for each new network. Having it just check again the passed known ones would be simpler. (And safer? Making sure the software is able to understand the invoice)\r\n\r\nChecking against the active networks would be similar, but is not really something we can easily do at the moment (since it is assumed only one network is active). Passing in known network would let us pass in the one active network for now, and just pass in the active networks in the future.","created_at":"2018-02-10T03:57:57Z","updated_at":"2018-02-10T03:57:57Z","html_url":"https://github.com/lightningnetwork/lnd/pull/625#discussion_r167388445","pull_request_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/625","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments/167388445"},"html":{"href":"https://github.com/lightningnetwork/lnd/pull/625#discussion_r167388445"},"pull_request":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/625"}},"in_reply_to_id":165850271},"pull_request":{"url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/625","id":163784976,"html_url":"https://github.com/lightningnetwork/lnd/pull/625","diff_url":"https://github.com/lightningnetwork/lnd/pull/625.diff","patch_url":"https://github.com/lightningnetwork/lnd/pull/625.patch","issue_url":"https://api.github.com/repos/lightningnetwork/lnd/issues/625","number":625,"state":"open","locked":false,"title":"Decode litecoin invoices & handle segwit prefixes > 2 chars","user":{"login":"sangaman","id":3440835,"avatar_url":"https://avatars1.githubusercontent.com/u/3440835?v=4","gravatar_id":"","url":"https://api.github.com/users/sangaman","html_url":"https://github.com/sangaman","followers_url":"https://api.github.com/users/sangaman/followers","following_url":"https://api.github.com/users/sangaman/following{/other_user}","gists_url":"https://api.github.com/users/sangaman/gists{/gist_id}","starred_url":"https://api.github.com/users/sangaman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sangaman/subscriptions","organizations_url":"https://api.github.com/users/sangaman/orgs","repos_url":"https://api.github.com/users/sangaman/repos","events_url":"https://api.github.com/users/sangaman/events{/privacy}","received_events_url":"https://api.github.com/users/sangaman/received_events","type":"User","site_admin":false},"body":"I attempted to solve the bug described in #430, I think the fix works properly but I struggled to set up the tests and could use some assistance with that. \r\n\r\nThe length of the Bech32HRPSegwit network parameter is used to determine where in the human-readable portion of the invoice the amount begins, rather than assuming it begins after the first four characters. I reused the `ltcToBtcParams()` function from the swapz branch by @cfromknecht (which in turn was adapted from the `applyLitecoinParams()` method in chainparams.go) to apply litecoin parameters to the btcd/chaincfg object, but I think the cleaner and more maintainable approach is to create an interface for chain configurations and use that everywhere btcd/chaincfg is used currently. That would touch the code in a lot of places, but I think I know what needs to happen and maybe I could work on that for a separate PR.\r\n\r\nIn my own testing I was able to call `decodepayreq` on invoices starting with \"lntltc\" I generated in lnd with `litecoin.active` set - I got back the values I'd expect including the amount. I spent a while on trying to set up test cases in invoice_test.go but hit a wall. I got as far as being able to successfully decode the invoice string and match the decoded values to the ones I provided, but the reencoded invoice doesn't match the original invoice string (for now I set `skipEncoding` to true so the test passes). I also wasn't able to figure out how I could create new invoice strings using the `testPubKey` and `testPaymentHash` that were already hardcoded, so I created my own variables. Any input on what I might be doing wrong would be greatly appreciated.","created_at":"2018-01-18T18:16:07Z","updated_at":"2018-02-10T03:57:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b05a65685b2fde4c46a50671e17bd0a7303119cd","assignee":null,"assignees":[],"requested_reviewers":[{"login":"cfromknecht","id":2013993,"avatar_url":"https://avatars1.githubusercontent.com/u/2013993?v=4","gravatar_id":"","url":"https://api.github.com/users/cfromknecht","html_url":"https://github.com/cfromknecht","followers_url":"https://api.github.com/users/cfromknecht/followers","following_url":"https://api.github.com/users/cfromknecht/following{/other_user}","gists_url":"https://api.github.com/users/cfromknecht/gists{/gist_id}","starred_url":"https://api.github.com/users/cfromknecht/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfromknecht/subscriptions","organizations_url":"https://api.github.com/users/cfromknecht/orgs","repos_url":"https://api.github.com/users/cfromknecht/repos","events_url":"https://api.github.com/users/cfromknecht/events{/privacy}","received_events_url":"https://api.github.com/users/cfromknecht/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/625/commits","review_comments_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/625/comments","review_comment_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lightningnetwork/lnd/issues/625/comments","statuses_url":"https://api.github.com/repos/lightningnetwork/lnd/statuses/86ee8178c05609bdeb0490357b530abea7354f21","head":{"label":"sangaman:master","ref":"master","sha":"86ee8178c05609bdeb0490357b530abea7354f21","user":{"login":"sangaman","id":3440835,"avatar_url":"https://avatars1.githubusercontent.com/u/3440835?v=4","gravatar_id":"","url":"https://api.github.com/users/sangaman","html_url":"https://github.com/sangaman","followers_url":"https://api.github.com/users/sangaman/followers","following_url":"https://api.github.com/users/sangaman/following{/other_user}","gists_url":"https://api.github.com/users/sangaman/gists{/gist_id}","starred_url":"https://api.github.com/users/sangaman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sangaman/subscriptions","organizations_url":"https://api.github.com/users/sangaman/orgs","repos_url":"https://api.github.com/users/sangaman/repos","events_url":"https://api.github.com/users/sangaman/events{/privacy}","received_events_url":"https://api.github.com/users/sangaman/received_events","type":"User","site_admin":false},"repo":{"id":117605507,"name":"lnd","full_name":"sangaman/lnd","owner":{"login":"sangaman","id":3440835,"avatar_url":"https://avatars1.githubusercontent.com/u/3440835?v=4","gravatar_id":"","url":"https://api.github.com/users/sangaman","html_url":"https://github.com/sangaman","followers_url":"https://api.github.com/users/sangaman/followers","following_url":"https://api.github.com/users/sangaman/following{/other_user}","gists_url":"https://api.github.com/users/sangaman/gists{/gist_id}","starred_url":"https://api.github.com/users/sangaman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sangaman/subscriptions","organizations_url":"https://api.github.com/users/sangaman/orgs","repos_url":"https://api.github.com/users/sangaman/repos","events_url":"https://api.github.com/users/sangaman/events{/privacy}","received_events_url":"https://api.github.com/users/sangaman/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sangaman/lnd","description":"Lightning Network Daemon ⚡️","fork":true,"url":"https://api.github.com/repos/sangaman/lnd","forks_url":"https://api.github.com/repos/sangaman/lnd/forks","keys_url":"https://api.github.com/repos/sangaman/lnd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sangaman/lnd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sangaman/lnd/teams","hooks_url":"https://api.github.com/repos/sangaman/lnd/hooks","issue_events_url":"https://api.github.com/repos/sangaman/lnd/issues/events{/number}","events_url":"https://api.github.com/repos/sangaman/lnd/events","assignees_url":"https://api.github.com/repos/sangaman/lnd/assignees{/user}","branches_url":"https://api.github.com/repos/sangaman/lnd/branches{/branch}","tags_url":"https://api.github.com/repos/sangaman/lnd/tags","blobs_url":"https://api.github.com/repos/sangaman/lnd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sangaman/lnd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sangaman/lnd/git/refs{/sha}","trees_url":"https://api.github.com/repos/sangaman/lnd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sangaman/lnd/statuses/{sha}","languages_url":"https://api.github.com/repos/sangaman/lnd/languages","stargazers_url":"https://api.github.com/repos/sangaman/lnd/stargazers","contributors_url":"https://api.github.com/repos/sangaman/lnd/contributors","subscribers_url":"https://api.github.com/repos/sangaman/lnd/subscribers","subscription_url":"https://api.github.com/repos/sangaman/lnd/subscription","commits_url":"https://api.github.com/repos/sangaman/lnd/commits{/sha}","git_commits_url":"https://api.github.com/repos/sangaman/lnd/git/commits{/sha}","comments_url":"https://api.github.com/repos/sangaman/lnd/comments{/number}","issue_comment_url":"https://api.github.com/repos/sangaman/lnd/issues/comments{/number}","contents_url":"https://api.github.com/repos/sangaman/lnd/contents/{+path}","compare_url":"https://api.github.com/repos/sangaman/lnd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sangaman/lnd/merges","archive_url":"https://api.github.com/repos/sangaman/lnd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sangaman/lnd/downloads","issues_url":"https://api.github.com/repos/sangaman/lnd/issues{/number}","pulls_url":"https://api.github.com/repos/sangaman/lnd/pulls{/number}","milestones_url":"https://api.github.com/repos/sangaman/lnd/milestones{/number}","notifications_url":"https://api.github.com/repos/sangaman/lnd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sangaman/lnd/labels{/name}","releases_url":"https://api.github.com/repos/sangaman/lnd/releases{/id}","deployments_url":"https://api.github.com/repos/sangaman/lnd/deployments","created_at":"2018-01-15T23:15:05Z","updated_at":"2018-01-15T23:15:08Z","pushed_at":"2018-02-04T16:16:51Z","git_url":"git://github.com/sangaman/lnd.git","ssh_url":"git@github.com:sangaman/lnd.git","clone_url":"https://github.com/sangaman/lnd.git","svn_url":"https://github.com/sangaman/lnd","homepage":"","size":11151,"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":"a8728ccb5ba2905ca7308a5c7a6f45e49951c76c","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-02-10T03:19:28Z","pushed_at":"2018-02-10T03:09:29Z","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":11386,"stargazers_count":1942,"watchers_count":1942,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":398,"mirror_url":null,"archived":false,"open_issues_count":124,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":398,"open_issues":124,"watchers":1942,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/625"},"html":{"href":"https://github.com/lightningnetwork/lnd/pull/625"},"issue":{"href":"https://api.github.com/repos/lightningnetwork/lnd/issues/625"},"comments":{"href":"https://api.github.com/repos/lightningnetwork/lnd/issues/625/comments"},"review_comments":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/625/comments"},"review_comment":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/625/commits"},"statuses":{"href":"https://api.github.com/repos/lightningnetwork/lnd/statuses/86ee8178c05609bdeb0490357b530abea7354f21"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"halseth"}}