From ee206b2ce92e2a2feb595c5d5ddf44fdad9de2f2 Mon Sep 17 00:00:00 2001 From: lifofifo Date: Tue, 16 Jan 2024 17:15:43 -0600 Subject: [PATCH 1/2] Allow inscribing a delegate without any batch or a file --- src/inscriptions/inscription.rs | 20 ++++++++++++++++++ src/subcommand/wallet/inscribe.rs | 35 +++++++++++++++++++++++++++---- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/src/inscriptions/inscription.rs b/src/inscriptions/inscription.rs index 271fa75efd..818ac95777 100644 --- a/src/inscriptions/inscription.rs +++ b/src/inscriptions/inscription.rs @@ -111,6 +111,26 @@ impl Inscription { }) } + pub(crate) fn without_file( + delegate: Option, + metadata: Option>, + metaprotocol: Option, + parent: Option, + pointer: Option, + ) -> Result { + Ok(Self { + body: None, + content_encoding: None, + content_type: None, + delegate: delegate.map(|delegate| delegate.value()), + metadata, + metaprotocol: metaprotocol.map(|metaprotocol| metaprotocol.into_bytes()), + parent: parent.map(|parent| parent.value()), + pointer: pointer.map(Self::pointer_value), + ..Default::default() + }) + } + pub(crate) fn pointer_value(pointer: u64) -> Vec { let mut bytes = pointer.to_le_bytes().to_vec(); diff --git a/src/subcommand/wallet/inscribe.rs b/src/subcommand/wallet/inscribe.rs index 7c036b5bf7..6c37fd3578 100644 --- a/src/subcommand/wallet/inscribe.rs +++ b/src/subcommand/wallet/inscribe.rs @@ -45,7 +45,7 @@ pub(crate) struct ParentInfo { #[clap( group = ArgGroup::new("source") .required(true) - .args(&["file", "batch"]), + .args(&["file", "batch", "delegate"]), )] pub(crate) struct Inscribe { #[arg( @@ -135,8 +135,8 @@ impl Inscribe { let parent_info; let sat; - match (self.file, self.batch) { - (Some(file), None) => { + match (self.file, self.batch, self.delegate) { + (Some(file), None, _) => { parent_info = Inscribe::get_parent_info(self.parent, &index, &utxos, &client, chain)?; postage = self.postage.unwrap_or(TARGET_POSTAGE); @@ -168,7 +168,7 @@ impl Inscribe { None => get_change_address(&client, chain)?, }]; } - (None, Some(batch)) => { + (None, Some(batch), _) => { let batchfile = Batchfile::load(&batch)?; parent_info = Inscribe::get_parent_info(batchfile.parent, &index, &utxos, &client, chain)?; @@ -196,6 +196,33 @@ impl Inscribe { sat = batchfile.sat; } + (None, None, Some(delegate)) => { + parent_info = Inscribe::get_parent_info(self.parent, &index, &utxos, &client, chain)?; + + postage = self.postage.unwrap_or(TARGET_POSTAGE); + + ensure! { + index.inscription_exists(delegate)?, + "delegate {delegate} does not exist" + } + + inscriptions = vec![Inscription::without_file( + self.delegate, + metadata, + self.metaprotocol, + self.parent, + None, + )?]; + + mode = Mode::SeparateOutputs; + + sat = self.sat; + + destinations = vec![match self.destination.clone() { + Some(destination) => destination.require_network(chain.network())?, + None => get_change_address(&client, chain)?, + }]; + } _ => unreachable!(), } From 7fc9271a5cf9190d3e20b7986932fab084869a67 Mon Sep 17 00:00:00 2001 From: lifofifo Date: Sat, 27 Jan 2024 11:52:49 -0600 Subject: [PATCH 2/2] Incorporate upstream changes --- src/subcommand/wallet/inscribe.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/subcommand/wallet/inscribe.rs b/src/subcommand/wallet/inscribe.rs index d242467d33..8237d78a32 100644 --- a/src/subcommand/wallet/inscribe.rs +++ b/src/subcommand/wallet/inscribe.rs @@ -149,12 +149,12 @@ impl Inscribe { sat = batchfile.sat; } (None, None, Some(delegate)) => { - parent_info = Inscribe::get_parent_info(self.parent, &index, &utxos, &client, chain)?; + parent_info = wallet.get_parent_info(self.parent, &utxos)?; postage = self.postage.unwrap_or(TARGET_POSTAGE); ensure! { - index.inscription_exists(delegate)?, + wallet.inscription_exists(delegate)?, "delegate {delegate} does not exist" } @@ -172,7 +172,7 @@ impl Inscribe { destinations = vec![match self.destination.clone() { Some(destination) => destination.require_network(chain.network())?, - None => get_change_address(&client, chain)?, + None => wallet.get_change_address()?, }]; } _ => unreachable!(),