You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Non-Wallet Tx verification doesn't work for RPC backend #498
running 1 test
thread 'test::test_transaction_validation' panicked at 'called `Result::unwrap()` on an `Err` value: Global(Rpc(JsonRpc(Rpc(RpcError { code: -5, message: "No such mempool transaction. Use -txindex or provide a block hash to enable blockchain transaction queries. Use gettransaction for wallet transactions.", data: None }))))', src/main.rs:335:63
stack backtrace:
Expected behavior verify_tx should verify any transaction, not only just wallet txs.
Possible recourse
We should enforce txindex to be used in rpc backend when using verify feature.
and instead each backend that benefits from verification (esplora, electrum) should verify the transactions as they come in during sync. Furthermore the verified field on TransactionDetails can be removed (this will be a non-breaking DB change hopefully).
and instead each backend that benefits from verification (esplora, electrum) should verify the transactions as they come in during sync.
Maybe I am missing something and forgot to ask this in the meeting, can you elaborate on whats the difference between electrum and esplora from rpc, in context of verification? They also have a bitcoin core backend running right? So transactions will be consensus verified in them too automatically?
Also in that case of refactoring, should verify_tx still be an public open function? or it will be something only internal to the syncs?
Another related thought, I feel like there's value in exposing the bitcoinconsensus through our API. There might be downstream usecases when dev needs to check for verification of custom transactions. There is no other exposed API wrapper around bitcoinconsensus as far as I know in the eco. I so feel like its important to keep the API live. Maybe make it an wallet API?
Maybe I am missing something and forgot to ask this in the meeting, can you elaborate on whats the difference between electrum and esplora from rpc, in context of verification? They also have a bitcoin core backend running right? So transactions will be consensus verified in them too automatically?
I think what @LLFourn meant is that if you're using rpc then it must be on your localhost and therefore you implicitly trust what ever transaction data you're getting. But for electrum or esplora you may be connecting to someone else's hosted service (ie. blockstream) and in that case it's a good idea to verify the transaction data.
Activity
LLFourn commentedon Dec 14, 2021
So on the call I think we agreed the solution here is not to verify the transactions on the rpc backend.
This bit of code has to be removed
bdk/src/wallet/mod.rs
Lines 1540 to 1555 in 64e88f0
and instead each backend that benefits from verification (esplora, electrum) should verify the transactions as they come in during sync. Furthermore the
verifiedfield onTransactionDetailscan be removed (this will be a non-breaking DB change hopefully).rajarshimaitra commentedon Dec 15, 2021
Maybe I am missing something and forgot to ask this in the meeting, can you elaborate on whats the difference between electrum and esplora from rpc, in context of verification? They also have a bitcoin core backend running right? So transactions will be consensus verified in them too automatically?
Also in that case of refactoring, should
verify_txstill be an public open function? or it will be something only internal to the syncs?Another related thought, I feel like there's value in exposing the
bitcoinconsensusthrough our API. There might be downstream usecases when dev needs to check for verification of custom transactions. There is no other exposed API wrapper aroundbitcoinconsensusas far as I know in the eco. I so feel like its important to keep the API live. Maybe make it an wallet API?notmandatory commentedon Dec 15, 2021
I think what @LLFourn meant is that if you're using
rpcthen it must be on your localhost and therefore you implicitly trust what ever transaction data you're getting. But forelectrumoresplorayou may be connecting to someone else's hosted service (ie. blockstream) and in that case it's a good idea to verify the transaction data.rajarshimaitra commentedon Dec 16, 2021
Ah ok, yes that makes sense. And I agree, verification is a costly operation and we should avoid that whenever possible.
rajarshimaitra commentedon Dec 16, 2021
I am working on a PR for this.
rajarshimaitra commentedon Jan 9, 2022
Closing after #502
Merge bitcoindevkit#502: Refactor verification logic
Merge bitcoindevkit#502: Refactor verification logic
Merge bitcoindevkit/bdk#502: Refactor verification logic
Merge bitcoindevkit/bdk#502: Refactor verification logic