Skip to content

Commit

Permalink
Formatting, fixes for clippy, small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Martin committed Apr 25, 2023
1 parent 982cb53 commit 4957fe6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 43 deletions.
14 changes: 7 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
Changelog
=========

[0.5.2-gm3](https://github.com/casey/ord/releases/tag/0.5.2-gm3) - 2023-04-25
-----------------------------------------------------------------------------
[0.5.2-gm3](https://github.com/gmart7t2/ord/releases/tag/0.5.2-gm3) - 2023-04-25
--------------------------------------------------------------------------------

### Added
- Add `destination-csv` to `ord wallet inscribe` input to allow you to define a list of destinations and filenames when inscribing ordinals.
- Add `--destination-csv` flag to `ord wallet inscribe` to provide a file containing a list of destinations and filenames when inscribing.

[0.5.2-gm2](https://github.com/casey/ord/releases/tag/0.5.2-gm2) - 2023-04-21
-----------------------------------------------------------------------------
[0.5.2-gm2](https://github.com/gmart7t2/ord/releases/tag/0.5.2-gm2) - 2023-04-21
--------------------------------------------------------------------------------

### Added
- Add `amount` and `content-type` fields to `ord inscriptions --number` and `ord inscriptions --id` output.

[0.5.2-gm1](https://github.com/casey/ord/releases/tag/0.5.2-gm1) - 2023-04-19
-----------------------------------------------------------------------------
[0.5.2-gm1](https://github.com/gmart7t2/ord/releases/tag/0.5.2-gm1) - 2023-04-19
--------------------------------------------------------------------------------

### Added
- Add `--id` and `--number` flags to `ord inscriptions` to list specific inscriptions by inscriptionid or by inscription number.
Expand Down
70 changes: 34 additions & 36 deletions src/subcommand/wallet/inscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ pub(crate) struct Inscribe {
help = "Use at most <MAX_INPUTS> inputs to build the commit transaction."
)]
pub(crate) max_inputs: Option<usize>,
#[clap(long, help = "Location of a CSV file to use for a combination of DESTINATION and FILE NAMES. Should be structured `destination,file`.")]
#[clap(
long,
help = "Location of a CSV file to use for a combination of DESTINATION and FILE NAMES. Should be structured `destination,file`."
)]
pub(crate) destination_csv: Option<PathBuf>,
}

Expand All @@ -111,11 +114,14 @@ impl Inscribe {
let mut client = options.bitcoin_rpc_client_for_wallet_command(false)?;

if let Some(destination_csv) = self.destination_csv {

if !self.files.is_empty() {
return Err(anyhow!("Cannot use both --destination-csv and provide files"));
} else if let Some(_) = self.destination {
return Err(anyhow!("Cannot use both --destination-csv and --destination"));
return Err(anyhow!(
"Cannot use both --destination-csv and provide files"
));
} else if self.destination.is_some() {
return Err(anyhow!(
"Cannot use both --destination-csv and --destination"
));
}

let destination_csv_ref = &destination_csv;
Expand All @@ -125,13 +131,13 @@ impl Inscribe {
let line = line?;
let mut split = line.split(',');
let destination = split.next().ok_or_else(|| {
anyhow::anyhow!(
"Destination CSV file {} is not formatted correctly",
destination_csv_ref.display()
)
anyhow!(
"Destination CSV file {} is not formatted correctly",
destination_csv_ref.display()
)
})?;
let file = split.next().ok_or_else(|| {
anyhow::anyhow!(
anyhow!(
"Destination CSV file {} is not formatted correctly",
destination_csv.display()
)
Expand All @@ -144,10 +150,12 @@ impl Inscribe {
for file in self.files {
inscription.push(Inscription::from_file(options.chain(), file)?);
}
destinations.push(self
.destination
.map(Ok)
.unwrap_or_else(|| get_change_address(&client))?);
destinations.push(
self
.destination
.map(Ok)
.unwrap_or_else(|| get_change_address(&client))?,
);
}

let index = Index::open(&options)?;
Expand Down Expand Up @@ -462,18 +470,12 @@ impl Inscribe {
));
taproot_spend_infos.push(taproot_spend_info);

let reveal_address = if destinations.len() > 1 {
&destinations[i]
} else {
&destinations[0]
};

let (_, reveal_fee) = Self::build_reveal_transaction(
&control_block,
reveal_fee_rate,
OutPoint::null(),
TxOut {
script_pubkey: reveal_address.script_pubkey(),
script_pubkey: destinations[i % destinations.len()].script_pubkey(),
value: 0,
},
&reveal_script,
Expand Down Expand Up @@ -501,14 +503,16 @@ impl Inscribe {

tprintln!("[remake reveals]");
let mut n = 0;
for (i, ((((control_block, reveal_script), key_pair), taproot_spend_info), commit_tx_address)) in
control_blocks
.iter()
.zip(reveal_scripts)
.zip(key_pairs)
.zip(taproot_spend_infos)
.zip(commit_tx_addresses)
.enumerate()
for (
i,
((((control_block, reveal_script), key_pair), taproot_spend_info), commit_tx_address),
) in control_blocks
.iter()
.zip(reveal_scripts)
.zip(key_pairs)
.zip(taproot_spend_infos)
.zip(commit_tx_addresses)
.enumerate()
{
let (vout, output) = unsigned_commit_tx
.output
Expand All @@ -517,12 +521,6 @@ impl Inscribe {
.find(|(_vout, output)| output.script_pubkey == commit_tx_address.script_pubkey())
.expect("should find sat commit/inscription output");

let reveal_address = if destinations.len() > 1 {
&destinations[i]
} else {
&destinations[0]
};

let (mut reveal_tx, fee) = Self::build_reveal_transaction(
control_block,
reveal_fee_rate,
Expand All @@ -531,7 +529,7 @@ impl Inscribe {
vout: vout.try_into().unwrap(),
},
TxOut {
script_pubkey: reveal_address.script_pubkey(),
script_pubkey: destinations[i % destinations.len()].script_pubkey(),
value: output.value,
},
&reveal_script,
Expand Down

0 comments on commit 4957fe6

Please sign in to comment.