lnwallet: check mempool acceptance before publishing
This commit adds a mempool acceptance check before broadcasting a given transaction. To maintain the current behavior from `BtcWallet.PublishTransaction`, the two errors, `ErrInMempool` and `ErrAlreadyConfirmed` returned from `TestMempoolAccept` are ignored.
This commit is contained in:
2 files changed
+94
-8
No files matched your search
@@ -0,0 +1,21 @@
|
||||
package lnutils
|
||||
|
||||
import "errors"
|
||||
|
||||
// ErrorAs behaves the same as `errors.As` except there's no need to declare
|
||||
// the target error as a variable first.
|
||||
// Instead of writing:
|
||||
//
|
||||
// var targetErr *TargetErr
|
||||
// errors.As(err, &targetErr)
|
||||
//
|
||||
// We can write:
|
||||
//
|
||||
// lnutils.ErrorAs[*TargetErr](err)
|
||||
//
|
||||
// To save us from declaring the target error variable.
|
||||
func ErrorAs[Target error](err error) bool {
|
||||
var targetErr Target
|
||||
|
||||
return errors.As(err, &targetErr)
|
||||
}
|
||||
Reference in new issue
Block a user