-
Notifications
You must be signed in to change notification settings - Fork 518
[POC/WIP] Add optional Bip352 silentpayments index #1075
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
base: master
Are you sure you want to change the base?
Conversation
6df1529 to
c1e110c
Compare
but I can make silent payments to the node, from a client? |
| if self | ||
| .index | ||
| .store | ||
| .iter_spending(SpendingPrefixRow::scan_prefix(outpoint)) | ||
| .next() | ||
| .is_none() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, this must make sure only transactions with (P2TR) unspent outputs are scanned.
Making an index dependent on data from another index seems odd to me, I have some questions about this:
- Does this handle collisions of
spendingentries in the database (correctly)? - Wouldn't a user want historic data after restoring a wallet?
- Looking at the code,
spendingis made sure to be updated to the current chain tip and thentweaksis indexed (do I get this correctly?). This will include spent transactions (imagine 1 P2TR output TXs) as blocks get propagated, but not on the initial sync or when spent in the same block. Is this intended?
| let height = index.chain.get_block_height(&hash).expect("Unexpected non existing blockhash"); | ||
| let mut value: Vec<u8> = u64::try_from(height).expect("Unexpected invalid usize").to_be_bytes().to_vec(); | ||
| value.extend(tweaks.iter()); | ||
| batch.tweak_rows.push(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, the key of the stored key-value pair is the block height. Is RocksDB the right tool for the job then? I think this can easily be achieved using two files that only need appending when building/updating the index: one for the tweaks, and one for the offsets and lengths in the tweaks file, for every block (for random access).
This PR proposes a new
--silent-payments-indexoption that creates an index of Bip352 silent payments.Most of the code is based on @Sosthene00's fork, but I made the following changes:
. It uses bitcoin-core/secp256k1#1519 and rust-bitcoin/rust-secp256k1#721 instead of the
rust-silentpaymentscrate.. It adds a new
--silent-payments-indexconfiguration option. Without this option, the server does not index silent payments and works the same as it does today.. The code does not use
Box[u8]indb.rs.To run this, something like the following command can be used:
cargo run -- --log-filters=INFO --db-dir <db_dir> --daemon-dir ~/.bitcoin/ --network signet --electrum-rpc-addr="127.0.0.1:60001" --silent-payments-index