okx / go-wallet-sdk

Multi-chain golang signature sdk, supports bitcoin, ethereum, aptos, cosmos, etc.
MIT License
363 stars 130 forks source link

Solana decode raw transaction error #52

Closed viaweb3 closed 4 months ago

viaweb3 commented 4 months ago

When decode raw transaction that created by Dapp, it looks like the accountTableLookups field is lost.

Demo:

rawStr := `AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAQADEO4Ti7ELpNlheK34aS1nU9SyOahrxNVhKc+HBUZ8Ok9+/r1cmarYUU2+uQ6Xfw2GeW+S3hbe7NhNes+gkeBjrDQGm4hX/quBhPtof2NGGMA12sQ53BrrO1WYoPAAAAAAAfWyieNQagqfYXHrGOZaCpVC7WHqfbyrZqba4MvDz3bR8M3vtrj9zOXD1v/fLYpG1Hu3oBu2o5UGbt1uv1R5/KDG+nrzvtutOj1l82qryXQxsbvkwtL24OR8pgIDRS9dYd6TBhiVE97EIUaTDBrSmxNiGFrvvaYVTVujoW1sUpU8W23FfY/TovEu0rqX0rE58cUzVl3A1cbBz//toyNr6uhssz2cjVCgS1WL7Q3b0kRCvws2k57E2iO7OUxnRHCpgzeZjMvy0EWLYVy8xrGjZ8R0np/vcwZiLhsbWJEBILyaUWe8Ce5CtE6sos2GtueIi2BEN2LGrxhcdoXf9Mkkob/ZbqMZ2O42JQfrfuwWxFdU4EE4tU9AOkF71ZDxKyf2ls2sAwhan+XTRRltrXJYuOBut94oEC91I0gF3n8u42ebAwZGb+UhFzL/7K26csOb57yM5bvF9xJrLEObOkAAAAAMwoDLa+MZLFA4OAHPRDAYD54/hmMiOsgBBpcQ2/fVB0FXsFgPMcX85EpiWC28+deO51lDoISjk7NQNo0iiZMIe0wTdioaHkfxqWFhqLW7pmeEA+i/4pO2PYD7PtMaZHIFDQAJA1z6DQAAAAAADQAFAtZyAgAOBgABAhAREgkFQEIPAAAAAAAOKRATERIAAQMUBAIFBg8GBgYHCAYGBgYGBhQDBQkKDwoKCgsMCgoKCgoKEQBAQg8AAAAAAAaKAQAAAAAADgYAAQAQERIBBgEZjx9MOkUiY9QTss0X68vBoOWIc2TmJhoSqBeS6hZaPgAFAgcAAw4=`
    tx := base.Transaction{}
    err := tx.UnmarshalBase64(rawStr)
    if err != nil {
        panic(err)
    }

    j, _ := json.Marshal(tx)
    println(string(j))

This transaction is created by Raydium, when decode transaction by nodejs or gagliardetto/solana-go, it has accountTableLookups, when use okx/go-wallet-sdk/, it does not have accountTableLookups.

image

leverwwz commented 4 months ago

When decode raw transaction that created by Dapp, it looks like the accountTableLookups field is lost.

Demo:

rawStr := `AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAQADEO4Ti7ELpNlheK34aS1nU9SyOahrxNVhKc+HBUZ8Ok9+/r1cmarYUU2+uQ6Xfw2GeW+S3hbe7NhNes+gkeBjrDQGm4hX/quBhPtof2NGGMA12sQ53BrrO1WYoPAAAAAAAfWyieNQagqfYXHrGOZaCpVC7WHqfbyrZqba4MvDz3bR8M3vtrj9zOXD1v/fLYpG1Hu3oBu2o5UGbt1uv1R5/KDG+nrzvtutOj1l82qryXQxsbvkwtL24OR8pgIDRS9dYd6TBhiVE97EIUaTDBrSmxNiGFrvvaYVTVujoW1sUpU8W23FfY/TovEu0rqX0rE58cUzVl3A1cbBz//toyNr6uhssz2cjVCgS1WL7Q3b0kRCvws2k57E2iO7OUxnRHCpgzeZjMvy0EWLYVy8xrGjZ8R0np/vcwZiLhsbWJEBILyaUWe8Ce5CtE6sos2GtueIi2BEN2LGrxhcdoXf9Mkkob/ZbqMZ2O42JQfrfuwWxFdU4EE4tU9AOkF71ZDxKyf2ls2sAwhan+XTRRltrXJYuOBut94oEC91I0gF3n8u42ebAwZGb+UhFzL/7K26csOb57yM5bvF9xJrLEObOkAAAAAMwoDLa+MZLFA4OAHPRDAYD54/hmMiOsgBBpcQ2/fVB0FXsFgPMcX85EpiWC28+deO51lDoISjk7NQNo0iiZMIe0wTdioaHkfxqWFhqLW7pmeEA+i/4pO2PYD7PtMaZHIFDQAJA1z6DQAAAAAADQAFAtZyAgAOBgABAhAREgkFQEIPAAAAAAAOKRATERIAAQMUBAIFBg8GBgYHCAYGBgYGBhQDBQkKDwoKCgsMCgoKCgoKEQBAQg8AAAAAAAaKAQAAAAAADgYAAQAQERIBBgEZjx9MOkUiY9QTss0X68vBoOWIc2TmJhoSqBeS6hZaPgAFAgcAAw4=`
  tx := base.Transaction{}
  err := tx.UnmarshalBase64(rawStr)
  if err != nil {
      panic(err)
  }

  j, _ := json.Marshal(tx)
  println(string(j))

This transaction is created by Raydium, when decode transaction by nodejs or gagliardetto/solana-go, it has accountTableLookups, when use okx/go-wallet-sdk/, it does not have accountTableLookups.

image

========================================== if you want to get the lookup table, please refer to this link, hope it work.

(https://docs.jup.ag/docs/additional-topics/composing-with-versioned-transaction)

viaweb3 commented 4 months ago

https://github.com/viaweb3/go-wallet-sdk/commit/20e09eeeb262af69759de11cb69d1bd838b1eb6f @leverwwz