Let's say I have PDA A, PDA B, and PDA C. PDA A has lamports. And I like to split lamports to B and C. Is it possible in a single anchor function to transfer lamports from A to B and C?
// TRANSACTION 1 (From A to B)
**ctx.accounts.account_b.to_account_info().lamports.borrow_mut() = account_b_lamports
.checked_add(lamports_to_b)
.unwrap();
**ctx.accounts.account_a.to_account_info().lamports.borrow_mut() = account_a_lamports
.checked_sub(lamports_to_b)
.unwrap();
// TRANSACTION 2 (From A to C)
**ctx.accounts.account_c.to_account_info().lamports.borrow_mut() = account_c_lamports
.checked_add(lamports_to_c)
.unwrap();
**ctx.accounts.account_a.to_account_info().lamports.borrow_mut() = account_a_lamports
.checked_sub(lamports_to_c)
.unwrap();
Is this possible?
I'm running into a program error: Error processing Instruction 0