Skip to content

Commit

Permalink
fix: missing regtest prefix in address check
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed Mar 20, 2024
1 parent 5f08a9c commit ee25c25
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/shared/crypto/bitcoin/bitcoin.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ export function getInputPaymentType(
): PaymentTypes {
const address = getBitcoinInputAddress(index, input, getBtcSignerLibNetworkConfigByMode(network));
if (address === '') throw new Error('Input address cannot be empty');
if (address.startsWith('bc1p') || address.startsWith('tb1p')) return 'p2tr';
if (address.startsWith('bc1q') || address.startsWith('tb1q')) return 'p2wpkh';
if (address.startsWith('bc1p') || address.startsWith('tb1p') || address.startsWith('bcrt1p'))
return 'p2tr';
if (address.startsWith('bc1q') || address.startsWith('tb1q') || address.startsWith('bcrt1q'))
return 'p2wpkh';
throw new Error('Unable to infer payment type from input address');
}
2 changes: 1 addition & 1 deletion src/shared/crypto/bitcoin/signer-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function getAssumedZeroIndexSigningConfig({
return indexes.map(inputIndex => {
const input = tx.getInput(inputIndex);

const paymentType = getInputPaymentType(inputIndex, input, 'mainnet');
const paymentType = getInputPaymentType(inputIndex, input, network);
switch (paymentType) {
case 'p2wpkh':
return {
Expand Down

0 comments on commit ee25c25

Please sign in to comment.