@@ -1205,7 +1205,7 @@ impl Processor {
1205
1205
) ?;
1206
1206
if validator_stake_info. transient_stake_lamports > 0 {
1207
1207
if maybe_ephemeral_stake_seed. is_none ( ) {
1208
- msg ! ( "Attempting to decrease stake on a validator with transient stake, use DecreaseAdditionalValidatorStake with the existing seed" ) ;
1208
+ msg ! ( "Attempting to decrease stake on a validator with pending transient stake, use DecreaseAdditionalValidatorStake with the existing seed" ) ;
1209
1209
return Err ( StakePoolError :: TransientAccountInUse . into ( ) ) ;
1210
1210
}
1211
1211
if transient_stake_seed != validator_stake_info. transient_seed_suffix {
@@ -1246,9 +1246,10 @@ impl Processor {
1246
1246
return Err ( ProgramError :: InsufficientFunds ) ;
1247
1247
}
1248
1248
1249
- let maybe_split_from_account_info =
1250
- if let Some ( ephemeral_stake_seed) = maybe_ephemeral_stake_seed {
1251
- let ephemeral_stake_account_info = maybe_ephemeral_stake_account_info. unwrap ( ) ;
1249
+ let source_stake_account_info =
1250
+ if let Some ( ( ephemeral_stake_seed, ephemeral_stake_account_info) ) =
1251
+ maybe_ephemeral_stake_seed. zip ( maybe_ephemeral_stake_account_info)
1252
+ {
1252
1253
let ephemeral_stake_bump_seed = check_ephemeral_stake_address (
1253
1254
program_id,
1254
1255
stake_pool_info. key ,
@@ -1287,39 +1288,37 @@ impl Processor {
1287
1288
stake_pool. stake_withdraw_bump_seed ,
1288
1289
) ?;
1289
1290
1290
- if validator_stake_info. transient_stake_lamports > 0 {
1291
- // transient stake exists, try to merge
1292
- let stake_history_info = maybe_stake_history_info. unwrap ( ) ;
1293
- Self :: stake_merge (
1294
- stake_pool_info. key ,
1295
- ephemeral_stake_account_info. clone ( ) ,
1296
- withdraw_authority_info. clone ( ) ,
1297
- AUTHORITY_WITHDRAW ,
1298
- stake_pool. stake_withdraw_bump_seed ,
1299
- transient_stake_account_info. clone ( ) ,
1300
- clock_info. clone ( ) ,
1301
- stake_history_info. clone ( ) ,
1302
- stake_program_info. clone ( ) ,
1303
- ) ?;
1304
- None
1305
- } else {
1306
- // otherwise, split everything from the ephemeral stake, into the transient
1307
- Some ( ephemeral_stake_account_info)
1308
- }
1291
+ ephemeral_stake_account_info
1309
1292
} else {
1310
1293
// if no ephemeral account is provided, split everything from the
1311
1294
// validator stake account, into the transient stake account
1312
- Some ( validator_stake_account_info)
1295
+ validator_stake_account_info
1313
1296
} ;
1314
1297
1315
- if let Some ( split_from_account_info) = maybe_split_from_account_info {
1316
- let transient_stake_bump_seed = check_transient_stake_address (
1317
- program_id,
1298
+ let transient_stake_bump_seed = check_transient_stake_address (
1299
+ program_id,
1300
+ stake_pool_info. key ,
1301
+ transient_stake_account_info. key ,
1302
+ & vote_account_address,
1303
+ transient_stake_seed,
1304
+ ) ?;
1305
+
1306
+ if validator_stake_info. transient_stake_lamports > 0 {
1307
+ let stake_history_info = maybe_stake_history_info. unwrap ( ) ;
1308
+ // transient stake exists, try to merge from the source account,
1309
+ // which is always an ephemeral account
1310
+ Self :: stake_merge (
1318
1311
stake_pool_info. key ,
1319
- transient_stake_account_info. key ,
1320
- & vote_account_address,
1321
- transient_stake_seed,
1312
+ source_stake_account_info. clone ( ) ,
1313
+ withdraw_authority_info. clone ( ) ,
1314
+ AUTHORITY_WITHDRAW ,
1315
+ stake_pool. stake_withdraw_bump_seed ,
1316
+ transient_stake_account_info. clone ( ) ,
1317
+ clock_info. clone ( ) ,
1318
+ stake_history_info. clone ( ) ,
1319
+ stake_program_info. clone ( ) ,
1322
1320
) ?;
1321
+ } else {
1323
1322
let transient_stake_account_signer_seeds: & [ & [ _ ] ] = & [
1324
1323
TRANSIENT_STAKE_SEED_PREFIX ,
1325
1324
& vote_account_address. to_bytes ( ) ,
@@ -1337,7 +1336,7 @@ impl Processor {
1337
1336
// split into transient stake account
1338
1337
Self :: stake_split (
1339
1338
stake_pool_info. key ,
1340
- split_from_account_info . clone ( ) ,
1339
+ source_stake_account_info . clone ( ) ,
1341
1340
withdraw_authority_info. clone ( ) ,
1342
1341
AUTHORITY_WITHDRAW ,
1343
1342
stake_pool. stake_withdraw_bump_seed ,
0 commit comments