Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: upgrade @noble/* & @scure/* packages #5488

Merged
merged 2 commits into from
Jun 6, 2024
Merged
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
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,14 @@
"@dlc-link/dlc-tools": "1.1.1",
"@fungible-systems/zone-file": "2.0.0",
"@hirosystems/token-metadata-api-client": "1.2.0",
"@leather-wallet/models": "0.6.6",
"@leather-wallet/query": "0.6.8",
"@leather-wallet/tokens": "0.5.0",
"@leather-wallet/utils": "0.6.6",
"@leather-wallet/bitcoin": "0.6.9",
"@leather-wallet/models": "0.6.8",
"@leather-wallet/query": "0.6.12",
"@leather-wallet/tokens": "0.5.2",
"@leather-wallet/utils": "0.7.0",
"@ledgerhq/hw-transport-webusb": "6.27.19",
"@noble/hashes": "1.3.2",
"@noble/secp256k1": "2.0.0",
"@noble/hashes": "1.4.0",
"@noble/secp256k1": "2.1.0",
"@octokit/types": "12.4.0",
"@radix-ui/colors": "3.0.0",
"@radix-ui/react-accessible-icon": "1.0.3",
Expand All @@ -155,10 +156,10 @@
"@radix-ui/react-tooltip": "1.0.7",
"@radix-ui/themes": "2.0.3",
"@reduxjs/toolkit": "2.2.3",
"@scure/base": "1.1.5",
"@scure/bip32": "1.3.3",
"@scure/base": "1.1.6",
"@scure/bip32": "1.4.0",
"@scure/bip39": "1.3.0",
"@scure/btc-signer": "1.2.1",
"@scure/btc-signer": "1.3.2",
"@segment/analytics-next": "1.70.0",
"@sentry/tracing": "7.106.0",
"@stacks/auth": "6.15.0",
Expand Down Expand Up @@ -253,9 +254,9 @@
"@actions/core": "1.10.1",
"@btckit/types": "0.0.19",
"@chromatic-com/storybook": "1.2.23",
"@leather-wallet/prettier-config": "0.4.0",
"@leather-wallet/rpc": "0.3.10",
"@leather-wallet/panda-preset": "0.2.0",
"@leather-wallet/prettier-config": "0.4.0",
"@leather-wallet/rpc": "1.0.1",
"@ls-lint/ls-lint": "2.2.3",
"@mdx-js/loader": "3.0.0",
"@pandacss/dev": "0.40.1",
Expand Down
785 changes: 509 additions & 276 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/app/common/psbt/requests.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { Money } from '@leather-wallet/models';
import { isString } from '@leather-wallet/utils';
import * as btc from '@scure/btc-signer';
import type { TransactionInput } from '@scure/btc-signer/psbt';
import { PsbtPayload } from '@stacks/connect';
import { decodeToken } from 'jsontokens';

export interface SignPsbtArgs {
addressNativeSegwitTotal?: Money;
addressTaprootTotal?: Money;
fee?: Money;
inputs: btc.TransactionInput[];
inputs: TransactionInput[];
}

export function getPsbtPayloadFromToken(requestToken: string): PsbtPayload {
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/loaders/bitcoin-account-loader.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { P2Ret } from '@scure/btc-signer';
import { P2Ret } from '@scure/btc-signer/payment';

import { useConfigBitcoinEnabled } from '@app/query/common/remote-config/remote-config.query';
import { useCurrentAccountIndex } from '@app/store/accounts/account';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { P2Ret, P2TROut } from '@scure/btc-signer';
import type { P2Ret, P2TROut } from '@scure/btc-signer/payment';

import { ZERO_INDEX } from '@shared/constants';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import {
getNativeSegwitAccountDerivationPath,
getTaprootAccountDerivationPath,
} from '@leather-wallet/bitcoin';
Comment on lines +2 to +4
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update import paths to ensure they are correctly resolved.

The static analysis tool reports that the module @leather-wallet/bitcoin cannot be found. This could be due to the module not being installed or incorrect path configurations. Please ensure that the package is correctly installed and the paths are correctly set in the TypeScript configuration.

- import {
-   getNativeSegwitAccountDerivationPath,
-   getTaprootAccountDerivationPath,
- } from '@leather-wallet/bitcoin';
+ // Ensure the correct path or package name is used here

Committable suggestion was skipped due to low confidence.

Tools
GitHub Check: typecheck

[failure] 6-6:
Cannot find module '@leather-wallet/bitcoin' or its corresponding type declarations.

import { delay } from '@leather-wallet/utils';
import BitcoinApp, { DefaultWalletPolicy } from 'ledger-bitcoin';

import { BitcoinNetworkModes, NetworkModes } from '@shared/constants';
import { createWalletIdDecoratedPath } from '@shared/crypto/bitcoin/bitcoin.utils';
import { getTaprootAccountDerivationPath } from '@shared/crypto/bitcoin/p2tr-address-gen';
import { getNativeSegwitAccountDerivationPath } from '@shared/crypto/bitcoin/p2wpkh-address-gen';

import { defaultNumberOfKeysToPullFromLedgerDevice } from '../../generic-flows/request-keys/use-request-ledger-keys';
import {
Expand Down
6 changes: 4 additions & 2 deletions src/app/features/ledger/utils/bitcoin-ledger-utils.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import {
getNativeSegwitAccountDerivationPath,
getTaprootAccountDerivationPath,
} from '@leather-wallet/bitcoin';
Comment on lines +1 to +4
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot find module '@leather-wallet/bitcoin' or its corresponding type declarations.

Please verify the existence of the module and ensure that its type declarations are correctly configured.

Tools
GitHub Check: typecheck

[failure] 9-9:
Cannot find module '@leather-wallet/bitcoin' or its corresponding type declarations.

import Transport from '@ledgerhq/hw-transport-webusb';
import { Psbt } from 'bitcoinjs-lib';
import BitcoinApp, { DefaultWalletPolicy } from 'ledger-bitcoin';
import { PartialSignature } from 'ledger-bitcoin/build/main/lib/appClient';

import { BitcoinNetworkModes } from '@shared/constants';
import { getTaprootAccountDerivationPath } from '@shared/crypto/bitcoin/p2tr-address-gen';
import { getNativeSegwitAccountDerivationPath } from '@shared/crypto/bitcoin/p2wpkh-address-gen';

import { LEDGER_APPS_MAP, promptOpenAppOnDevice } from './generic-ledger-utils';

Expand Down
4 changes: 2 additions & 2 deletions src/app/features/psbt-signer/hooks/use-parsed-inputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useMemo } from 'react';
import type { Inscription } from '@leather-wallet/models';
import { useInscriptionsByOutputs } from '@leather-wallet/query';
import { isDefined, isUndefined } from '@leather-wallet/utils';
import * as btc from '@scure/btc-signer';
import type { TransactionInput } from '@scure/btc-signer/psbt';
import { bytesToHex } from '@stacks/common';

import { getBtcSignerLibNetworkConfigByMode } from '@shared/crypto/bitcoin/bitcoin.network';
Expand All @@ -24,7 +24,7 @@ export interface PsbtInput {
}

interface UseParsedInputsArgs {
inputs: btc.TransactionInput[];
inputs: TransactionInput[];
indexesToSign?: number[];
}
export function useParsedInputs({ inputs, indexesToSign }: UseParsedInputsArgs) {
Expand Down
4 changes: 2 additions & 2 deletions src/app/features/psbt-signer/hooks/use-parsed-outputs.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMemo } from 'react';

import { isDefined, isUndefined } from '@leather-wallet/utils';
import * as btc from '@scure/btc-signer';
import type { TransactionOutput } from '@scure/btc-signer/psbt';

import { NetworkConfiguration } from '@shared/constants';
import { getBtcSignerLibNetworkConfigByMode } from '@shared/crypto/bitcoin/bitcoin.network';
Expand All @@ -20,7 +20,7 @@ export interface PsbtOutput {

interface UseParsedOutputsArgs {
isPsbtMutable: boolean;
outputs: btc.TransactionOutput[];
outputs: TransactionOutput[];
network: NetworkConfiguration;
}
export function useParsedOutputs({ isPsbtMutable, outputs, network }: UseParsedOutputsArgs) {
Expand Down
6 changes: 3 additions & 3 deletions src/app/features/psbt-signer/hooks/use-psbt-details.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useCallback, useMemo } from 'react';

import { createMoney, subtractMoney } from '@leather-wallet/utils';
import * as btc from '@scure/btc-signer';
import type { TransactionInput, TransactionOutput } from '@scure/btc-signer/psbt';

import { useCurrentAccountNativeSegwitIndexZeroSigner } from '@app/store/accounts/blockchain/bitcoin/native-segwit-account.hooks';
import { useCurrentAccountTaprootIndexZeroSigner } from '@app/store/accounts/blockchain/bitcoin/taproot-account.hooks';
Expand All @@ -13,9 +13,9 @@ import { usePsbtInscriptions } from './use-psbt-inscriptions';
import { usePsbtTotals } from './use-psbt-totals';

interface UsePsbtDetailsArgs {
inputs: btc.TransactionInput[];
inputs: TransactionInput[];
indexesToSign?: number[];
outputs: btc.TransactionOutput[];
outputs: TransactionOutput[];
}
export function usePsbtDetails({ inputs, indexesToSign, outputs }: UsePsbtDetailsArgs) {
const network = useCurrentNetwork();
Expand Down
7 changes: 4 additions & 3 deletions src/app/features/psbt-signer/hooks/use-psbt-signer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useMemo } from 'react';
import { isString } from '@leather-wallet/utils';
import { hexToBytes } from '@noble/hashes/utils';
import * as btc from '@scure/btc-signer';
import { RawPSBTV0, RawPSBTV2 } from '@scure/btc-signer/psbt';

import { BitcoinInputSigningConfig } from '@shared/crypto/bitcoin/signer-config';
import { logger } from '@shared/logger';
Expand All @@ -12,7 +13,7 @@ import {
useSignBitcoinTx,
} from '@app/store/accounts/blockchain/bitcoin/bitcoin.hooks';

export type RawPsbt = ReturnType<typeof btc.RawPSBTV0.decode>;
export type RawPsbt = ReturnType<typeof RawPSBTV0.decode>;

interface SignPsbtArgs {
signingConfig: BitcoinInputSigningConfig[];
Expand All @@ -35,11 +36,11 @@ export function usePsbtSigner() {
getRawPsbt(psbt: string | Uint8Array) {
const bytes = isString(psbt) ? hexToBytes(psbt) : psbt;
try {
return btc.RawPSBTV0.decode(bytes);
return RawPSBTV0.decode(bytes);
} catch (e1) {
logger.error(`Unable to decode PSBT as v0, trying v2, ${e1}`);
try {
return btc.RawPSBTV2.decode(bytes);
return RawPSBTV2.decode(bytes);
} catch (e2) {
throw new Error(`Unable to decode PSBT, ${e1 ?? e2}`);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { getNativeSegwitAddressIndexDerivationPath } from '@leather-wallet/bitcoin';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

The package @leather-wallet/bitcoin is listed in package.json but is missing from node_modules. Please ensure that the package is installed by running npm install. After installation, verify that the type declarations are present in the package directory.

  • Ensure @leather-wallet/bitcoin is installed.
  • Verify the presence of type declarations in node_modules/@leather-wallet/bitcoin.
Analysis chain

Verify the installation of @leather-wallet/bitcoin and ensure that its type declarations are available.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Check if the package `@leather-wallet/bitcoin` is installed and if its type declarations are present.

# Test: Search for the package in node_modules and its type declarations.
if [ -d "node_modules/@leather-wallet/bitcoin" ] && [ -f "node_modules/@leather-wallet/bitcoin/index.d.ts" ]; then
  echo "Package and type declarations are present."
else
  echo "Package or type declarations are missing."
fi

Length of output: 142



Script:

#!/bin/bash
# Check if the package `@leather-wallet/bitcoin` is listed in package.json
if grep -q '"@leather-wallet/bitcoin"' package.json; then
  echo "Package is listed in package.json."
else
  echo "Package is not listed in package.json."
fi

# List the contents of the package directory to check for type declarations
if [ -d "node_modules/@leather-wallet/bitcoin" ]; then
  echo "Contents of node_modules/@leather-wallet/bitcoin:"
  ls -l node_modules/@leather-wallet/bitcoin
else
  echo "Package directory is missing in node_modules."
fi

Length of output: 280



Script:

#!/bin/bash
# Attempt to install the missing package
npm install

# Check the installation logs for any errors related to `@leather-wallet/bitcoin`
if grep -i '@leather-wallet/bitcoin' npm-debug.log; then
  echo "Errors related to @leather-wallet/bitcoin found in npm-debug.log."
else
  echo "No errors related to @leather-wallet/bitcoin found in npm-debug.log."
fi

# Verify if the package directory is now present in node_modules
if [ -d "node_modules/@leather-wallet/bitcoin" ]; then
  echo "Package directory is now present in node_modules."
else
  echo "Package directory is still missing in node_modules."
fi

Length of output: 489

Tools
GitHub Check: typecheck

[failure] 1-1:
Cannot find module '@leather-wallet/bitcoin' or its corresponding type declarations.

import type { Inscription } from '@leather-wallet/models';
import type { UtxoWithDerivationPath } from '@leather-wallet/query';

import { BitcoinNetworkModes } from '@shared/constants';
import { getNativeSegwitAddressIndexDerivationPath } from '@shared/crypto/bitcoin/p2wpkh-address-gen';

interface CreateUtxoFromInscriptionArgs {
inscription: Inscription;
network: BitcoinNetworkModes;
accountIndex: number;
inscriptionAddressIdx: number;
}

export function createUtxoFromInscription({
inscription,
network,
Expand Down
6 changes: 4 additions & 2 deletions src/app/store/accounts/blockchain/bitcoin/bitcoin-signer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { useCallback } from 'react';

import {
getNativeSegwitAddressIndexDerivationPath,
getTaprootAddressIndexDerivationPath,
} from '@leather-wallet/bitcoin';
Comment on lines +4 to +6
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update import paths to ensure they are correctly resolved.

The static analysis tool reports that the module @leather-wallet/bitcoin cannot be found. This could be due to the module not being installed or incorrect path configurations. Please ensure that the package is correctly installed and the paths are correctly set in the TypeScript configuration.

- import {
-   getNativeSegwitAddressIndexDerivationPath,
-   getTaprootAddressIndexDerivationPath,
- } from '@leather-wallet/bitcoin';
+ // Ensure the correct path or package name is used here

Committable suggestion was skipped due to low confidence.

Tools
GitHub Check: typecheck

[failure] 9-9:
Cannot find module '@leather-wallet/bitcoin' or its corresponding type declarations.

import { HDKey, Versions } from '@scure/bip32';
import * as btc from '@scure/btc-signer';

Expand All @@ -9,8 +13,6 @@ import {
deriveAddressIndexKeychainFromAccount,
whenPaymentType,
} from '@shared/crypto/bitcoin/bitcoin.utils';
import { getTaprootAddressIndexDerivationPath } from '@shared/crypto/bitcoin/p2tr-address-gen';
import { getNativeSegwitAddressIndexDerivationPath } from '@shared/crypto/bitcoin/p2wpkh-address-gen';
import { AllowedSighashTypes } from '@shared/rpc/methods/sign-psbt';

import { useBitcoinExtendedPublicKeyVersions } from './bitcoin-keychain';
Expand Down
6 changes: 4 additions & 2 deletions src/app/store/accounts/blockchain/bitcoin/bitcoin.hooks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { PaymentTypes } from '@btckit/types';
import {
getNativeSegwitAccountDerivationPath,
getTaprootAccountDerivationPath,
} from '@leather-wallet/bitcoin';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module @leather-wallet/bitcoin cannot be found. Ensure the package is correctly installed and included in package.json.

Tools
GitHub Check: typecheck

[failure] 10-10:
Cannot find module '@leather-wallet/bitcoin' or its corresponding type declarations.

import { isNumber, isUndefined } from '@leather-wallet/utils';
import { bytesToHex } from '@noble/hashes/utils';
import * as btc from '@scure/btc-signer';
Expand All @@ -11,8 +15,6 @@ import {
getInputPaymentType,
getTaprootAddress,
} from '@shared/crypto/bitcoin/bitcoin.utils';
import { getTaprootAccountDerivationPath } from '@shared/crypto/bitcoin/p2tr-address-gen';
import { getNativeSegwitAccountDerivationPath } from '@shared/crypto/bitcoin/p2wpkh-address-gen';
import {
BitcoinInputSigningConfig,
getAssumedZeroIndexSigningConfig,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { useMemo } from 'react';
import { useSelector } from 'react-redux';

import {
deriveNativeSegwitAccountFromRootKeychain,
getNativeSegWitPaymentFromAddressIndex,
getNativeSegwitAccountDerivationPath,
} from '@leather-wallet/bitcoin';
Comment on lines +5 to +8
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update import paths to ensure they are correctly resolved.

The static analysis tool reports that the module @leather-wallet/bitcoin cannot be found. This could be due to the module not being installed or incorrect path configurations. Please ensure that the package is correctly installed and the paths are correctly set in the TypeScript configuration.

- import {
-   deriveNativeSegwitAccountFromRootKeychain,
-   getNativeSegWitPaymentFromAddressIndex,
-   getNativeSegwitAccountDerivationPath,
- } from '@leather-wallet/bitcoin';
+ // Ensure the correct path or package name is used here

Committable suggestion was skipped due to low confidence.

Tools
GitHub Check: typecheck

[failure] 11-11:
Cannot find module '@leather-wallet/bitcoin' or its corresponding type declarations.

import { reverseBytes } from '@leather-wallet/utils';
import { createSelector } from '@reduxjs/toolkit';
import { Psbt } from 'bitcoinjs-lib';
Expand All @@ -10,11 +15,6 @@ import {
extractAddressIndexFromPath,
lookUpLedgerKeysByPath,
} from '@shared/crypto/bitcoin/bitcoin.utils';
import {
deriveNativeSegwitAccountFromRootKeychain,
getNativeSegWitPaymentFromAddressIndex,
getNativeSegwitAccountDerivationPath,
} from '@shared/crypto/bitcoin/p2wpkh-address-gen';
import { BitcoinInputSigningConfig } from '@shared/crypto/bitcoin/signer-config';
import { analytics } from '@shared/utils/analytics';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { useMemo } from 'react';
import { useSelector } from 'react-redux';

import {
deriveTaprootAccount,
getTaprootAccountDerivationPath,
getTaprootPaymentFromAddressIndex,
} from '@leather-wallet/bitcoin';
Comment on lines +5 to +8
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update import paths to ensure they are correctly resolved.

The static analysis tool reports that the module @leather-wallet/bitcoin cannot be found. This could be due to the module not being installed or incorrect path configurations. Please ensure that the package is correctly installed and the paths are correctly set in the TypeScript configuration.

- import {
-   deriveTaprootAccount,
-   getTaprootAccountDerivationPath,
-   getTaprootPaymentFromAddressIndex,
- } from '@leather-wallet/bitcoin';
+ // Ensure the correct path or package name is used here

Committable suggestion was skipped due to low confidence.

Tools
GitHub Check: typecheck

[failure] 11-11:
Cannot find module '@leather-wallet/bitcoin' or its corresponding type declarations.

import { createSelector } from '@reduxjs/toolkit';
import { Psbt } from 'bitcoinjs-lib';

Expand All @@ -10,11 +15,6 @@ import {
extractAddressIndexFromPath,
lookUpLedgerKeysByPath,
} from '@shared/crypto/bitcoin/bitcoin.utils';
import {
deriveTaprootAccount,
getTaprootAccountDerivationPath,
getTaprootPaymentFromAddressIndex,
} from '@shared/crypto/bitcoin/p2tr-address-gen';
import { BitcoinInputSigningConfig } from '@shared/crypto/bitcoin/signer-config';

import { selectCurrentNetwork, useCurrentNetwork } from '@app/store/networks/networks.selectors';
Expand Down
25 changes: 7 additions & 18 deletions src/shared/crypto/bitcoin/bitcoin.utils.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { PaymentTypes as PaymentType } from '@btckit/types';
import { getTaprootPayment } from '@leather-wallet/bitcoin';
import { defaultWalletKeyId, isDefined, whenNetwork } from '@leather-wallet/utils';
import { hexToBytes } from '@noble/hashes/utils';
import { HDKey, Versions } from '@scure/bip32';
import * as btc from '@scure/btc-signer';
import type { TransactionInput, TransactionOutput } from '@scure/btc-signer/psbt';

import { BitcoinNetworkModes, NetworkModes } from '@shared/constants';
import { logger } from '@shared/logger';

import { DerivationPathDepth } from '../derivation-path.utils';
import { BtcSignerNetwork, getBtcSignerLibNetworkConfigByMode } from './bitcoin.network';
import { getTaprootPayment } from './p2tr-address-gen';

export interface BitcoinAccount {
type: PaymentType;
Expand All @@ -29,15 +30,6 @@ export function bitcoinNetworkModeToCoreNetworkMode(mode: BitcoinNetworkModes) {
return bitcoinNetworkToCoreNetworkMap[mode];
}

const coinTypeMap: Record<NetworkModes, 0 | 1> = {
mainnet: 0,
testnet: 1,
};

export function getBitcoinCoinTypeIndexByNetwork(network: BitcoinNetworkModes) {
return coinTypeMap[bitcoinNetworkModeToCoreNetworkMode(network)];
}

export function deriveAddressIndexKeychainFromAccount(keychain: HDKey) {
if (keychain.depth !== DerivationPathDepth.Account)
throw new Error('Keychain passed is not an account');
Expand Down Expand Up @@ -95,10 +87,7 @@ export function getAddressFromOutScript(script: Uint8Array, bitcoinNetwork: BtcS
}
}

export function getBitcoinInputAddress(
input: btc.TransactionInput,
bitcoinNetwork: BtcSignerNetwork
) {
export function getBitcoinInputAddress(input: TransactionInput, bitcoinNetwork: BtcSignerNetwork) {
if (isDefined(input.witnessUtxo))
return getAddressFromOutScript(input.witnessUtxo.script, bitcoinNetwork);
if (isDefined(input.nonWitnessUtxo) && isDefined(input.index))
Expand All @@ -109,7 +98,7 @@ export function getBitcoinInputAddress(
return '';
}

export function getBitcoinInputValue(input: btc.TransactionInput) {
export function getBitcoinInputValue(input: TransactionInput) {
if (isDefined(input.witnessUtxo)) return Number(input.witnessUtxo.amount);
if (isDefined(input.nonWitnessUtxo) && isDefined(input.index))
return Number(input.nonWitnessUtxo.outputs[input.index]?.amount);
Expand Down Expand Up @@ -251,20 +240,20 @@ export function getTaprootAddress({ index, keychain, network }: GetTaprootAddres

export function getPsbtTxInputs(psbtTx: btc.Transaction) {
const inputsLength = psbtTx.inputsLength;
const inputs: btc.TransactionInput[] = [];
const inputs: TransactionInput[] = [];
for (let i = 0; i < inputsLength; i++) inputs.push(psbtTx.getInput(i));
return inputs;
}

export function getPsbtTxOutputs(psbtTx: btc.Transaction) {
const outputsLength = psbtTx.outputsLength;
const outputs: btc.TransactionOutput[] = [];
const outputs: TransactionOutput[] = [];
for (let i = 0; i < outputsLength; i++) outputs.push(psbtTx.getOutput(i));
return outputs;
}

export function getInputPaymentType(
input: btc.TransactionInput,
input: TransactionInput,
network: BitcoinNetworkModes
): PaymentType {
const address = getBitcoinInputAddress(input, getBtcSignerLibNetworkConfigByMode(network));
Expand Down
Loading
Loading