Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/abstract-utxo/src/abstractUtxoCoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -703,7 +704,6 @@ export abstract class AbstractUtxoCoin
address,
keychains,
format: params.format ?? 'base58',
addressType: params.addressType,
chain,
index,
});
Expand Down
6 changes: 1 addition & 5 deletions modules/abstract-utxo/src/address/fixedScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export interface FixedScriptAddressCoinSpecific {
}

export interface GenerateAddressOptions {
addressType?: ScriptType2Of3;
chain?: number;
index?: number;
segwit?: boolean;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand All @@ -169,7 +166,6 @@ export function assertFixedScriptWalletAddress(

const expectedAddress = generateAddress(coinName, {
format,
addressType: addressType as ScriptType2Of3,
keychains,
chain,
index,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
Expand All @@ -82,10 +81,10 @@ interface VerifyCustomChangeAddressOptions {
* @return {boolean}
*/
async function verifyCustomChangeAddress(params: VerifyCustomChangeAddressOptions): Promise<boolean> {
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,
})
Expand All @@ -106,7 +105,6 @@ interface HandleVerifyAddressErrorOptions {
customChangeKeys?: CustomChangeOptions['keys'];
coin: AbstractUtxoCoin;
addressDetails?: any;
addressType?: string;
considerMigratedFromAddressInternal?: boolean;
}

Expand All @@ -118,7 +116,6 @@ async function handleVerifyAddressError({
customChangeKeys,
coin,
addressDetails,
addressType,
considerMigratedFromAddressInternal,
}: HandleVerifyAddressErrorOptions): Promise<HandleVerifyAddressErrorResponse> {
// Todo: name server-side errors to avoid message-based checking [BG-5124]
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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,
})
Expand All @@ -331,7 +325,6 @@ export async function parseOutput({
txParams,
customChangeKeys: customChange && customChange.keys,
addressDetails: currentAddressDetails,
addressType: currentAddressType,
considerMigratedFromAddressInternal: verification.considerMigratedFromAddressInternal,
})
);
Expand Down
Loading