gagliardetto / solana-go

Go SDK library and RPC client for the Solana Blockchain
Apache License 2.0
818 stars 242 forks source link

invalid transaction: Transaction failed to sanitize accounts offsets correctly #134

Open femtoeu opened 1 year ago

femtoeu commented 1 year ago

Hello, i'm trying to make swap using jup.ag quote api

tx, err := solana.TransactionFromDecoder(bin.NewBinDecoder(swapTx))
if err != nil {
    log.Fatal(err)
}

_, err = tx.Sign(
    func(key solana.PublicKey) *solana.PrivateKey {
    if account.PublicKey().Equals(key) {
                    return &account.PrivateKey
                }
                return nil
            },
        )
        if err != nil {
            log.Fatal(err)
        }

        hash, err := solanaClient.SendTransaction(context.Background(), tx)
        if err != nil {
            log.Fatal(err)
}
log.Println("swap:", hash)

swapTx is []byte that i got from jup.ag api and when i'm was trying to send tx i got this err: (*jsonrpc.RPCError)(0xc00002b920)({ Code: (int) -32602, Message: (string) (len=78) "invalid transaction: Transaction failed to sanitize accounts offsets correctly", Data: (interface {}) <nil> })

akbariandev commented 1 year ago

Did you find any solution?

ubuygold commented 5 months ago

Same here, do you have any solution?

AlexandreColauto commented 2 months ago

Same, no succes with Tx from API's.

AlexandreColauto commented 2 months ago

It seems that tx.Sign() can’t overwrite the origin signature(11111111111…) from jupiter and I have to delete them manually. from https://github.com/gagliardetto/solana-go/issues/186 That happens when they have a default signature on the api's. we might need to change it.