pub async fn sign_and_broadcast(
		&mut self,
		mut tx: StacksTransaction,
	) -> anyhow::Result<StacksTxId> {
		#[cfg(debug_assertions)]
		{
			sleep(Duration::from_secs(3)).await;
		}

		tx.set_origin_nonce(self.get_nonce_info().await?.possible_next_nonce);
		tx.set_tx_fee(self.calculate_fee(tx.tx_len()).await?);

		tx.anchor_mode = TransactionAnchorMode::Any;
		tx.post_condition_mode = TransactionPostConditionMode::Allow;
		tx.chain_id = CHAIN_ID_TESTNET;

		let mut signer = StacksTransactionSigner::new(&tx);

		signer
			.sign_origin(
				&StacksPrivateKey::from_slice(
					&self
						.config
						.stacks_credentials
						.private_key()
						.secret_bytes(),
				)
				.unwrap(),
			)
			.unwrap();

		tx = signer.get_tx().unwrap();

		let mut tx_bytes = vec![];
		tx.consensus_serialize(&mut tx_bytes).unwrap();

		let res = self
			.send_request(|| {
				let tx_bytes = tx_bytes.clone();

				self.http_client
					.post(self.transaction_url())
					.header("Content-type", "application/octet-stream")
					.body(tx_bytes)
					.build()
					.unwrap()
			})
			.await?;

		Ok(res)
	}
Sign and broadcast an unsigned stacks transaction
romeo/src/stacks_client.rs