Multisig

Struct Multisig 

Source
pub struct Multisig {
    pub create_key: Pubkey,
    pub config_authority: Pubkey,
    pub threshold: u16,
    pub time_lock: u32,
    pub transaction_index: u64,
    pub stale_transaction_index: u64,
    pub rent_collector: Option<Pubkey>,
    pub bump: u8,
    pub members: Vec<Member>,
}

Fields§

§create_key: Pubkey

Key that is used to seed the multisig PDA.

§config_authority: Pubkey

The authority that can change the multisig config. This is a very important parameter as this authority can change the members and threshold.

The convention is to set this to Pubkey::default(). In this case, the multisig becomes autonomous, so every config change goes through the normal process of voting by the members.

However, if this parameter is set to any other key, all the config changes for this multisig will need to be signed by the config_authority. We call such a multisig a “controlled multisig”.

§threshold: u16

Threshold for signatures.

§time_lock: u32

How many seconds must pass between transaction voting settlement and execution.

§transaction_index: u64

Last transaction index. 0 means no transactions have been created.

§stale_transaction_index: u64

Last stale transaction index. All transactions up until this index are stale. This index is updated when multisig config (members/threshold/time_lock) changes.

§rent_collector: Option<Pubkey>

The address where the rent for the accounts related to executed, rejected, or cancelled transactions can be reclaimed. If set to None, the rent reclamation feature is turned off.

§bump: u8

Bump for the multisig PDA seed.

§members: Vec<Member>

Members of the multisig.

Implementations§

Source§

impl Multisig

Source

pub fn size(members_length: usize) -> usize

Source

pub fn num_voters(members: &[Member]) -> usize

Source

pub fn num_proposers(members: &[Member]) -> usize

Source

pub fn num_executors(members: &[Member]) -> usize

Source

pub fn realloc_if_needed<'a>( multisig: AccountInfo<'a>, members_length: usize, rent_payer: Option<AccountInfo<'a>>, system_program: Option<AccountInfo<'a>>, ) -> Result<bool>

Check if the multisig account space needs to be reallocated to accommodate members_length. Returns true if the account was reallocated.

Source

pub fn invariant(&self) -> Result<()>

Source

pub fn invalidate_prior_transactions(&mut self)

Makes the transactions created up until this moment stale. Should be called whenever any multisig parameter related to the voting consensus is changed.

Source

pub fn is_member(&self, member_pubkey: Pubkey) -> Option<usize>

Returns Some(index) if member_pubkey is a member, with index into the members vec. None otherwise.

Source

pub fn member_has_permission( &self, member_pubkey: Pubkey, permission: Permission, ) -> bool

Source

pub fn cutoff(&self) -> usize

How many “reject” votes are enough to make the transaction “Rejected”. The cutoff must be such that it is impossible for the remaining voters to reach the approval threshold. For example: total voters = 7, threshold = 3, cutoff = 5.

Source

pub fn add_member(&mut self, new_member: Member)

Add new_member to the multisig members vec and sort the vec.

Source

pub fn remove_member(&mut self, member_pubkey: Pubkey) -> Result<()>

Remove member_pubkey from the multisig members vec.

§Errors
  • MultisigError::NotAMember if member_pubkey is not a member.

Trait Implementations§

Source§

impl AccountDeserialize for Multisig

Source§

fn try_deserialize(buf: &mut &[u8]) -> Result<Self>

Deserializes previously initialized account data. Should fail for all uninitialized accounts, where the bytes are zeroed. Implementations should be unique to a particular account type so that one can never successfully deserialize the data of one account type into another. For example, if the SPL token program were to implement this trait, it should be impossible to deserialize a Mint account into a token Account.
Source§

fn try_deserialize_unchecked(buf: &mut &[u8]) -> Result<Self>

Deserializes account data without checking the account discriminator. This should only be used on account initialization, when the bytes of the account are zeroed.
Source§

impl AccountSerialize for Multisig

Source§

fn try_serialize<W: Write>(&self, writer: &mut W) -> Result<()>

Serializes the account data into writer.
Source§

impl BorshDeserialize for Multisig

Source§

fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self, Error>

Source§

fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes.
Source§

fn try_from_slice(v: &[u8]) -> Result<Self, Error>

Deserialize this instance from a slice of bytes.
Source§

fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>
where R: Read,

Source§

impl BorshSerialize for Multisig

Source§

fn serialize<W: Write>(&self, writer: &mut W) -> Result<(), Error>

Source§

fn try_to_vec(&self) -> Result<Vec<u8>, Error>

Serialize this instance into a vector of bytes.
Source§

impl Clone for Multisig

Source§

fn clone(&self) -> Multisig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Discriminator for Multisig

Source§

impl Owner for Multisig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> AbiExample for T

Source§

default fn example() -> T

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V