There is an issue in the release_escrow command of V1 of escrow:
pub fn release_escrow(program_id: &Pubkey, accounts: &[AccountInfo], amount: u64) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let source = next_account_info(account_info_iter)?;
let destination = next_account_info(account_info_iter)?;
let authority = next_account_info(account_info_iter)?;
let token_program = next_account_info(account_info_iter)?;
let (authority_key, bump_seed) =
Pubkey::find_program_address(&[source.key.as_ref()], program_id);
if authority.key != &authority_key {
return Err(HelloWorldError::InvalidAuthority.into());
}
let authority_signer_seeds = &[source.key.as_ref(), &[bump_seed]];
spl_token_transfer(TokenTransferParams {
source: source.clone(),
destination: destination.clone(),
amount: 0,
authority: authority.clone(),
authority_signer_seeds: authority_signer_seeds,
token_program: token_program.clone(),
})?;
Ok(())
}
The amount is hardcoded to zero. The fix is to actually use amount. Suggested change:
pub fn release_escrow(program_id: &Pubkey, accounts: &[AccountInfo], amount: u64) -> ProgramResult {
let account_info_iter = &mut accounts.iter();
let source = next_account_info(account_info_iter)?;
let destination = next_account_info(account_info_iter)?;
let authority = next_account_info(account_info_iter)?;
let token_program = next_account_info(account_info_iter)?;
let (authority_key, bump_seed) =
Pubkey::find_program_address(&[source.key.as_ref()], program_id);
if authority.key != &authority_key {
return Err(HelloWorldError::InvalidAuthority.into());
}
let authority_signer_seeds = &[source.key.as_ref(), &[bump_seed]];
spl_token_transfer(TokenTransferParams {
source: source.clone(),
destination: destination.clone(),
amount: amount,
authority: authority.clone(),
authority_signer_seeds: authority_signer_seeds,
token_program: token_program.clone(),
})?;
Ok(())
}