I have a transaction that uses 2 signers(the user and the Keypair from the backend). It signs from the Backend and returns a serialized transaction for the user to sign. However, I am getting this Error
`Error: failed to send transaction: Transaction signature verification failure
at Connection.sendEncodedTransaction(node_modules/@solana/web3.js/src/connection.ts:5054:13)
at processTicksAndRejections(node:internal/process/task_queues:96:5)
at Connection.sendRawTransaction(node_modules/@solana/web3.js/src/connection.ts:5013:20)`.
This is my code snippet
const tx = await program.methods.create(new anchor.BN(3))
.accounts({
payer: provider.wallet.publicKey,
backend: backend.publicKey,
systemProgram: SystemProgram.programId
}).transaction();
tx.recentBlockhash = (
await program.provider.connection.getLatestBlockhash()
).blockhash;
tx.sign(backend);
const serializedTx = tx.serialize({ requireAllSignatures: false });
// Deserialize it and then sign with provider wallet
let recoveredTransaction: Transaction | undefined = Transaction.from(Buffer.from(serializedTx));
recoveredTransaction = await provider.wallet.signTransaction(recoveredTransaction);
recoveredTransaction.feePayer = provider.wallet.publicKey;
const final_tx =
(await provider.connection.sendRawTransaction(
recoveredTransaction.serialize({ verifySignatures: false, requireAllSignatures: false }),
));
await provider.connection.confirmTransaction(final_tx, "confirmed");
tx.partialSign
produces the same output, I have posted my findings to the root cause of the problem below