Skip to content

Commit

Permalink
fix: validation regtest addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed Mar 20, 2024
1 parent ee25c25 commit 4371b84
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 8 additions & 2 deletions src/app/common/validation/forms/address-validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { AddressType, Network, getAddressInfo, validate } from 'bitcoin-address-
import * as yup from 'yup';

import { BitcoinNetworkModes, NetworkConfiguration } from '@shared/constants';
import { bitcoinNetworkModeToCoreNetworkMode } from '@shared/crypto/bitcoin/bitcoin.utils';
import { isString } from '@shared/utils';

import { FormErrorMessages } from '@app/common/error-messages';
Expand Down Expand Up @@ -46,9 +45,16 @@ export function btcTaprootAddressValidator() {
}

function btcAddressNetworkValidatorFactory(network: BitcoinNetworkModes) {
function getAddressNetworkType(network: BitcoinNetworkModes): Network {
// Signet uses testnet address format, this parsing is to please the
// validation library
if (network === 'signet') return Network.testnet;
return network as Network;
}

return (value?: string) => {
if (!isString(value)) return false;
return validate(value, bitcoinNetworkModeToCoreNetworkMode(network) as Network);
return validate(value, getAddressNetworkType(network));
};
}

Expand Down
6 changes: 3 additions & 3 deletions src/app/features/psbt-signer/hooks/use-parsed-inputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export function useParsedInputs({ inputs, indexesToSign }: UseParsedInputsArgs)
const bitcoinNetwork = getBtcSignerLibNetworkConfigByMode(network.chain.bitcoin.bitcoinNetwork);
const bitcoinAddressNativeSegwit = useCurrentAccountNativeSegwitIndexZeroSigner().address;
const { address: bitcoinAddressTaproot } = useCurrentAccountTaprootIndexZeroSigner();
const inscriptions = useGetInscriptionsByOutputQueries(inputs).map(query => {
return query.data?.results[0];
});
const inscriptions = useGetInscriptionsByOutputQueries(inputs).map(
query => query.data?.results[0]
);
const signAll = isUndefined(indexesToSign);

const psbtInputs = useMemo(
Expand Down

0 comments on commit 4371b84

Please sign in to comment.