Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command to list pending etchings #3732

Merged
merged 12 commits into from
May 17, 2024
4 changes: 4 additions & 0 deletions src/subcommand/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub mod outputs;
pub mod receive;
pub mod restore;
pub mod resume;
pub mod pending;
pub mod sats;
pub mod send;
mod shared_args;
Expand Down Expand Up @@ -67,6 +68,8 @@ pub(crate) enum Subcommand {
Restore(restore::Restore),
#[command(about = "Resume pending etchings")]
Resume(resume::Resume),
#[command(about = "List pending etchings")]
Pending(pending::Pending),
#[command(about = "List wallet satoshis")]
Sats(sats::Sats),
#[command(about = "Send sat or inscription")]
Expand Down Expand Up @@ -110,6 +113,7 @@ impl WalletCommand {
Subcommand::Outputs => outputs::run(wallet),
Subcommand::Receive(receive) => receive.run(wallet),
Subcommand::Resume(resume) => resume.run(wallet),
Subcommand::Pending(pending) => pending.run(wallet),
Subcommand::Sats(sats) => sats.run(wallet),
Subcommand::Send(send) => send.run(wallet),
Subcommand::Transactions(transactions) => transactions.run(wallet),
Expand Down
28 changes: 28 additions & 0 deletions src/subcommand/wallet/pending.rs
ldiego08 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use super::*;

#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
pub struct PendingOutput {
pub rune: SpacedRune,
pub commit: Txid,
}
#[derive(Debug, Parser)]
pub(crate) struct Pending {}

impl Pending {
pub(crate) fn run(self, wallet: Wallet) -> SubcommandResult {
let etchings = wallet
.pending_etchings()?
.into_iter()
.map(|(rune, entry)| {
let spaced_rune = rune.to_string().parse::<SpacedRune>().unwrap();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raphjaph what's the best way to get a SpacedRune from a Rune?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's buried inside the entry struct. Something like this:

let spaced_rune = entry.output.rune.unwrap().rune


PendingOutput {
rune: spaced_rune,
commit: entry.commit.txid()
}
})
.collect::<Vec<PendingOutput>>();

Ok(Some(Box::new(etchings) as Box<dyn Output>))
}
}