-
Notifications
You must be signed in to change notification settings - Fork 9
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
(WIP!) Enable BIP-127 support #34
base: main
Are you sure you want to change the base?
Conversation
sorry for the late reply. I had a first quick look. But before diving in deeper, I want to get the CI working again. Is "point in time" proof validation already working? This is a highly desired feature. When I looked at this initially, I had only Electrum as a backend, and I couldn't see a way to support it with the Electrum server API. What kind of backend is required for this to work? |
Significant refactor to support these tests. * Add a `TxOutSet` trait for retrieving live Utxos * Implement `TxOutSet` for `&bdk::Wallet` * Implement `TxOutSet` for `&BTreeMap<OutPoint, TxOut>` * Add `WalletAtHeight` struct to support `max_block_height` use case previously supported * Implement `TxOutSet` for `WalletAtHeight` * Eliminate `ProofError::NonSpendableInput` and use `ProofError::OutpointNotFound` instead since `NonSpendableInput` interprets the actual fact that the outpoint is not found * Eliminate dead `ProofError::NeitherWitnessNorLegacy` variant * Add `ProofError::OutpointLookupError` variant for cases where the underlying `TxOutSet` generated an error. (Such as an RPC error) * Refactor other code to use these new primitives * Remove free `verify_proof` function
097c7a9 supports point in time validation using the esplora backend. I added some rudimentary tests and I think it's mostly correct but there's a couple of edge cases I need to think a bit about. Steve also said he wants bdk tests to use electrsd, which this doesn't (I'm just using the public mempool.space signet endpoint with esplora_client and a few txids I hand picked). Not sure if that's a blocker for merging, but this all should still be considered a WIP at the moment anyway. I want to add foreign utxo support using electrum and bitcoind rpc as well, I don't believe they can support full point-in-time though. I believe electrum can at least support a maximum block height (by which a user can establish a minimum number of confirmations) |
RE: using a public esplora instance in the tests, I actually had a test failure due to this, so the unreliability actually matters. |
There are already some regtest tests with electrsd in bdk-reserves. If I remember correctly, we would just have to add the esplora_a33e97e1 feature to be able to test using an esplora backend. |
I added a point in time test with electrsd / esplora but it fails. |
cba4130
to
fda985a
Compare
fda985a
to
a11cd3c
Compare
yeah WalletAtHeight cant support point in time regardless of backend (it's limited by the bdk database). You need the txout_set::PointInTimeTxOutSet trait which is implemented for the esplora blocking client, take a look at txout_set::test::test_spent_at_later_height it can be adapted to use electrsd. i was actually looking at it this morning too (but I need to get to my day job shortly) |
As far as I know this is what's possible:
While we're talking about it, I'm trying to come up with a concise term for the second case "UTXOs currently unspent, but confirmed before a certain height" |
Just to be precise, we have 2 (really 3) sets of transaction outputs
I believe some (all?) backends can support |
Very cool! I wanted to be able to verify proofs containing UTXOs that were spent after generating the proof since forever. Super glad that this can now be done. |
I added support for electrum |
I just added very WIP Once that's resolved, I think that will be everything I want to do with this PR, and I'll change from a draft to a "real" PR. (I imagine review will reveal some issues though)
|
DRAFT PR
This change set enables key parts of BIP-127 such that I believe it can be described as properly implementing most of BIP-127. Notably absent is the protobuf based multi-proof serialization. This change set adds:
PSBT_IN_POR_COMMITMENT
key is added to proof PSBTs. This enables BIP-127 supporting hardware signers to operate properly.Transaction
structure, PSBT metadata is not required to verify a BIP-127 proof. Add a compatibility layer to PSBTs which retains API compatibilityThis change set also includes changes from my
cleanup
branch which are not really relevant to discussion.I'm creating this draft PR now to discuss (and hopefully concept ACK) switching to single SHA-256, and moving validation onto
Transaction
In addition I'm seeking feedback on the
TxOutSet
trait I added. I think it's a useful abstraction, and it can facilitate "point in time" proofs, such as proving ownership of coins which are spent now, as well as out-of-wallet proofs in a seamless way.TxOutSet
in particular added quite a few lines of code however.