Remove RpcClient::resign_transaction()
This commit is contained in:
@ -24,7 +24,6 @@ use solana_sdk::{
|
|||||||
hash::Hash,
|
hash::Hash,
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
signature::Signature,
|
signature::Signature,
|
||||||
signers::Signers,
|
|
||||||
transaction::{self, Transaction},
|
transaction::{self, Transaction},
|
||||||
};
|
};
|
||||||
use solana_transaction_status::{
|
use solana_transaction_status::{
|
||||||
@ -415,17 +414,6 @@ impl RpcClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resign_transaction<T: Signers>(
|
|
||||||
&self,
|
|
||||||
tx: &mut Transaction,
|
|
||||||
signer_keys: &T,
|
|
||||||
) -> ClientResult<()> {
|
|
||||||
let (blockhash, _fee_calculator) =
|
|
||||||
self.get_new_blockhash(&tx.message().recent_blockhash)?;
|
|
||||||
tx.try_sign(signer_keys, blockhash)?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_account(&self, pubkey: &Pubkey) -> ClientResult<Account> {
|
pub fn get_account(&self, pubkey: &Pubkey) -> ClientResult<Account> {
|
||||||
self.get_account_with_commitment(pubkey, CommitmentConfig::default())?
|
self.get_account_with_commitment(pubkey, CommitmentConfig::default())?
|
||||||
.value
|
.value
|
||||||
@ -1161,28 +1149,6 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_resign_transaction() {
|
|
||||||
let rpc_client = RpcClient::new_mock("succeeds".to_string());
|
|
||||||
|
|
||||||
let key = Keypair::new();
|
|
||||||
let to = Pubkey::new_rand();
|
|
||||||
let blockhash: Hash = "HUu3LwEzGRsUkuJS121jzkPJW39Kq62pXCTmTa1F9jDL"
|
|
||||||
.parse()
|
|
||||||
.unwrap();
|
|
||||||
let prev_tx = system_transaction::transfer(&key, &to, 50, blockhash);
|
|
||||||
let mut tx = system_transaction::transfer(&key, &to, 50, blockhash);
|
|
||||||
|
|
||||||
rpc_client.resign_transaction(&mut tx, &[&key]).unwrap();
|
|
||||||
|
|
||||||
assert_ne!(prev_tx, tx);
|
|
||||||
assert_ne!(prev_tx.signatures, tx.signatures);
|
|
||||||
assert_ne!(
|
|
||||||
prev_tx.message().recent_blockhash,
|
|
||||||
tx.message().recent_blockhash
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_rpc_client_thread() {
|
fn test_rpc_client_thread() {
|
||||||
let rpc_client = RpcClient::new_mock("succeeds".to_string());
|
let rpc_client = RpcClient::new_mock("succeeds".to_string());
|
||||||
|
@ -205,7 +205,11 @@ fn send_message<S: Signers>(
|
|||||||
no_wait: bool,
|
no_wait: bool,
|
||||||
) -> Result<Signature, ClientError> {
|
) -> Result<Signature, ClientError> {
|
||||||
let mut transaction = Transaction::new_unsigned(message);
|
let mut transaction = Transaction::new_unsigned(message);
|
||||||
client.resign_transaction(&mut transaction, signers)?;
|
|
||||||
|
let (blockhash, _fee_calculator) =
|
||||||
|
client.get_new_blockhash(&transaction.message().recent_blockhash)?;
|
||||||
|
transaction.try_sign(signers, blockhash)?;
|
||||||
|
|
||||||
if no_wait {
|
if no_wait {
|
||||||
client.send_transaction(&transaction)
|
client.send_transaction(&transaction)
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user