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 an easy way to get missing txouts from data source crates for fee calculation #1083

Open
evanlinjin opened this issue Aug 21, 2023 · 1 comment
Labels
discussion There's still a discussion ongoing module-blockchain new feature New feature or request

Comments

@evanlinjin
Copy link
Member

Description

The TxGraph needs to have the prev txouts of a given tx to calculate the fee. Right now, when we sync/scan from our data source crates (esplora/electrum), these txouts are NOT obtained.

Some users would like to be able to calculate the fee for every full tx in the graph.

Thank you to @afilini for pointing this problem out to me.

Proposal

Add TxGraph::missing_prev_txouts method.

pub fn missing_prev_txouts(&self) -> impl Iterator<Item = OutPoint> { /* TODO */ }

Add fetch_txouts_only (better name?) method to EsploraExt and ElectrumExt. This is different to using scan_without_keychain with outpoints set. The intention here is to get partial transactions.

fn fetch_txouts_only(&self, outpoints: impl IntoIterator<Item = OutPoint>) -> <Vec<(OutPoint, TxOut)>, Error>;

We also should add a method to Wallet: add_txout(&mut self, outpoint: OutPoint, txout: TxOut), for users who would like to add arbitrary txouts.

Further Notes

Let's move forward with this once everyone comes to consensus as to what is needed.

@evanlinjin evanlinjin added new feature New feature or request discussion There's still a discussion ongoing labels Aug 21, 2023
@LLFourn
Copy link
Contributor

LLFourn commented Aug 21, 2023

Esplora always gives you the spent txouts for the transactions. I feel like we we used to insert them into the graph but looking at the code now we don't. See: https://docs.rs/esplora-client/latest/esplora_client/api/struct.Tx.html#method.previous_outputs. We should just insert all of those.

So this problem is restricted to electrum and block scanning apis. With electrum I think we can just have a enum flag to decide whether we fetch all inputs and whether we fetch the full input tx or we fetch it and then prune to relevant txouts (or none at all).

With block scanning we cannot easily go back in time and look things up so you just have to accept the limitation: you will not know the tx fee of transactions spending to you that did not have an input that originated from your wallet.

We also should add a method to Wallet: add_txout(&mut self, outpoint: OutPoint, txout: TxOut), for users who would like to add arbitrary txouts.

We have this already in #1048

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion There's still a discussion ongoing module-blockchain new feature New feature or request
Projects
Status: Todo
Development

No branches or pull requests

3 participants