diff --git a/src/index/updater/inscription_updater.rs b/src/index/updater/inscription_updater.rs index 7559f88b61..4eaf2639b8 100644 --- a/src/index/updater/inscription_updater.rs +++ b/src/index/updater/inscription_updater.rs @@ -256,7 +256,7 @@ impl<'a, 'db, 'tx> InscriptionUpdater<'a, 'db, 'tx> { pointer: inscription.payload.pointer(), unbound, }, - inscription_data: Some(inscription.inscription.clone()), + inscription_data: Some(inscription.payload.clone()), }); envelopes.next(); @@ -440,7 +440,7 @@ impl<'a, 'db, 'tx> InscriptionUpdater<'a, 'db, 'tx> { new_satpoint: SatPoint, ) -> Result { let inscription_id = flotsam.inscription_id.store(); - let mut new_inscription_number: i64 = 0; + let new_inscription_number: i64 = 0; let unbound = match flotsam.origin { Origin::Old { old_satpoint } => { self.satpoint_to_id.remove_all(&old_satpoint.store())?; @@ -534,7 +534,7 @@ impl<'a, 'db, 'tx> InscriptionUpdater<'a, 'db, 'tx> { new_inscription_number } else { let inscription_entry = self.id_to_entry.get(&inscription_id.store())?.unwrap(); - InscriptionEntry::load(inscription_entry.value()).number + InscriptionEntry::load(inscription_entry.value()).inscription_number }; if let Some(inscription) = flotsam.inscription_data { diff --git a/src/subcommand/file.rs b/src/subcommand/file.rs index 7cbce11f15..1c0d58e270 100644 --- a/src/subcommand/file.rs +++ b/src/subcommand/file.rs @@ -5,21 +5,32 @@ pub(crate) struct File { #[clap(long)] pub(crate) inscription: InscriptionId, #[clap()] - pub(crate) filename: String, + pub(crate) filename: PathBuf, } impl File { pub(crate) fn run(&self, options: Options) -> SubcommandResult { let client = options.bitcoin_rpc_client()?; - // TODO: not sure which one we need here - // let client = options.bitcoin_rpc_client_for_wallet_command(false)?; - let tx = client.get_raw_transaction(&self.inscription.txid, None)?; - let inscription = &Inscription::from_transaction(&tx)[self.inscription.index as usize]; + let inscriptions = ParsedEnvelope::from_transaction(&tx); + + let mut filename = self.filename.clone(); + let mut file_number = 2; + + for inscription in inscriptions { + println!("Saving inscription to file {:?}", filename); + let content_bytes = inscription.payload.body().unwrap(); + let mut file = fs::File::create(self.filename.clone())?; + file.write_all(content_bytes)?; - let content_bytes = inscription.inscription.body().unwrap(); - let mut file = fs::File::create(self.filename.clone())?; - file.write_all(content_bytes)?; + filename.set_file_name(format!( + "{}-{}{}", + filename.file_stem().unwrap().to_str().unwrap(), + file_number, + filename.extension().unwrap().to_str().unwrap() + )); + file_number += 1; + } Ok(Box::new(())) } diff --git a/src/subcommand/wallet/create.rs b/src/subcommand/wallet/create.rs index f5420424ce..e230a5b4d5 100644 --- a/src/subcommand/wallet/create.rs +++ b/src/subcommand/wallet/create.rs @@ -1,5 +1,5 @@ -use bitcoin::secp256k1::PublicKey; use bitcoin::bip32::{self, ExtendedPubKey}; +use bitcoin::secp256k1::PublicKey; use super::*;