Skip to content

Commit 31d048c

Browse files
authored
Merge pull request #6014 from hstove/fix/remove-unused-stacks-client-methods
fix: remove unused stacks-client methods
2 parents 0d35a99 + 7817465 commit 31d048c

File tree

1 file changed

+1
-63
lines changed

1 file changed

+1
-63
lines changed

stacks-signer/src/client/stacks_client.rs

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ use std::time::{Duration, Instant};
2020
use blockstack_lib::chainstate::nakamoto::NakamotoBlock;
2121
use blockstack_lib::chainstate::stacks::boot::{NakamotoSignerEntry, SIGNERS_NAME};
2222
use blockstack_lib::chainstate::stacks::db::StacksBlockHeaderTypes;
23-
use blockstack_lib::chainstate::stacks::{
24-
StacksTransaction, StacksTransactionSigner, TransactionAnchorMode, TransactionAuth,
25-
TransactionContractCall, TransactionPayload, TransactionPostConditionMode,
26-
TransactionSpendingCondition, TransactionVersion,
27-
};
23+
use blockstack_lib::chainstate::stacks::TransactionVersion;
2824
use blockstack_lib::net::api::callreadonly::CallReadOnlyResponse;
2925
use blockstack_lib::net::api::get_tenures_fork_info::{
3026
TenureForkingInfo, RPC_TENURE_FORKING_INFO_PATH,
@@ -61,8 +57,6 @@ use crate::runloop::RewardCycleInfo;
6157
pub struct StacksClient {
6258
/// The stacks address of the signer
6359
stacks_address: StacksAddress,
64-
/// The private key used in all stacks node communications
65-
stacks_private_key: StacksPrivateKey,
6660
/// The stacks node HTTP base endpoint
6761
http_origin: String,
6862
/// The types of transactions
@@ -94,7 +88,6 @@ pub struct CurrentAndLastSortition {
9488
impl From<&GlobalConfig> for StacksClient {
9589
fn from(config: &GlobalConfig) -> Self {
9690
Self {
97-
stacks_private_key: config.stacks_private_key,
9891
stacks_address: config.stacks_address,
9992
http_origin: format!("http://{}", config.node_host),
10093
tx_version: config.network.to_transaction_version(),
@@ -123,7 +116,6 @@ impl StacksClient {
123116
};
124117
let stacks_address = StacksAddress::p2pkh(mainnet, &pubkey);
125118
Self {
126-
stacks_private_key,
127119
stacks_address,
128120
http_origin: format!("http://{}", node_host),
129121
tx_version,
@@ -756,60 +748,6 @@ impl StacksClient {
756748
fn tenure_tip_path(&self, consensus_hash: &ConsensusHash) -> String {
757749
format!("{}/v3/tenures/tip/{}", self.http_origin, consensus_hash)
758750
}
759-
760-
/// Helper function to create a stacks transaction for a modifying contract call
761-
#[allow(clippy::too_many_arguments)]
762-
pub fn build_unsigned_contract_call_transaction(
763-
contract_addr: &StacksAddress,
764-
contract_name: ContractName,
765-
function_name: ClarityName,
766-
function_args: &[ClarityValue],
767-
stacks_private_key: &StacksPrivateKey,
768-
tx_version: TransactionVersion,
769-
chain_id: u32,
770-
nonce: u64,
771-
) -> Result<StacksTransaction, ClientError> {
772-
let tx_payload = TransactionPayload::ContractCall(TransactionContractCall {
773-
address: *contract_addr,
774-
contract_name,
775-
function_name,
776-
function_args: function_args.to_vec(),
777-
});
778-
let public_key = StacksPublicKey::from_private(stacks_private_key);
779-
let tx_auth = TransactionAuth::Standard(
780-
TransactionSpendingCondition::new_singlesig_p2pkh(public_key).ok_or(
781-
ClientError::TransactionGenerationFailure(format!(
782-
"Failed to create spending condition from public key: {}",
783-
public_key.to_hex()
784-
)),
785-
)?,
786-
);
787-
788-
let mut unsigned_tx = StacksTransaction::new(tx_version, tx_auth, tx_payload);
789-
unsigned_tx.set_origin_nonce(nonce);
790-
791-
unsigned_tx.anchor_mode = TransactionAnchorMode::Any;
792-
unsigned_tx.post_condition_mode = TransactionPostConditionMode::Allow;
793-
unsigned_tx.chain_id = chain_id;
794-
Ok(unsigned_tx)
795-
}
796-
797-
/// Sign an unsigned transaction
798-
pub fn sign_transaction(
799-
&self,
800-
unsigned_tx: StacksTransaction,
801-
) -> Result<StacksTransaction, ClientError> {
802-
let mut tx_signer = StacksTransactionSigner::new(&unsigned_tx);
803-
tx_signer
804-
.sign_origin(&self.stacks_private_key)
805-
.map_err(|e| ClientError::TransactionGenerationFailure(e.to_string()))?;
806-
807-
tx_signer
808-
.get_tx()
809-
.ok_or(ClientError::TransactionGenerationFailure(
810-
"Failed to generate transaction from a transaction signer".to_string(),
811-
))
812-
}
813751
}
814752

815753
#[cfg(test)]

0 commit comments

Comments
 (0)