Target repo
doublezerofoundation/doublezero-offchain
Background
In crates/solana-client-tools/src/payer.rs, Wallet has:
pub struct Wallet {
pub connection: SolanaConnection,
pub signer: Keypair,
pub compute_unit_price_ix: Option<Instruction>,
pub verbose: bool,
pub fee_payer: Option<Keypair>,
pub dry_run: bool,
}
When --fee-payer is unset, the signer (-k) pays. When --fee-payer is set, that keypair pays instead. Today there is no helper for "give me the pubkey that will actually pay this transaction's fees", so call sites that need it have to spell out:
wallet.fee_payer.as_ref().map(Signer::pubkey).unwrap_or_else(|| wallet.pubkey())
This came up during code review of doublezerofoundation/doublezero-offchain#373, where configure.rs was passing wallet_key (the signer pubkey) as the funding address to create_associated_token_account_idempotent. When --fee-payer is set, the funding address should be the fee-payer's pubkey, not the signer's. The in-PR fix uses the boilerplate above. A Wallet::fee_payer_key(&self) -> Pubkey helper would prevent every future call site from re-deriving it (and getting it wrong).
Proposal
Add to impl Wallet in crates/solana-client-tools/src/payer.rs:
/// Pubkey of the account that pays transaction fees and account rent for
/// this wallet: the `--fee-payer` keypair if set, otherwise the signer.
pub fn fee_payer_key(&self) -> Pubkey {
self.fee_payer.as_ref().map(Signer::pubkey).unwrap_or_else(|| self.signer.pubkey())
}
Then audit existing call sites that pass wallet.pubkey() or wallet_key as a "funding address" or "rent payer". They likely all want wallet.fee_payer_key() instead.
Cross-references
Target repo
doublezerofoundation/doublezero-offchain
Background
In
crates/solana-client-tools/src/payer.rs,Wallethas:When
--fee-payeris unset, the signer (-k) pays. When--fee-payeris set, that keypair pays instead. Today there is no helper for "give me the pubkey that will actually pay this transaction's fees", so call sites that need it have to spell out:This came up during code review of doublezerofoundation/doublezero-offchain#373, where
configure.rswas passingwallet_key(the signer pubkey) as the funding address tocreate_associated_token_account_idempotent. When--fee-payeris set, the funding address should be the fee-payer's pubkey, not the signer's. The in-PR fix uses the boilerplate above. AWallet::fee_payer_key(&self) -> Pubkeyhelper would prevent every future call site from re-deriving it (and getting it wrong).Proposal
Add to
impl Walletincrates/solana-client-tools/src/payer.rs:Then audit existing call sites that pass
wallet.pubkey()orwallet_keyas a "funding address" or "rent payer". They likely all wantwallet.fee_payer_key()instead.Cross-references