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

Refactor spclient #46

Merged
merged 4 commits into from
Sep 30, 2024
Merged

Refactor spclient #46

merged 4 commits into from
Sep 30, 2024

Conversation

cygnet3
Copy link
Owner

@cygnet3 cygnet3 commented Sep 24, 2024

This PR intends to do a complete rework of the role of sp-client in regards to the callers of the library (e.g. Dana wallet).

Sp Client

Rework Sp-client to be a thin wrapper around rust-silentpayments. Sp-client only contains the bare minimum to operate a wallet: A scan key (private), a spend key (public/private), and the current bitcoin network.

Updater

Add a 'Updater' trait. This trait tells the caller that a certain persistent operation should be handled (e.g. 'mark this transaction mined').

ChainBackend

Add a 'ChainBackend' trait. This trait is called whenever chain data is required. For example, 'get utxos from this block'.

We also add a 'BlindbitBackend', which implements the ChainBackend trait. The BlindbitBackend is behind the optional 'blindbit-backend' feature.

Sp Scanner

Finally, there is the Sp Scanner. This is a new struct that goes along with the Sp client. The Sp Scanner takes a Sp-client, along with a boxed ChainBackend and Updater.

The scanner has a scan_blocks function, that takes a range and will scan the blocks for transactions. SpScanner requests block/utxo data from the ChainBackend. Whenever a new output is found, it calls 'updater.record_block_outputs', with the found outputs. The caller is then responsible for recording these outputs in their persistent storage.

Note

The trait definitions are very primitive, and they are clearly written around the blindbit model. The trait definitions should therefore not be considered final, but rather a starting point to be iterated on later.

@cygnet3 cygnet3 merged commit 09a70e4 into master Sep 30, 2024
2 checks passed
@cygnet3 cygnet3 deleted the refactor-spclient branch September 30, 2024 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant