diff --git a/src/main/tjava/com/r35157/cryptowallet/solana/SolanaWallet.tjava b/src/main/tjava/com/r35157/cryptowallet/solana/SolanaWallet.tjava index b8a0341..5b311cc 100644 --- a/src/main/tjava/com/r35157/cryptowallet/solana/SolanaWallet.tjava +++ b/src/main/tjava/com/r35157/cryptowallet/solana/SolanaWallet.tjava @@ -11,10 +11,11 @@ import java.io.IOException; import java.math.BigDecimal; /** - * A Solana wallet capable of identifying itself and signing transactions. + * A Solana wallet capable of identifying itself, signing transactions and + * submitting them to the Solana blockchain. * - *

Signing a transaction does not submit it to the Solana blockchain. - * Submission must be performed separately through {@code SolanaBlockChain}.

+ *

Signing and submission can be performed separately or as one complete + * operation.

*/ public interface SolanaWallet { /** @@ -106,4 +107,35 @@ public interface SolanaWallet { SolanaSignedTransaction signTransaction( @NotNull SolanaUnsignedTransaction transaction ) throws IOException, InterruptedException; + + /** + * Submits a signed Solana transaction to the Solana blockchain. + * + * @param transaction the signed transaction to submit + * @return the transaction signature returned by Solana RPC + * @throws IllegalArgumentException if the transaction is missing or blank + * @throws IOException if the transaction cannot be sent + * @throws InterruptedException if the calling thread is interrupted + */ + @NotNull + ΩSolanaTransactionSignatureΩ sendTransaction( + @NotNull SolanaSignedTransaction transaction + ) throws IOException, InterruptedException; + + /** + * Signs and submits an unsigned Solana transaction. + * + * @param transaction the unsigned transaction to sign and submit + * @return the transaction signature returned by Solana RPC + * @throws IllegalArgumentException if the transaction is missing or blank + * @throws IOException if the transaction cannot be signed or sent + * @throws InterruptedException if the signing process or calling thread + * is interrupted + */ + @NotNull + default ΩSolanaTransactionSignatureΩ signAndSendTransaction( + @NotNull SolanaUnsignedTransaction transaction + ) throws IOException, InterruptedException { + return sendTransaction(signTransaction(transaction)); + } } diff --git a/src/main/tjava/com/r35157/cryptowallet/solana/impl/ref/SolanaWalletImpl.tjava b/src/main/tjava/com/r35157/cryptowallet/solana/impl/ref/SolanaWalletImpl.tjava index db5899d..75493b5 100644 --- a/src/main/tjava/com/r35157/cryptowallet/solana/impl/ref/SolanaWalletImpl.tjava +++ b/src/main/tjava/com/r35157/cryptowallet/solana/impl/ref/SolanaWalletImpl.tjava @@ -171,6 +171,13 @@ public class SolanaWalletImpl implements SolanaWallet { return sst; } + @Override + public @NotNull ΩSolanaTransactionSignatureΩ sendTransaction( + @NotNull SolanaSignedTransaction transaction + ) throws IOException, InterruptedException { + return solanaBlockChain.sendTransaction(transaction); + } + private record SignerResponse( String signer, ΩBase64StringΩ signedTransaction