File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
modules/abstract-utxo/src Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -415,10 +415,19 @@ export abstract class AbstractUtxoCoin extends BaseCoin {
415415 throw new Error ( 'deprecated' ) ;
416416 }
417417
418- const formats = utxolib . addressFormat . addressFormats . filter ( ( format ) =>
419- utxolib . addressFormat . isSupportedAddressFormat ( format , this . network )
420- ) ;
418+ // Default to anyFormat to true - if anyFormat is false then only check the default. Otherwise, check
419+ // all formats
420+ const anyFormat = ( param as { anyFormat : boolean | undefined } ) ?. anyFormat ;
421+ const formats =
422+ anyFormat === undefined || anyFormat
423+ ? utxolib . addressFormat . addressFormats . filter ( ( format ) =>
424+ utxolib . addressFormat . isSupportedAddressFormat ( format , this . network )
425+ )
426+ : [ 'default' as const ] ;
427+
421428 try {
429+ // To make sure that we are preserving `fromOutputScript(script, network) === address`, we need to do the
430+ // circular check below. An example of something that this protects against is uppercase Bech32.
422431 const script = utxolib . addressFormat . toOutputScriptTryFormats ( address , this . network , formats ) ;
423432 const genAddresses = formats . map ( ( format ) =>
424433 utxolib . addressFormat . fromOutputScriptWithFormat ( script , format , this . network )
You can’t perform that action at this time.
0 commit comments