mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
2686ca324a
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.
22 lines
459 B
Go
22 lines
459 B
Go
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)
|
|
}
|