btcsuite / btcwallet

A secure bitcoin wallet daemon written in Go (golang)
ISC License
1.13k stars 577 forks source link

chain: define and adhere to set of concrete errors for the `SendRawTransaction` interface method #515

Open Roasbeef opened 6 years ago

Roasbeef commented 6 years ago

Currently in several areas, we're forced to perform string checking in order to ensure we act accordingly. Examples include removing a transaction if we accidentally double spent one of our inputs, or realizing that the remote node already has the transaction in their mempool. The current scheme isn't ideal though, as we're forced to ensure proper coverage across all distinct backends at the highest level. Instead, we should define a set of concrete errors, that each backend is responsible for. This way, we can have a set of uniform checks at the very top level, and not have to worry about string matching.

A starting set of errors (to map to concrete errors) are the ones we currently use within lnd: https://github.com/lightningnetwork/lnd/blob/master/lnwallet/btcwallet/btcwallet.go#L374

kulpreet commented 6 years ago

Been open for a while, if no one is taking this, I am going to have a go at this.