49: Add high-level SOL send operations
This commit is contained in:
@@ -52,6 +52,42 @@ public interface SolanaWallet {
|
|||||||
@NotNull SolanaSPLTokenProgram splProgram
|
@NotNull SolanaSPLTokenProgram splProgram
|
||||||
) throws IOException, InterruptedException;
|
) throws IOException, InterruptedException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a specific amount of SOL to another wallet.
|
||||||
|
*
|
||||||
|
* <p>The wallet builds, signs and submits the required transaction.</p>
|
||||||
|
*
|
||||||
|
* @param recipient the wallet that should receive the SOL
|
||||||
|
* @param amount the amount of SOL to send
|
||||||
|
* @return the transaction signature returned by Solana RPC
|
||||||
|
* @throws IllegalArgumentException if the recipient or amount is invalid
|
||||||
|
* @throws IOException if the transaction cannot be built, signed or sent
|
||||||
|
* @throws InterruptedException if the calling thread is interrupted
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
ΩSolanaTransactionSignatureΩ sendSolana(
|
||||||
|
@NotNull ΩSolanaWalletIdΩ recipient,
|
||||||
|
@NotNull ΩSolanaAmountΩ amount
|
||||||
|
) throws IOException, InterruptedException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends the wallet's complete native SOL balance to another wallet after
|
||||||
|
* paying the exact transaction fee.
|
||||||
|
*
|
||||||
|
* <p>The wallet builds, signs and submits the required transaction.</p>
|
||||||
|
*
|
||||||
|
* @param recipient the wallet that should receive the SOL
|
||||||
|
* @return the transaction signature returned by Solana RPC
|
||||||
|
* @throws IllegalArgumentException if the recipient is invalid
|
||||||
|
* @throws IllegalStateException if the balance cannot cover a transfer
|
||||||
|
* @throws IOException if the transaction cannot be built, signed or sent
|
||||||
|
* @throws InterruptedException if the calling thread is interrupted
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
ΩSolanaTransactionSignatureΩ sendAllSolana(
|
||||||
|
@NotNull ΩSolanaWalletIdΩ recipient
|
||||||
|
) throws IOException, InterruptedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds an unsigned transaction that transfers a specific amount of SOL.
|
* Builds an unsigned transaction that transfers a specific amount of SOL.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -52,6 +52,40 @@ public class SolanaWalletImpl implements SolanaWallet {
|
|||||||
: tokenHolding.uiAmount();
|
: tokenHolding.uiAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull ΩSolanaTransactionSignatureΩ sendSolana(
|
||||||
|
@NotNull ΩSolanaWalletIdΩ recipient,
|
||||||
|
@NotNull ΩSolanaAmountΩ amount
|
||||||
|
) throws IOException, InterruptedException {
|
||||||
|
SolanaUnsignedTransaction unsignedTransaction =
|
||||||
|
solanaBlockChain.buildSolanaTransferTransaction(
|
||||||
|
address,
|
||||||
|
recipient,
|
||||||
|
amount
|
||||||
|
);
|
||||||
|
|
||||||
|
SolanaSignedTransaction signedTransaction =
|
||||||
|
signTransaction(unsignedTransaction);
|
||||||
|
|
||||||
|
return solanaBlockChain.sendTransaction(signedTransaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull ΩSolanaTransactionSignatureΩ sendAllSolana(
|
||||||
|
@NotNull ΩSolanaWalletIdΩ recipient
|
||||||
|
) throws IOException, InterruptedException {
|
||||||
|
SolanaUnsignedTransaction unsignedTransaction =
|
||||||
|
solanaBlockChain.buildSolanaTransferAllTransaction(
|
||||||
|
address,
|
||||||
|
recipient
|
||||||
|
);
|
||||||
|
|
||||||
|
SolanaSignedTransaction signedTransaction =
|
||||||
|
signTransaction(unsignedTransaction);
|
||||||
|
|
||||||
|
return solanaBlockChain.sendTransaction(signedTransaction);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull SolanaUnsignedTransaction buildSolanaTransferTransaction(
|
public @NotNull SolanaUnsignedTransaction buildSolanaTransferTransaction(
|
||||||
@NotNull ΩSolanaWalletIdΩ recipient,
|
@NotNull ΩSolanaWalletIdΩ recipient,
|
||||||
|
|||||||
Reference in New Issue
Block a user