Skip to content

Commit

Permalink
Merge pull request #50 from metagood/fix-conflicts
Browse files Browse the repository at this point in the history
Fix conflicts
  • Loading branch information
ericatallah authored Oct 31, 2023
2 parents 5caddeb + d48936e commit 13ca96e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/index/updater/inscription_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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())?;
Expand Down Expand Up @@ -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 {
Expand Down
27 changes: 19 additions & 8 deletions src/subcommand/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(()))
}
Expand Down
2 changes: 1 addition & 1 deletion src/subcommand/wallet/create.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bitcoin::secp256k1::PublicKey;
use bitcoin::bip32::{self, ExtendedPubKey};
use bitcoin::secp256k1::PublicKey;

use super::*;

Expand Down

0 comments on commit 13ca96e

Please sign in to comment.