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

Expose locked_outputs to users? #1549

Open
Thoralf-M opened this issue Nov 1, 2023 · 1 comment
Open

Expose locked_outputs to users? #1549

Thoralf-M opened this issue Nov 1, 2023 · 1 comment
Labels
m-wallet Module - Wallet t-investigate Task - Investigation

Comments

@Thoralf-M
Copy link
Member

Description

Expose locked_outputs or basically a duplication of it to users, so they manually can lock some outputs they don't want to be consumed in transactions?
Having two methods like .lock_output(output_id), .unlock_output(output_id) that add/remove this output id to/from the locked_outputs field of the wallet.

Motivation

For example one has a basic output with some metadata feature that one would like to keep and not consume in other transactions, then it would be nice if one can just call .lock_output(output_id), .unlock_output(output_id) to make it not available for transactions or later available again.

Requirements

  1. Add .lock_output(output_id) or .lock_output(output_id, "my precious metadata output".to_string()) and .unlock_output(output_id) which make outputs not or available to the input selection
  2. Make sure that users don't mess up transactions and that
    account.locked_outputs.retain(|input| {
    isn't messing up user locked outputs

Open questions (optional)

Currently locked_outputs is a HashSet locked_outputs: HashSet<OutputId> that is automatically filled/cleared based on selecting inputs/transactions, if we allow to just unlock any output id there, users could mess it up (unlock outputs that are already used as inputs in txs) which could lead to conflicting transactions. And user defined outputs would be also removed automatically here

account.locked_outputs.retain(|input| {
if that's not changed.
Therefore it might make sense to create a new HashSet for user defined locked outputs to keep them separated. Or maybe a HashMap<OutputId, Reason> would be better? Then users could even specify a reason for what they locked an output. Reason could be an enum like this

pub enum Reason {
    // Used as input in a transaction.
    TransactionInput,
    // Locked by the user.
    Custom(String),
}

Then .lock_output(output_id, "my precious metadata output".to_string())

Are you planning to do it yourself in a pull request?

No.

@Thoralf-M Thoralf-M added the m-wallet Module - Wallet label Nov 1, 2023
@Thoralf-M Thoralf-M added this to the v2.0.0 milestone Nov 1, 2023
@thibault-martinez thibault-martinez added the t-investigate Task - Investigation label Nov 2, 2023
@Thoralf-M
Copy link
Member Author

As a simpler but not so convenient alternative, forbidden_inputs could be added to the TransactionOptions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
m-wallet Module - Wallet t-investigate Task - Investigation
Projects
Status: Product Backlog
Development

No branches or pull requests

2 participants