skynetcap/solanaj

invalid transaction: Transaction failed to sanitize accounts offsets correctly REOPEN

Closed this issue · 1 comments

So what was the root cause of transactions ? My Code
I have 0.001 sol on account

`@GetMapping("/send_transaction")
public ResponseEntity<?> sendTransaction() {
PublicKey fromPublicKey = new PublicKey("PUBLIC-EXAMPLE-SECURED");
PublicKey toPublickKey = new PublicKey("PUBLIC-EXAMPLE-SECURED");
int lamports = 10000;
String secretBase64 = "SECRET-KEY-EXAMPLE-SECURED";

    Account signer = new Account(Base64.getDecoder().decode(secretBase64));

    TransactionInstruction instruction = SystemProgram.transfer(
            fromPublicKey,
            toPublickKey,
            lamports
    );
    Transaction transaction = new Transaction();
    transaction.addInstruction(instruction);

    try {
        RpcApi api = client.getApi();

        transaction.setRecentBlockHash(api.getRecentBlockhash());
        transaction.sign(signer);

        return ResponseEntity.ok(api.sendTransaction(transaction, signer));

    } catch (RpcException e) {

        return ResponseEntity.status(500).body(e);
    }
}`

You aren't supposed to sign the transactions outside of RpcApi (it handles it for you). Remove that line and try again