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

Implement burn #3437

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

onchainguy-eth
Copy link

After my first burn PR (#2766) got a bit outdated, I created a new one. Tried to make as less changes as possible. This PR does not support burn messages yet. Hope we can get the general burning merged first and then I'm happy to add support for an optional burn message via data pushes.

Copy link
Collaborator

@raphjaph raphjaph left a comment

Choose a reason for hiding this comment

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

Finally having a look at this. There's just two things but they probably require a bit of refactoring. Especially the new command ord wallet burn I think is important because burning is quite drastic and we want it to be a very distinct action.

src/subcommand/wallet/send.rs Outdated Show resolved Hide resolved
src/wallet/transaction_builder.rs Outdated Show resolved Hide resolved
@onchainguy-eth
Copy link
Author

@raphjaph thanks for the feedback, will get that done asap!

@onchainguy-eth
Copy link
Author

@raphjaph just implemented the changes. Let me know if I can improve on anything else. Can also write some more tests if you have ideas for some good ones.

Copy link
Collaborator

@raphjaph raphjaph left a comment

Choose a reason for hiding this comment

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

In OP_RETURNs there is no dust_limit and I see that you correctly disable the check for that. One thing you could try doing is only burn the exact sat that the inscription is on instead of the whole UTXO. This will require some careful changes to the TransactionBuilder, which should then be tested as well in the unit tests of the transaction_builder.rs file.

help = "Target <AMOUNT> postage with sent inscriptions. [default: 10000 sat]"
)]
pub(crate) postage: Option<Amount>,
outgoing: Outgoing,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
outgoing: Outgoing,
inscription_id: InscriptionId,

For now we only want to enable burning inscriptions, so let's make sure only that is possible. We'll add burning functionality to the other types (sats, btc, runes) later.

Comment on lines 3 to 14
#[derive(Clone, Copy)]
struct AddressParser;

#[derive(Clone, Debug, PartialEq)]
pub(crate) enum ParsedAddress {
Address(Address<NetworkUnchecked>),
ScriptBuf(ScriptBuf),
}

fn parse_address(arg: &str) -> Result<ParsedAddress, bitcoin::address::Error> {
Ok(ParsedAddress::Address(Address::from_str(arg)?))
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
#[derive(Clone, Copy)]
struct AddressParser;
#[derive(Clone, Debug, PartialEq)]
pub(crate) enum ParsedAddress {
Address(Address<NetworkUnchecked>),
ScriptBuf(ScriptBuf),
}
fn parse_address(arg: &str) -> Result<ParsedAddress, bitcoin::address::Error> {
Ok(ParsedAddress::Address(Address::from_str(arg)?))
}

Let's get rid of all of these. The burn command should just use the transaction builder directly with the correct TxOut, which can include an OP_RETURN script.

address: Address<NetworkUnchecked>,
outgoing: Outgoing,
#[arg(value_parser = parse_address)]
pub(crate) address: ParsedAddress,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
pub(crate) address: ParsedAddress,
pub(crate) address: Address,

@onchainguy-eth
Copy link
Author

In OP_RETURNs there is no dust_limit and I see that you correctly disable the check for that. One thing you could try doing is only burn the exact sat that the inscription is on instead of the whole UTXO. This will require some careful changes to the TransactionBuilder, which should then be tested as well in the unit tests of the transaction_builder.rs file.

@raphjaph Do you think that's worth it? If I'm not mistaking doing so would add additional inputs to the transaction for extracting the sat. The fee for that could potentially be higher than what the inscription sats are worth.

As an alternative idea: What if we exit the ord wallet burn command with an error if the inscription is on a utxo with more than 10_000 sats. This way we can prevent burning large bitcoin amounts by mistake. If people still want to burn the inscriptions, they can first transfer it to a different, smaller output.

@@ -62,6 +64,7 @@ impl Charm {
Self::Unbound => "🔓",
Self::Uncommon => "🌱",
Self::Vindicated => "❤️‍🔥",
Self::Burned => "💀🔥",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Self::Burned => "💀🔥",
Self::Burned => "🔥",

@raphjaph
Copy link
Collaborator

@raphjaph Do you think that's worth it? If I'm not mistaking doing so would add additional inputs to the transaction for extracting the sat. The fee for that could potentially be higher than what the inscription sats are worth.

That's true, then let's just leave it how it is for now.

As an alternative idea: What if we exit the ord wallet burn command with an error if the inscription is on a utxo with more than 10_000 sats. This way we can prevent burning large bitcoin amounts by mistake. If people still want to burn the inscriptions, they can first transfer it to a different, smaller output.

Sounds reasonble

@onchainguy-eth
Copy link
Author

@raphjaph Do you think that's worth it? If I'm not mistaking doing so would add additional inputs to the transaction for extracting the sat. The fee for that could potentially be higher than what the inscription sats are worth.

That's true, then let's just leave it how it is for now.

As an alternative idea: What if we exit the ord wallet burn command with an error if the inscription is on a utxo with more than 10_000 sats. This way we can prevent burning large bitcoin amounts by mistake. If people still want to burn the inscriptions, they can first transfer it to a different, smaller output.

Sounds reasonble

Cool, will adapt to that!

@raphjaph
Copy link
Collaborator

raphjaph commented Jun 2, 2024

Let me know when this is ready for review :)

@onchainguy-eth
Copy link
Author

@raphjaph Ready for review ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Ready for Review
Development

Successfully merging this pull request may close these issues.

None yet

2 participants