From bfd31d845032c8302a6b0b195d28c7c760555748 Mon Sep 17 00:00:00 2001 From: Iceomatic <89707822+iceomatic@users.noreply.github.com> Date: Sun, 22 Sep 2024 18:08:42 +0800 Subject: [PATCH] fix: transaction_buffer_close seed constraints --- .../src/instructions/transaction_buffer_close.rs | 4 +++- .../src/instructions/transaction_buffer_extend.rs | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/programs/squads_multisig_program/src/instructions/transaction_buffer_close.rs b/programs/squads_multisig_program/src/instructions/transaction_buffer_close.rs index ea1bf37c..9f1fa76d 100644 --- a/programs/squads_multisig_program/src/instructions/transaction_buffer_close.rs +++ b/programs/squads_multisig_program/src/instructions/transaction_buffer_close.rs @@ -18,11 +18,13 @@ pub struct TransactionBufferClose<'info> { close = creator, // Only the creator can close the buffer constraint = transaction_buffer.creator == creator.key() @ MultisigError::Unauthorized, + // Account can be closed anytime by the creator, regardless of the + // current multisig transaction index seeds = [ SEED_PREFIX, multisig.key().as_ref(), SEED_TRANSACTION_BUFFER, - &multisig.transaction_index.checked_add(1).unwrap().to_le_bytes(), + &transaction_buffer.transaction_index.to_le_bytes(), ], bump )] diff --git a/programs/squads_multisig_program/src/instructions/transaction_buffer_extend.rs b/programs/squads_multisig_program/src/instructions/transaction_buffer_extend.rs index 7fcbd6b1..0ea56193 100644 --- a/programs/squads_multisig_program/src/instructions/transaction_buffer_extend.rs +++ b/programs/squads_multisig_program/src/instructions/transaction_buffer_extend.rs @@ -23,6 +23,8 @@ pub struct TransactionBufferExtend<'info> { mut, // Only the creator can extend the buffer constraint = transaction_buffer.creator == creator.key() @ MultisigError::Unauthorized, + // Extending the buffer only work if it still represents the next + // transaction index in the multisig seeds = [ SEED_PREFIX, multisig.key().as_ref(),