diff --git a/programs/instant-send-program/src/instructions/initialize_transfer.rs b/programs/instant-send-program/src/instructions/initialize_transfer.rs index 21b599a..37362a2 100644 --- a/programs/instant-send-program/src/instructions/initialize_transfer.rs +++ b/programs/instant-send-program/src/instructions/initialize_transfer.rs @@ -44,6 +44,7 @@ impl<'info> InitializeTransferSPL<'info> { CpiContext::new(self.token_program.to_account_info(), cpi_accounts) } + // REVIEW: should be claim_rent_from_sender pub fn cliam_rent_from_sender(&self) -> Result<()> { let rent = Rent::get()?; let recipient_token_account_rent = rent.minimum_balance(TokenAccount::LEN); diff --git a/programs/instant-send-program/src/instructions/redeem_funds.rs b/programs/instant-send-program/src/instructions/redeem_funds.rs index bce1115..69b5c68 100644 --- a/programs/instant-send-program/src/instructions/redeem_funds.rs +++ b/programs/instant-send-program/src/instructions/redeem_funds.rs @@ -126,6 +126,7 @@ pub struct RedeemFundsSOL<'info> { } impl<'info> RedeemFundsSOL<'info> { + // REVIEW: I assume the secret is randomly generated, otherwise it would be better to use a hash and a salt pub fn verify_secret(&self, secret: &str) -> Result<()> { let provided_hash = { let mut hasher = Sha256::new(); @@ -140,6 +141,7 @@ impl<'info> RedeemFundsSOL<'info> { } pub fn transfer_sol_to_recipient(&self, amount: u64) -> Result<()> { + // REVIEW: you have to use the system program to transfer lamports, like you did in the initialize_transfer_spl instruction **self.recipient.to_account_info().try_borrow_mut_lamports()? += amount; **self.escrow_account.to_account_info().try_borrow_mut_lamports()? -= amount; Ok(()) @@ -166,6 +168,7 @@ pub fn redeem_funds_sol(ctx: Context, secret: String) -> Result< ctx.accounts.escrow_account.is_redeemed = true; ctx.accounts.transfer_sol_to_recipient(ctx.accounts.escrow_account.amount)?; + // REVIEW: after the transfer, the escrow account should be deleted // ctx.accounts.refund_remaining_lamports_to_sender()?; Ok(()) diff --git a/programs/instant-send-program/src/instructions/refund_funds.rs b/programs/instant-send-program/src/instructions/refund_funds.rs index 28f0d35..da0dbd0 100644 --- a/programs/instant-send-program/src/instructions/refund_funds.rs +++ b/programs/instant-send-program/src/instructions/refund_funds.rs @@ -31,6 +31,7 @@ pub struct RefundFundsSPL<'info> { } impl<'info> RefundFundsSPL<'info> { + // REVIEW: I assume the secret is randomly generated, otherwise it would be better to use a hash and a salt pub fn verify_secret(&self, secret: &str) -> Result<()> { let provided_hash = { let mut hasher = Sha256::new(); @@ -122,6 +123,7 @@ impl<'info> RefundFundsSOL<'info> { } pub fn transfer_sol_back_to_sender(&self, amount: u64) -> Result<()> { + // REVIEW: this also does not work because you need to call the system program to transfer lamports **self.sender.to_account_info().try_borrow_mut_lamports()? += amount; **self .escrow_account