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:
yyforyongyu committed 2024-01-25 07:54:39 +08:00
1 parent e4482421c9
commit 2686ca324a
2 files changed
+94 -8

No files matched your search

+21
View File
@@ -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)
}