I'm trying to post to ZECpages, but Nighthawk wallet doesn't like the QR codes, which are ZIP321 URIs which contain valid zcash addresses. Nighthawk gives me the following error:
"This QR code does not contain a Zcash valid address!"
I've talked with Aditya about this, I know this is on your radar, but I thought it wise to document it here. These URI's have really helped streamline ZECpages' interface, and it'd be great to have them supported in your wallet!
Tiny, comparatively unimportant aside - I think the error message is incorrect and also too alarming. I think a more precise message (in the current implementation) would be "Zcash address not recognized"
EDIT:
Here's a js example. It's surely bulky and under engineered but it works
function parseZaddrOrUri(str) {
str = str.replace(/ /g, "") // strip whitespace just to be thorough
let amount = 0;
let zaddr = "";
let memo = "";
const zaddrRegex = /(zs\w{76})/;
const uriRegex2 = /(zcash:zs\w{76})/;
const isValid = zaddrRegex.test(str) || uriRegex.test(str)
if (!isValid) return {error: "Address/URI not recognized."}
const memoMatch = str.match(/(memo=([^&]*))/);
const amountMatch = str.match(/(amount=([^&]*))/);
const zaddrMatch = str.match(zaddrRegex);
if (memoMatch) memo = memoMatch[2]
if (amountMatch) amount = amountMatch[2]
if (zaddrMatch) zaddr = zaddrMatch[0]
return {memo, amount, zaddr}
}
Some manual tests - I think these are all the permutations you have to handle.
var str = "zcash:zs19dedmnrkhq2pth3jp3cnn6c5jqshnu9ss2fljllm9l0tlgqw0mtpvs9207ecywwtmx7wkrvksvn?amount=0.001&memo=memobase64"
var str2 = "zcash:zs19dedmnrkhq2pth3jp3cnn6c5jqshnu9ss2fljllm9l0tlgqw0mtpvs9207ecywwtmx7wkrvksvn?memo=memobase64"
var str3 = "zcash:zs19dedmnrkhq2pth3jp3cnn6c5jqshnu9ss2fljllm9l0tlgqw0mtpvs9207ecywwtmx7wkrvksvn?amount=0.001"
var str4 = "zcash:zs19dedmnrkhq2pth3jp3cnn6c5jqshnu9ss2fljllm9l0tlgqw0mtpvs9207ecywwtmx7wkrvksvn"
var str5 = "zs19dedmnrkhq2pth3jp3cnn6c5jqshnu9ss2fljllm9l0tlgqw0mtpvs9207ecywwtmx7wkrvksvn"
console.log(parseZaddrOrUri(str))
console.log(parseZaddrOrUri(str2))
console.log(parseZaddrOrUri(str3))
console.log(parseZaddrOrUri(str4))
console.log(parseZaddrOrUri(str5))
Platform: iPhone 8
I'm trying to post to ZECpages, but Nighthawk wallet doesn't like the QR codes, which are ZIP321 URIs which contain valid zcash addresses. Nighthawk gives me the following error:
"This QR code does not contain a Zcash valid address!"
I've talked with Aditya about this, I know this is on your radar, but I thought it wise to document it here. These URI's have really helped streamline ZECpages' interface, and it'd be great to have them supported in your wallet!
Tiny, comparatively unimportant aside - I think the error message is incorrect and also too alarming. I think a more precise message (in the current implementation) would be "Zcash address not recognized"
EDIT: Here's a js example. It's surely bulky and under engineered but it works
Some manual tests - I think these are all the permutations you have to handle.