File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -415,10 +415,15 @@ export abstract class AbstractUtxoCoin extends BaseCoin {
415415 throw new Error ( 'deprecated' ) ;
416416 }
417417
418- const formats = param && param . anyFormat ? undefined : [ 'default' as const ] ;
418+ const formats = utxolib . addressFormat . addressFormats . filter ( ( format ) =>
419+ utxolib . addressFormat . isSupportedAddressFormat ( format , this . network )
420+ ) ;
419421 try {
420422 const script = utxolib . addressFormat . toOutputScriptTryFormats ( address , this . network , formats ) ;
421- return address === utxolib . address . fromOutputScript ( script , this . network ) ;
423+ const genAddresses = formats . map ( ( format ) =>
424+ utxolib . addressFormat . fromOutputScriptWithFormat ( script , format , this . network )
425+ ) ;
426+ return genAddresses . includes ( address ) ;
422427 } catch ( e ) {
423428 return false ;
424429 }
Original file line number Diff line number Diff line change @@ -242,6 +242,18 @@ describe('V2 Wallet:', function () {
242242 } ) ;
243243 } ) ;
244244
245+ it ( 'should verify bch cashaddr format as valid' , async function ( ) {
246+ const coin = bitgo . coin ( 'tbch' ) ;
247+ const valid = coin . isValidAddress ( 'bchtest:pzfkxv532t0q5zchck2mhmmf2y02cdejyssq5qrz7a' ) ;
248+ valid . should . be . True ( ) ;
249+ } ) ;
250+
251+ it ( 'should verify bch legacy format as valid' , async function ( ) {
252+ const coin = bitgo . coin ( 'tbch' ) ;
253+ const valid = coin . isValidAddress ( '2N6gY9r9iuXQQzZiSyngWJeoUuL5mC1x4Ac' ) ;
254+ valid . should . be . True ( ) ;
255+ } ) ;
256+
245257 describe ( 'TETH Wallet Addresses' , function ( ) {
246258 let ethWallet ;
247259
You can’t perform that action at this time.
0 commit comments