Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The signature query obtained after the solana chain sign failed #318

Open
pingko opened this issue Nov 14, 2024 · 3 comments
Open

The signature query obtained after the solana chain sign failed #318

pingko opened this issue Nov 14, 2024 · 3 comments

Comments

@pingko
Copy link

pingko commented Nov 14, 2024

Describe the bug
When I listened to the solana_signTransaction method, I signed the message and got the signature. When I called web3Wallet.respondSessionRequest(), there was no error but it prompted "Error: Signature verification failed. Invalid signature for public key [My solana address]. In addition, I could not find this transaction on the solana browser.

To Reproduce
Steps to reproduce the behavior:

  1. Process the data when listening to solana_signTransaction. First, base58Decode the saved private key
  2. Get the keypair object and generate the message object
  3. Use Keypair to sign the compiledMessage
  4. Get the signature. After broadcasting it through web3Wallet.respondSessionRequest(), the signature cannot be queried on the blockchain browser. The current dApp page prompts an error message:
    "Error: Signature verification failed. Invalid signature for public key [My solana address].

Expected behavior
Transactions can be queried in the blockchain browser

Reproducible code

Screenshots
image

Desktop (please complete the following information):
Platform agnostic, doesnt matter which device i test on it allways does the explained issue

Smartphone (please complete the following information):
Developing a dApp wallet, Use walletconnectV2Flutter to trade in jito dApp

Additional context

Tasks

Preview Give feedback
No tasks being tracked yet.
@pingko
Copy link
Author

pingko commented Nov 14, 2024

use walletconnect_flutter_v2: ^2.4.1

@quetool
Copy link
Collaborator

quetool commented Nov 14, 2024

Hello @pingko, can you share the code in text format so I can copy/paste it on my side?

Regarding this

In addition, I could not find this transaction on the solana browser.

solana_signTransaction doesn't broadcast the transaction, it only signs it, that's why you don't see it in the explorer. Dapp should use solana_signAndSendTransaction to broadcast it.

@pingko
Copy link
Author

pingko commented Nov 14, 2024

Hello @quetool ,The code is as follows:

   /// get base58encode seckey from android native code
          String secKeyEncode = await getSignPrivateKey(arguments);
          final secKeyBytes =
              Uint8List.fromList(base58decode(secKeyEncode).sublist(0, 32));
          final keyPair = await Ed25519HDKeyPair.fromPrivateKeyBytes(
            privateKey: secKeyBytes,
          );

          if (keyPair.address != feePayer) {
            debugPrint('address error');
            handleWalletConnectData(response, 'transaction error', topic, false, 'SOL');
            return;
          }

          const encoder = JsonEncoder.withIndent('  ');
          final transaction = encoder.convert(params);
          // Sign the transaction.
          final instructions = instructionsList.map((json) {
            return (json as Map<String, dynamic>).toInstruction();
          }).toList();

          final message = Message(instructions: instructions);
          final compiledMessage = message.compile(
            recentBlockhash: recentBlockHash,
            feePayer: Ed25519HDPublicKey.fromBase58(feePayer),
          );

          final signature = await keyPair.sign(compiledMessage.toByteArray());

          response = response.copyWith(
            result: {
              'signature': signature.toBase58(),
            },
          );
          try {
            await web3Wallet.respondSessionRequest(
              topic: topic,
              response: response,
            );
            print('sign result:${response.result}...$signature');
          } on WalletConnectError catch (error) {
            print('WalletConnectError ${error.message}');
          }

I referred to solanaSignTransaction,However, I did not see the solana_signAndSendTransaction in the solana_service file. In evm_service, I can easily use ethClient.sendTransaction to get signedTx to get the signature. After requesting respondSessionRequest, I can find the signedTx in the blockchain browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants