Add helper for paring down signers to those requried by a tx message (bp #15899) (#15937)

* sdk: Add accessor for signer pubkeys of a tx message

(cherry picked from commit bf33ce8906)

* clap-utils: Add helper to `CliSignerInfo` for getting signers for a message

(cherry picked from commit 4e99f1e634)

Co-authored-by: Trent Nelson <trent@solana.com>
This commit is contained in:
mergify[bot]
2021-03-17 05:22:40 +00:00
committed by GitHub
parent 6a334a8bef
commit eed62bc408
2 changed files with 54 additions and 0 deletions

View File

@@ -435,6 +435,15 @@ impl Message {
accounts,
})
}
pub fn signer_keys(&self) -> Vec<&Pubkey> {
// Clamp in case we're working on un-`sanitize()`ed input
let last_key = self
.account_keys
.len()
.max(self.header.num_required_signatures as usize);
self.account_keys[..last_key].iter().collect()
}
}
#[cfg(test)]