Skip to content

Commit

Permalink
Revert "Cleanup (ordinals#3348)"
Browse files Browse the repository at this point in the history
This reverts commit 6f77b24.
  • Loading branch information
harutyunaraci committed Apr 2, 2024
1 parent 1762c87 commit 0f28f9a
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 25 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<BlockHash, jsonrpc_core::Error>;
fn get_best_block_hash(&self) -> Result<bitcoin::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<BlockHash, jsonrpc_core::Error> {
fn get_best_block_hash(&self) -> Result<bitcoin::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 Display for MintError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
impl fmt::Display for MintError {
fn fmt(&self, f: &mut fmt::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::<&PushBytes>(varint::encode(1).as_slice().try_into().unwrap())
.push_slice::<&PushBytes>(varint::encode(1).as_slice().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([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::<&PushBytes>(varint::encode(1).as_slice().try_into().unwrap())
.push_slice::<&PushBytes>(varint::encode(2).as_slice().try_into().unwrap())
.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([3, 0])
.into_script(),
value: 0,
Expand Down Expand Up @@ -1276,8 +1276,8 @@ mod tests {
.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::<&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(2).as_slice().try_into().unwrap())
.push_slice::<&PushBytes>(varint::encode(0).as_slice().try_into().unwrap())
.into_script(),
Expand Down
3 changes: 2 additions & 1 deletion src/subcommand/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ rpcport={bitcoind_port}
"failed to generate receive address: {status}"
);

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

let status = Command::new("bitcoin-cli")
.arg(format!("-datadir={relative}"))
Expand Down
16 changes: 9 additions & 7 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: Client,
bitcoin_client: bitcoincore_rpc::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 = HeaderMap::new();
let mut headers = header::HeaderMap::new();

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

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

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

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

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

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

let public_key = secret_key.to_public(secp)?;

let mut key_map = HashMap::new();
let mut key_map = std::collections::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 = TempDir::new().unwrap();
let tempdir = tempfile::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 = TempDir::new().unwrap();
let tempdir = tempfile::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 = TempDir::new().unwrap();
let tempdir = tempfile::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 = TempDir::new().unwrap();
let tempdir = tempfile::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 = TempDir::new().unwrap();
let tempdir = tempfile::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 = TempDir::new().unwrap();
let tempdir = tempfile::TempDir::new().unwrap();
let batch_file = tempdir.path().join("batch.yaml");
fs::write(
batch_file.clone(),
Expand Down

0 comments on commit 0f28f9a

Please sign in to comment.