diff --git a/package.json b/package.json index 808dce77..d9272e2b 100644 --- a/package.json +++ b/package.json @@ -231,7 +231,7 @@ "@babel/core": "7.22.5", "@babel/preset-react": "7.22.5", "@babel/preset-typescript": "7.22.5", - "@btckit/types": "0.0.18", + "@btckit/types": "0.0.19", "@emotion/babel-plugin": "11.11.0", "@emotion/babel-preset-css-prop": "11.11.0", "@emotion/cache": "11.11.0", diff --git a/src/app/common/psbt/use-psbt-request-params.ts b/src/app/common/psbt/use-psbt-request-params.ts index fcab3f0d..d702404a 100644 --- a/src/app/common/psbt/use-psbt-request-params.ts +++ b/src/app/common/psbt/use-psbt-request-params.ts @@ -1,8 +1,7 @@ import { useMemo } from 'react'; import { useSearchParams } from 'react-router-dom'; -import * as btc from '@scure/btc-signer'; - +import { AllowedSighashTypes } from '@shared/rpc/methods/sign-psbt'; import { ensureArray, undefinedIfLengthZero } from '@shared/utils'; import { useRejectIfLedgerWallet } from '@app/common/rpc-helpers'; @@ -23,7 +22,7 @@ export function usePsbtRequestSearchParams() { () => ({ appName: payload?.appDetails?.name, allowedSighash: payload?.allowedSighash - ? undefinedIfLengthZero(payload.allowedSighash.map(h => Number(h)) as btc.SignatureHash[]) + ? undefinedIfLengthZero(payload.allowedSighash.map(h => Number(h)) as AllowedSighashTypes[]) : undefined, origin, payload, @@ -54,7 +53,7 @@ export function useRpcSignPsbtParams() { requestId, psbtHex, allowedSighash: undefinedIfLengthZero( - allowedSighash.map(h => Number(h)) as btc.SignatureHash[] + allowedSighash.map(h => Number(h)) as AllowedSighashTypes[] ), signAtIndex: undefinedIfLengthZero(ensureArray(signAtIndex).map(h => Number(h))), }; diff --git a/src/app/features/psbt-signer/components/psbt-request-details/psbt-request-details.tsx b/src/app/features/psbt-signer/components/psbt-request-details/psbt-request-details.tsx index 46b2e868..641eea82 100644 --- a/src/app/features/psbt-signer/components/psbt-request-details/psbt-request-details.tsx +++ b/src/app/features/psbt-signer/components/psbt-request-details/psbt-request-details.tsx @@ -1,5 +1,7 @@ import * as btc from '@scure/btc-signer'; +import { AllowedSighashTypes } from '@shared/rpc/methods/sign-psbt'; + import { useCurrentAccountNativeSegwitIndexZeroSigner } from '@app/store/accounts/blockchain/bitcoin/native-segwit-account.hooks'; import { useCurrentAccountTaprootIndexZeroSigner } from '@app/store/accounts/blockchain/bitcoin/taproot-account.hooks'; @@ -14,7 +16,7 @@ import { PsbtRequestFee } from './components/psbt-request-fee'; import { PsbtRequestRaw } from './components/psbt-request-raw'; interface PsbtRequestDetailsProps { - allowedSighash?: btc.SignatureHash[]; + allowedSighash?: AllowedSighashTypes[]; indexesToSign?: number[]; psbtRaw?: RawPsbt; psbtTxInputs: btc.TransactionInput[]; diff --git a/src/app/features/psbt-signer/hooks/use-parsed-inputs.tsx b/src/app/features/psbt-signer/hooks/use-parsed-inputs.tsx index 74bfcd4b..46c37ed2 100644 --- a/src/app/features/psbt-signer/hooks/use-parsed-inputs.tsx +++ b/src/app/features/psbt-signer/hooks/use-parsed-inputs.tsx @@ -8,6 +8,7 @@ import { getBtcSignerLibNetworkConfigByMode, } from '@shared/crypto/bitcoin/bitcoin.network'; import { getAddressFromOutScript } from '@shared/crypto/bitcoin/bitcoin.utils'; +import { AllowedSighashTypes } from '@shared/rpc/methods/sign-psbt'; import { ensureArray, isDefined, isUndefined } from '@shared/utils'; import { useOrdinalsAwareUtxoQueries } from '@app/query/bitcoin/ordinals/ordinals-aware-utxo.query'; @@ -44,7 +45,7 @@ function getInputValue(index: number, input: btc.TransactionInput) { } interface UseParsedInputsArgs { - allowedSighash?: btc.SignatureHash[]; + allowedSighash?: AllowedSighashTypes[]; inputs: btc.TransactionInput[]; indexesToSign?: number[]; } diff --git a/src/app/features/psbt-signer/hooks/use-parsed-psbt.tsx b/src/app/features/psbt-signer/hooks/use-parsed-psbt.tsx index 4f2859dd..7a54a743 100644 --- a/src/app/features/psbt-signer/hooks/use-parsed-psbt.tsx +++ b/src/app/features/psbt-signer/hooks/use-parsed-psbt.tsx @@ -2,6 +2,8 @@ import { useCallback } from 'react'; import * as btc from '@scure/btc-signer'; +import { AllowedSighashTypes } from '@shared/rpc/methods/sign-psbt'; + import { subtractMoney } from '@app/common/money/calculate-money'; import { useCurrentAccountNativeSegwitIndexZeroSigner } from '@app/store/accounts/blockchain/bitcoin/native-segwit-account.hooks'; import { useCurrentAccountTaprootIndexZeroSigner } from '@app/store/accounts/blockchain/bitcoin/taproot-account.hooks'; @@ -13,7 +15,7 @@ import { usePsbtInscriptions } from './use-psbt-inscriptions'; import { usePsbtTotals } from './use-psbt-totals'; interface UseParsedPsbtArgs { - allowedSighash?: btc.SignatureHash[]; + allowedSighash?: AllowedSighashTypes[]; inputs: btc.TransactionInput[]; indexesToSign?: number[]; outputs: btc.TransactionOutput[]; diff --git a/src/app/features/psbt-signer/hooks/use-psbt-signer.tsx b/src/app/features/psbt-signer/hooks/use-psbt-signer.tsx index 813697fb..f1c5cb28 100644 --- a/src/app/features/psbt-signer/hooks/use-psbt-signer.tsx +++ b/src/app/features/psbt-signer/hooks/use-psbt-signer.tsx @@ -4,6 +4,7 @@ import { hexToBytes } from '@noble/hashes/utils'; import * as btc from '@scure/btc-signer'; import { logger } from '@shared/logger'; +import { AllowedSighashTypes } from '@shared/rpc/methods/sign-psbt'; import { isString, isUndefined } from '@shared/utils'; import { useCurrentAccountNativeSegwitSigner } from '@app/store/accounts/blockchain/bitcoin/native-segwit-account.hooks'; @@ -12,7 +13,7 @@ import { useCurrentAccountTaprootSigner } from '@app/store/accounts/blockchain/b export type RawPsbt = ReturnType; interface SignPsbtArgs { - allowedSighash?: btc.SignatureHash[]; + allowedSighash?: AllowedSighashTypes[]; inputs: btc.TransactionInput[]; indexesToSign?: number[]; tx: btc.Transaction; diff --git a/src/app/features/psbt-signer/psbt-signer.tsx b/src/app/features/psbt-signer/psbt-signer.tsx index 00d05ef0..a8f3bd54 100644 --- a/src/app/features/psbt-signer/psbt-signer.tsx +++ b/src/app/features/psbt-signer/psbt-signer.tsx @@ -4,6 +4,7 @@ import { useNavigate } from 'react-router-dom'; import * as btc from '@scure/btc-signer'; import { RouteUrls } from '@shared/route-urls'; +import { AllowedSighashTypes } from '@shared/rpc/methods/sign-psbt'; import { useRouteHeader } from '@app/common/hooks/use-route-header'; import { PopupHeader } from '@app/features/current-account/popup-header'; @@ -36,7 +37,7 @@ function getPsbtTxOutputs(psbtTx: btc.Transaction) { } interface PsbtSignerProps { - allowedSighash?: btc.SignatureHash[]; + allowedSighash?: AllowedSighashTypes[]; indexesToSign?: number[]; name?: string; origin: string; diff --git a/src/app/store/accounts/blockchain/bitcoin/bitcoin-signer.ts b/src/app/store/accounts/blockchain/bitcoin/bitcoin-signer.ts index e17e8d31..1c53d3dc 100644 --- a/src/app/store/accounts/blockchain/bitcoin/bitcoin-signer.ts +++ b/src/app/store/accounts/blockchain/bitcoin/bitcoin-signer.ts @@ -11,6 +11,7 @@ import { } 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'; interface Signer { network: BitcoinNetworkModes; @@ -20,7 +21,7 @@ interface Signer { address: string; publicKey: Uint8Array; sign(tx: btc.Transaction): void; - signIndex(tx: btc.Transaction, index: number, allowedSighash?: btc.SignatureHash[]): void; + signIndex(tx: btc.Transaction, index: number, allowedSighash?: AllowedSighashTypes[]): void; } interface MakeBitcoinSignerArgs { @@ -29,7 +30,7 @@ interface MakeBitcoinSignerArgs { derivationPath: string; paymentFn(keychain: HDKey, network: BitcoinNetworkModes): any; signFn(tx: btc.Transaction): void; - signAtIndexFn(tx: btc.Transaction, index: number, allowedSighash?: btc.SignatureHash[]): void; + signAtIndexFn(tx: btc.Transaction, index: number, allowedSighash?: AllowedSighashTypes[]): void; } function makeBitcoinSigner(args: T) { const { derivationPath, keychain, network, paymentFn, signFn, signAtIndexFn } = args; @@ -89,7 +90,8 @@ export function bitcoinAddressIndexSignerFactory().test(testIsNumberOrArrayOfNumbers), diff --git a/yarn.lock b/yarn.lock index e6904587..2b069b87 100644 --- a/yarn.lock +++ b/yarn.lock @@ -926,10 +926,10 @@ sha.js "^2.4.11" smart-buffer "^4.1.0" -"@btckit/types@0.0.18": - version "0.0.18" - resolved "https://registry.yarnpkg.com/@btckit/types/-/types-0.0.18.tgz#48bd0b564a9c14bf0c670b0834131e5054c20d69" - integrity sha512-2b/Ny4rZ+TbGW59xiV/PvXRP1cnF40874t12OzeVKa/BghxBFazEayDHce9YtPTkxQ4ilQkmeNrS67FWK4OsGA== +"@btckit/types@0.0.19": + version "0.0.19" + resolved "https://registry.yarnpkg.com/@btckit/types/-/types-0.0.19.tgz#8454326b669d3b029094d3d20026fdc6e6c72319" + integrity sha512-APoOfYSg9SRR4CMXL606IDtpgh+ZD3kS/+iY0BkUALD6HvXo2pVw20L5YYIc+HrgMcF6WN0TH7TXdVs+Vu+kww== "@coinbase/cbpay-js@1.0.2": version "1.0.2"