Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

check for cashAdrr in isValidRecipient #286

Closed
wants to merge 1 commit into from

Conversation

valpinkman
Copy link
Member

No description provided.

@@ -17,6 +17,11 @@ export const isValidRecipient: F = withLibcoreF(core => async arg => {
return res;
}
const { currency, recipient } = arg;

if (recipient.startsWith("bitcoincash:")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO it's not enough to only test for the bitcoincash: prefix, especially since it collides with the URI scheme used in QR Codes (see #60 ):

  • A cashaddr QR formatted as bitcoincash:<addr> rather than bitcoincash:bitcoincash:<addr> would not be caught by this test
  • Wallets or websites omitting the bitcoincash: prefix or users only copying the last part of the address would not be caught either
  • On the other hand, implementations displaying a supported bitcoin addresses with the bitcoincash: URI scheme would trigger a not supported error

Copy link
Contributor

@gre gre Jun 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so technically it would still catch if you manually copy paste in that field. only the QR code scanning can have a problem.

I kinda wonder if we should just make the qrcode scanner preserving bitcoincash:* as the recipient, meaning we will not support bitcoincash:* as a "uri scheme" qrcode bit will assume it's an address part already

the code to modify would be in URIScheme

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regardless of the QR issue (the official specs require to not have a double prefix in this context btw), using CashAddr without prefix is not uncommon and should be handled: Bitcoin ABC own CashAddr announcement states:

Note the prefix “bitcoincash:”, which is technically always part of the address, although the prefix may be optional or missing entirely, depending on the wallet or the implementation.

EDIT: It's also in the specs: When presented to users, the prefix may be omitted

Why not use the reference bitcoincashjs lib to test the address format?
https://github.com/bitcoincashjs/bchaddrjs#test-for-address-format

Copy link
Contributor

@gre gre Jun 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's more libcore that should provide a way to do that. live-common is supposed to be as agnostic as possible & we will try to drop dep like ripple-lib and ethereumjs-tx

@gre
Copy link
Contributor

gre commented Mar 4, 2020

for internal discussion

@gre gre closed this Mar 4, 2020
@valpinkman valpinkman deleted the feat/cashadrr-error branch October 29, 2020 14:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants