Skip to content

Commit

Permalink
fix: Standardize OneKey PSBT signing results
Browse files Browse the repository at this point in the history
  • Loading branch information
originalix committed Aug 13, 2024
1 parent dea6d25 commit 4ca0289
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions src/app/common/utils/psbt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { Psbt, Transaction } from "bitcoinjs-lib";

import { WalletProvider } from "@/utils/wallet/wallet_provider";

const SIGN_PSBT_NOT_COMPATIBLE_WALLETS = ["OneKey"];

export type SignPsbtTransaction = (psbtHex: string) => Promise<Transaction>;

// This method is created to accommodate backward compatibility with the
Expand All @@ -12,17 +10,6 @@ export type SignPsbtTransaction = (psbtHex: string) => Promise<Transaction>;
export const signPsbtTransaction = (wallet: WalletProvider) => {
return async (psbtHex: string) => {
const signedHex = await wallet.signPsbt(psbtHex);
const providerName = await wallet.getWalletProviderName();
if (SIGN_PSBT_NOT_COMPATIBLE_WALLETS.includes(providerName)) {
try {
// Try to parse the signedHex as PSBT to see if it follows the new implementation
return Psbt.fromHex(signedHex).extractTransaction();
} catch {
// If parsing fails, it's the old version implementation
return Transaction.fromHex(signedHex);
}
}

// For compatible wallets, directly extract the transaction from the signed PSBT
return Psbt.fromHex(signedHex).extractTransaction();
};
Expand Down

0 comments on commit 4ca0289

Please sign in to comment.