SHA256
Добавить систему поддержки SHiNE
This commit is contained in:
@@ -290,6 +290,21 @@ export async function transferSol({ endpoint, fromKeypair, toAddress, amountSol
|
||||
return { endpoint: rpc, signature, lamports };
|
||||
}
|
||||
|
||||
/** Прямой перевод точной суммы в lamports, без преобразований через дробный SOL. */
|
||||
export async function transferSolLamports({ endpoint, fromKeypair, toAddress, amountLamports }) {
|
||||
const solana = await loadSolanaLib();
|
||||
const amount = BigInt(amountLamports);
|
||||
if (amount <= 0n || amount > BigInt(Number.MAX_SAFE_INTEGER)) throw new Error('Сумма вне безопасного диапазона прямого перевода');
|
||||
const connection = new solana.Connection(normalizeEndpoint(endpoint), 'confirmed');
|
||||
const tx = new solana.Transaction().add(solana.SystemProgram.transfer({
|
||||
fromPubkey: fromKeypair.publicKey,
|
||||
toPubkey: new solana.PublicKey(String(toAddress || '').trim()),
|
||||
lamports: Number(amount),
|
||||
}));
|
||||
const signature = await sendAndConfirmSolanaHttp(connection, tx, [fromKeypair]);
|
||||
return { signature, lamports: amount };
|
||||
}
|
||||
|
||||
export async function transferAllSol({ endpoint, fromKeypair, toAddress }) {
|
||||
const solana = await loadSolanaLib();
|
||||
const rpc = normalizeEndpoint(endpoint);
|
||||
|
||||
Reference in New Issue
Block a user