diff --git a/modules/abstract-utxo/src/abstractUtxoCoin.ts b/modules/abstract-utxo/src/abstractUtxoCoin.ts index 1b08585bc5..d06d0032f3 100644 --- a/modules/abstract-utxo/src/abstractUtxoCoin.ts +++ b/modules/abstract-utxo/src/abstractUtxoCoin.ts @@ -530,6 +530,7 @@ export abstract class AbstractUtxoCoin } /** + * @deprecated - will be removed when we drop support for utxolib * Determine an address' type based on its witness and redeem script presence * @param addressDetails */ @@ -703,7 +704,6 @@ export abstract class AbstractUtxoCoin address, keychains, format: params.format ?? 'base58', - addressType: params.addressType, chain, index, }); diff --git a/modules/abstract-utxo/src/address/fixedScript.ts b/modules/abstract-utxo/src/address/fixedScript.ts index 56c7462f01..4f5bc372ea 100644 --- a/modules/abstract-utxo/src/address/fixedScript.ts +++ b/modules/abstract-utxo/src/address/fixedScript.ts @@ -24,7 +24,6 @@ export interface FixedScriptAddressCoinSpecific { } export interface GenerateAddressOptions { - addressType?: ScriptType2Of3; chain?: number; index?: number; segwit?: boolean; @@ -98,7 +97,7 @@ export function generateAddress(coinName: UtxoCoinName, params: GenerateFixedScr } } - const addressType = normalizeScriptType(params.addressType || convertFlagsToAddressType()); + const addressType = normalizeScriptType(convertFlagsToAddressType()); if (addressType !== fixedScriptWallet.ChainCode.scriptType(derivationChain)) { throw new AddressTypeChainMismatchError(addressType, derivationChain); @@ -146,14 +145,12 @@ export function assertFixedScriptWalletAddress( index, keychains, format, - addressType, address, }: { chain: number | undefined; index: number; keychains: Keychain[]; format: CreateAddressFormat; - addressType: string | undefined; address: string; } ): void { @@ -169,7 +166,6 @@ export function assertFixedScriptWalletAddress( const expectedAddress = generateAddress(coinName, { format, - addressType: addressType as ScriptType2Of3, keychains, chain, index, diff --git a/modules/abstract-utxo/src/transaction/fixedScript/parseOutput.ts b/modules/abstract-utxo/src/transaction/fixedScript/parseOutput.ts index a3b0186d88..c48fc2600a 100644 --- a/modules/abstract-utxo/src/transaction/fixedScript/parseOutput.ts +++ b/modules/abstract-utxo/src/transaction/fixedScript/parseOutput.ts @@ -71,7 +71,6 @@ function isMigratedAddress(wallet: IWallet, currentAddress: string): boolean { interface VerifyCustomChangeAddressOptions { coin: AbstractUtxoCoin; customChangeKeys: HandleVerifyAddressErrorOptions['customChangeKeys']; - addressType: HandleVerifyAddressErrorOptions['addressType']; addressDetails: HandleVerifyAddressErrorOptions['addressDetails']; currentAddress: HandleVerifyAddressErrorOptions['currentAddress']; } @@ -82,10 +81,10 @@ interface VerifyCustomChangeAddressOptions { * @return {boolean} */ async function verifyCustomChangeAddress(params: VerifyCustomChangeAddressOptions): Promise { - const { coin, customChangeKeys, addressType, addressDetails, currentAddress } = params; + const { coin, customChangeKeys, addressDetails, currentAddress } = params; try { return await coin.verifyAddress( - _.extend({ addressType }, addressDetails, { + _.extend({}, addressDetails, { keychains: customChangeKeys, address: currentAddress, }) @@ -106,7 +105,6 @@ interface HandleVerifyAddressErrorOptions { customChangeKeys?: CustomChangeOptions['keys']; coin: AbstractUtxoCoin; addressDetails?: any; - addressType?: string; considerMigratedFromAddressInternal?: boolean; } @@ -118,7 +116,6 @@ async function handleVerifyAddressError({ customChangeKeys, coin, addressDetails, - addressType, considerMigratedFromAddressInternal, }: HandleVerifyAddressErrorOptions): Promise { // Todo: name server-side errors to avoid message-based checking [BG-5124] @@ -137,7 +134,7 @@ async function handleVerifyAddressError({ // attempt to verify address using custom change address keys if the wallet has that feature enabled if ( customChangeKeys && - (await verifyCustomChangeAddress({ coin, addressDetails, addressType, currentAddress, customChangeKeys })) + (await verifyCustomChangeAddress({ coin, addressDetails, currentAddress, customChangeKeys })) ) { // address is valid against the custom change keys. Mark address as not external // and request signature verification for the custom change keys @@ -239,7 +236,6 @@ export async function parseOutput({ const addressDetailsVerification: AddressVerificationData = verification?.addresses?.[currentAddress] ?? {}; debug('Parsing address details for %s', currentAddress); let currentAddressDetails = undefined; - let currentAddressType: string | undefined = undefined; const RECIPIENT_THRESHOLD = 1000; try { // In the case of PSBTs, we can already determine the internal/external status of the output addresses @@ -256,7 +252,6 @@ export async function parseOutput({ // can just return the current output as is without contacting the server. if (isWalletOutput(currentOutput)) { const res = await coin.isWalletAddress({ - addressType: AbstractUtxoCoin.inferAddressType({ chain: currentOutput.chain }) || undefined, keychains: keychainArray, address: currentAddress, chain: currentOutput.chain, @@ -305,10 +300,9 @@ export async function parseOutput({ }); // verify that the address is on the wallet. verifyAddress throws if // it fails to correctly rederive the address, meaning it's external - currentAddressType = AbstractUtxoCoin.inferAddressType(addressDetails) || undefined; currentAddressDetails = addressDetails; await coin.verifyAddress( - _.extend({ addressType: currentAddressType }, addressDetails, { + _.extend({}, addressDetails, { keychains: keychainArray, address: currentAddress, }) @@ -331,7 +325,6 @@ export async function parseOutput({ txParams, customChangeKeys: customChange && customChange.keys, addressDetails: currentAddressDetails, - addressType: currentAddressType, considerMigratedFromAddressInternal: verification.considerMigratedFromAddressInternal, }) );