bmresearch / Solnet

Solana's .NET SDK and integration library.
https://blockmountain.io/Solnet
MIT License
324 stars 130 forks source link

[Bug] Transaction signature verification failure #459

Open robertvo opened 5 months ago

robertvo commented 5 months ago

Describe the bug Get error from Solana network "Transaction signature verification failure"

To Reproduce Create a consolidation transaction with 4 transfers from 4 input addresses to 1 output

There's some kind of signature mismatch. It always works with 1 input, it SOMETIMES works with 3 and it never works with 4.

AbanoubNassem commented 3 months ago

any updates ? have you figured a work around ?

BifrostTitan commented 3 months ago

This is from Solnet.Serum. Maybe it will help bypass the verification issue. When certain transactions are deserialized the public keys for the signatures are pulled from the instructions which can be incorrect.

Create a TransactionBuilder instance and create your transaction by adding the instructions etc then obtain signatures from all the signers and add them to the signature list. Try populating the signatures manually.

I will look into the web3.js source code and take a look at the typescript implementation to see if I can find a better way to serialize and break down transactions.

   byte[] txBytes = txBuilder.CompileMessage();

   byte[] signatureBytes = TraderWallet.Sign(txBytes);

   List<byte[]> signatures = new() { signatureBytes };
   signatures.AddRange(_signers.Select(signer => signer.Sign(txBytes)));
   _signers.Clear();

   Transaction tx = Transaction.Populate(Message.Deserialize(txBytes), signatures);
    return await rpc.SendTransactionAsync(tx.Serialize());
robertvo commented 2 months ago

I did not figure this out. Instead of making 4 transfers in one transactions, I'm sending 4 separate transactions :(