Files
solana/faucet/src/faucet_mock.rs
Tyera Eulberg 03d3ae1cb9 Faucet: repurpose cap and slice args to apply to single IPs (#16381)
* Single use stmt

* Log request IP

* Switch cap and slice to apply per IP

* Use SOL in logs, error msgs

* Use thiserror instead of overloading io::Error

* Return memo transaction for requests that exceed per-request-cap

* Handle faucet memos in cli

* Add some docs, esp about memo transaction

* Use SOL symbol & standardize memo

Co-authored-by: Michael Vines <mvines@gmail.com>

* Differentiate faucet tx-length errors

* Populate signature in cli airdrop memo case

Co-authored-by: Michael Vines <mvines@gmail.com>
2021-04-06 07:01:05 +00:00

28 lines
702 B
Rust

use {
solana_sdk::{
hash::Hash, pubkey::Pubkey, signature::Keypair, system_transaction,
transaction::Transaction,
},
std::{
io::{Error, ErrorKind},
net::SocketAddr,
},
};
pub fn request_airdrop_transaction(
_faucet_addr: &SocketAddr,
_id: &Pubkey,
lamports: u64,
_blockhash: Hash,
) -> Result<Transaction, Error> {
if lamports == 0 {
Err(Error::new(ErrorKind::Other, "Airdrop failed"))
} else {
let key = Keypair::new();
let to = solana_sdk::pubkey::new_rand();
let blockhash = Hash::default();
let tx = system_transaction::transfer(&key, &to, lamports, blockhash);
Ok(tx)
}
}