Skip to content

Commit

Permalink
Cleanup (#3348)
Browse files Browse the repository at this point in the history
  • Loading branch information
lugondev authored Mar 23, 2024
1 parent a2c1a1d commit 418670c
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 28 deletions.
2 changes: 1 addition & 1 deletion crates/test-bitcoincore-rpc/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub trait Api {
fn get_balances(&self) -> Result<GetBalancesResult, jsonrpc_core::Error>;

#[rpc(name = "getbestblockhash")]
fn get_best_block_hash(&self) -> Result<bitcoin::BlockHash, jsonrpc_core::Error>;
fn get_best_block_hash(&self) -> Result<BlockHash, jsonrpc_core::Error>;

#[rpc(name = "getblockhash")]
fn get_block_hash(&self, height: usize) -> Result<BlockHash, jsonrpc_core::Error>;
Expand Down
2 changes: 1 addition & 1 deletion crates/test-bitcoincore-rpc/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Api for Server {
})
}

fn get_best_block_hash(&self) -> Result<bitcoin::BlockHash, jsonrpc_core::Error> {
fn get_best_block_hash(&self) -> Result<BlockHash, jsonrpc_core::Error> {
match self.state().hashes.last() {
Some(block_hash) => Ok(*block_hash),
None => Err(Self::not_found()),
Expand Down
6 changes: 3 additions & 3 deletions src/runes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ pub enum MintError {
Unmintable(Rune),
}

impl fmt::Display for MintError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
impl Display for MintError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
MintError::Deadline((rune, deadline)) => {
write!(f, "rune {rune} mint ended at {deadline}")
Expand Down Expand Up @@ -5276,7 +5276,7 @@ mod tests {
..Default::default()
});

context.mine_blocks((RUNE_COMMIT_INTERVAL).into());
context.mine_blocks(RUNE_COMMIT_INTERVAL.into());

let mut witness = Witness::new();

Expand Down
12 changes: 6 additions & 6 deletions src/runes/runestone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,8 @@ mod tests {
.push_opcode(MAGIC_NUMBER)
.push_opcode(opcodes::all::OP_VERIFY)
.push_slice([0])
.push_slice::<&script::PushBytes>(varint::encode(1).as_slice().try_into().unwrap())
.push_slice::<&script::PushBytes>(varint::encode(1).as_slice().try_into().unwrap())
.push_slice::<&PushBytes>(varint::encode(1).as_slice().try_into().unwrap())
.push_slice::<&PushBytes>(varint::encode(1).as_slice().try_into().unwrap())
.push_slice([2, 0])
.into_script(),
value: 0,
Expand All @@ -495,8 +495,8 @@ mod tests {
.push_opcode(opcodes::all::OP_RETURN)
.push_opcode(MAGIC_NUMBER)
.push_slice([0])
.push_slice::<&script::PushBytes>(varint::encode(1).as_slice().try_into().unwrap())
.push_slice::<&script::PushBytes>(varint::encode(2).as_slice().try_into().unwrap())
.push_slice::<&PushBytes>(varint::encode(1).as_slice().try_into().unwrap())
.push_slice::<&PushBytes>(varint::encode(2).as_slice().try_into().unwrap())
.push_slice([3, 0])
.into_script(),
value: 0,
Expand Down Expand Up @@ -1276,8 +1276,8 @@ mod tests {
.try_into()
.unwrap()
)
.push_slice::<&script::PushBytes>(varint::encode(1).as_slice().try_into().unwrap())
.push_slice::<&script::PushBytes>(varint::encode(1).as_slice().try_into().unwrap())
.push_slice::<&PushBytes>(varint::encode(1).as_slice().try_into().unwrap())
.push_slice::<&PushBytes>(varint::encode(1).as_slice().try_into().unwrap())
.push_slice::<&PushBytes>(varint::encode(2).as_slice().try_into().unwrap())
.push_slice::<&PushBytes>(varint::encode(0).as_slice().try_into().unwrap())
.into_script(),
Expand Down
3 changes: 1 addition & 2 deletions src/subcommand/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ rpcport={bitcoind_port}
"failed to generate receive address: {status}"
);

let receive =
serde_json::from_slice::<crate::subcommand::wallet::receive::Output>(&output.stdout)?;
let receive = serde_json::from_slice::<wallet::receive::Output>(&output.stdout)?;

let status = Command::new("bitcoin-cli")
.arg(format!("-datadir={relative}"))
Expand Down
16 changes: 7 additions & 9 deletions src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl OrdClient {
}

pub(crate) struct Wallet {
bitcoin_client: bitcoincore_rpc::Client,
bitcoin_client: Client,
has_rune_index: bool,
has_sat_index: bool,
rpc_url: Url,
Expand All @@ -61,7 +61,7 @@ impl Wallet {
settings: Settings,
rpc_url: Url,
) -> Result<Self> {
let mut headers = header::HeaderMap::new();
let mut headers = HeaderMap::new();

headers.insert(
header::ACCEPT,
Expand Down Expand Up @@ -209,7 +209,7 @@ impl Wallet {
Ok(output_json)
}

fn get_utxos(bitcoin_client: &bitcoincore_rpc::Client) -> Result<BTreeMap<OutPoint, TxOut>> {
fn get_utxos(bitcoin_client: &Client) -> Result<BTreeMap<OutPoint, TxOut>> {
Ok(
bitcoin_client
.list_unspent(None, None, None, None, None)?
Expand All @@ -227,12 +227,10 @@ impl Wallet {
)
}

fn get_locked_utxos(
bitcoin_client: &bitcoincore_rpc::Client,
) -> Result<BTreeMap<OutPoint, TxOut>> {
fn get_locked_utxos(bitcoin_client: &Client) -> Result<BTreeMap<OutPoint, TxOut>> {
#[derive(Deserialize)]
pub(crate) struct JsonOutPoint {
txid: bitcoin::Txid,
txid: Txid,
vout: u32,
}

Expand Down Expand Up @@ -325,7 +323,7 @@ impl Wallet {
)))
}

pub(crate) fn bitcoin_client(&self) -> &bitcoincore_rpc::Client {
pub(crate) fn bitcoin_client(&self) -> &Client {
&self.bitcoin_client
}

Expand Down Expand Up @@ -625,7 +623,7 @@ impl Wallet {

let public_key = secret_key.to_public(secp)?;

let mut key_map = std::collections::HashMap::new();
let mut key_map = HashMap::new();
key_map.insert(public_key.clone(), secret_key);

let descriptor = miniscript::descriptor::Descriptor::new_tr(public_key, None)?;
Expand Down
12 changes: 6 additions & 6 deletions src/wallet/inscribe/batchfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ mod tests {

#[test]
fn batchfile_not_sat_and_satpoint() {
let tempdir = tempfile::TempDir::new().unwrap();
let tempdir = TempDir::new().unwrap();
let batch_file = tempdir.path().join("batch.yaml");
fs::write(
batch_file.clone(),
Expand All @@ -227,7 +227,7 @@ inscriptions:

#[test]
fn batchfile_wrong_mode_for_satpoints() {
let tempdir = tempfile::TempDir::new().unwrap();
let tempdir = TempDir::new().unwrap();
let batch_file = tempdir.path().join("batch.yaml");
fs::write(
batch_file.clone(),
Expand All @@ -254,7 +254,7 @@ inscriptions:

#[test]
fn batchfile_missing_satpoint() {
let tempdir = tempfile::TempDir::new().unwrap();
let tempdir = TempDir::new().unwrap();
let batch_file = tempdir.path().join("batch.yaml");
fs::write(
batch_file.clone(),
Expand All @@ -280,7 +280,7 @@ inscriptions:

#[test]
fn batchfile_only_first_sat_of_outpoint() {
let tempdir = tempfile::TempDir::new().unwrap();
let tempdir = TempDir::new().unwrap();
let batch_file = tempdir.path().join("batch.yaml");
fs::write(
batch_file.clone(),
Expand All @@ -307,7 +307,7 @@ inscriptions:

#[test]
fn batchfile_no_postage_if_mode_satpoints() {
let tempdir = tempfile::TempDir::new().unwrap();
let tempdir = TempDir::new().unwrap();
let batch_file = tempdir.path().join("batch.yaml");
fs::write(
batch_file.clone(),
Expand Down Expand Up @@ -335,7 +335,7 @@ inscriptions:

#[test]
fn batchfile_no_duplicate_satpoints() {
let tempdir = tempfile::TempDir::new().unwrap();
let tempdir = TempDir::new().unwrap();
let batch_file = tempdir.path().join("batch.yaml");
fs::write(
batch_file.clone(),
Expand Down

0 comments on commit 418670c

Please sign in to comment.