Skip to content

Commit

Permalink
Merge branch 'multiple-destinations'
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Martin committed Apr 26, 2023
2 parents ddc11b7 + b78a3a3 commit 7a992bd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
Changelog
=========

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

### Changed
- Shorten the `--destination-csv` flag for `wallet inscribe` to just `--csv`.
- If no `--destination` or `--csv` flag is provided to `wallet inscribe`, generate a different destination address for each inscription.
- Allow multiple `--destination` flags to `wallet inscribe`. If there are less destinations than files to inscribe, cycle through the destinations.

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

### Added
- Add `--csv` flag to `wallet inscribe` to provide a file containing a list of `<destination>,<filename>` pairs when inscribing.
- Add `--destination-csv` flag to `wallet inscribe` to provide a file containing a list of `<destination>,<filename>` pairs when inscribing.

### Changed
- Don't have `--no-broadcast` imply `--no-backup` in `wallet inscribe`..
Expand Down
4 changes: 2 additions & 2 deletions src/subcommand/preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ impl Preview {
dry_run: false,
dump: false,
no_limit: false,
destination: None,
destination: Vec::new(),
alignment: None,
postage: Some(TransactionBuilder::DEFAULT_TARGET_POSTAGE),
max_inputs: None,
destination_csv: None,
csv: None,
},
)),
}
Expand Down
35 changes: 18 additions & 17 deletions src/subcommand/wallet/inscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub(crate) struct Inscribe {
#[clap(long, help = "Dump raw hex transactions instead of sending them.")]
pub(crate) dump: bool,
#[clap(long, help = "Send inscription to <DESTINATION>.")]
pub(crate) destination: Option<Address>,
pub(crate) destination: Vec<Address>,
#[clap(long, help = "Send any alignment output to <ALIGNMENT>.")]
pub(crate) alignment: Option<Address>,
#[clap(
Expand All @@ -103,7 +103,7 @@ pub(crate) struct Inscribe {
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>,
pub(crate) csv: Option<PathBuf>,
}

impl Inscribe {
Expand All @@ -113,49 +113,50 @@ impl Inscribe {

let mut client = options.bitcoin_rpc_client_for_wallet_command(false)?;

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

let destination_csv_ref = &destination_csv;
let file = File::open(destination_csv_ref)?;
let file = File::open(&csv)?;
let reader = BufReader::new(file);
for line in reader.lines() {
let line = line?;
let mut split = line.split(',');
let destination = split.next().ok_or_else(|| {
anyhow!(
"Destination CSV file {} is not formatted correctly",
destination_csv_ref.display()
csv.display()
)
})?;
let file = split.next().ok_or_else(|| {
anyhow!(
"Destination CSV file {} is not formatted correctly",
destination_csv.display()
csv.display()
)
})?;
let file = PathBuf::from(file);
inscription.push(Inscription::from_file(options.chain(), file)?);
destinations.push(Address::from_str(destination)?);
}
} else {
for file in self.files {
for file in self.files.iter() {
inscription.push(Inscription::from_file(options.chain(), file)?);
}
destinations.push(
self
.destination
.map(Ok)
.unwrap_or_else(|| get_change_address(&client))?,
);
if self.destination.is_empty() {
for _ in self.files {
destinations.push(
get_change_address(&client)?);
}
} else {
destinations = self.destination;
}
}

let index = Index::open(&options)?;
Expand Down

0 comments on commit 7a992bd

Please sign in to comment.