Add create-address-with-seed to solana-cli (#7472)

* Add create account with seed to cli

* clippy

* fixup
This commit is contained in:
Rob Walker
2019-12-14 04:38:24 -08:00
committed by GitHub
parent 2b5e919a47
commit f05860672c
10 changed files with 240 additions and 51 deletions

View File

@@ -139,7 +139,28 @@ pub fn initialize(stake_pubkey: &Pubkey, authorized: &Authorized, lockup: &Locku
)
}
pub fn create_stake_account_with_lockup(
pub fn create_account_with_seed(
from_pubkey: &Pubkey,
stake_pubkey: &Pubkey,
seed: &str,
authorized: &Authorized,
lockup: &Lockup,
lamports: u64,
) -> Vec<Instruction> {
vec![
system_instruction::create_account_with_seed(
from_pubkey,
stake_pubkey,
seed,
lamports,
std::mem::size_of::<StakeState>() as u64,
&id(),
),
initialize(stake_pubkey, authorized, lockup),
]
}
pub fn create_account(
from_pubkey: &Pubkey,
stake_pubkey: &Pubkey,
authorized: &Authorized,
@@ -183,29 +204,15 @@ pub fn split(
]
}
pub fn create_stake_account(
from_pubkey: &Pubkey,
stake_pubkey: &Pubkey,
authorized: &Authorized,
lamports: u64,
) -> Vec<Instruction> {
create_stake_account_with_lockup(
from_pubkey,
stake_pubkey,
authorized,
&Lockup::default(),
lamports,
)
}
pub fn create_stake_account_and_delegate_stake(
pub fn create_account_and_delegate_stake(
from_pubkey: &Pubkey,
stake_pubkey: &Pubkey,
vote_pubkey: &Pubkey,
authorized: &Authorized,
lockup: &Lockup,
lamports: u64,
) -> Vec<Instruction> {
let mut instructions = create_stake_account(from_pubkey, stake_pubkey, authorized, lamports);
let mut instructions = create_account(from_pubkey, stake_pubkey, authorized, lockup, lamports);
instructions.push(delegate_stake(
stake_pubkey,
&authorized.staker,