How to use the bitcore-lib-cash.URI function in bitcore-lib-cash

To help you get started, we’ve selected a few bitcore-lib-cash examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bitpay / bitcore / packages / crypto-wallet-core / src / validation / bch / index.ts View on Github external
validateAddress(network: string, address: string): boolean {
      // Check if the input is a valid uri or address
      const URICash = BitcoreCash.URI;
      const AddressCash = BitcoreCash.Address;

       // Bip21 uri
      let uri, uriAddress;
      if (/^bitcoincash:|^bchtest:i/.test(address)) {
        if (URICash.isValid(address)) {
          uri = new URICash(address);
          uriAddress = uri.address.toString();
          return AddressCash.isValid(uriAddress, network);
        }
      }

       // Regular Address: try Bitcoin Cash
      return AddressCash.isValid(address, network);
    }
}