From 0d4472c5eaeb6caad99cdbb29334c574cd49739d Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Wed, 28 Feb 2024 13:53:49 +0800 Subject: [PATCH] lnwallet: skip `TestMempoolAccept` for old backend versions --- lnwallet/btcwallet/btcwallet.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lnwallet/btcwallet/btcwallet.go b/lnwallet/btcwallet/btcwallet.go index 364953be4..fd4683509 100644 --- a/lnwallet/btcwallet/btcwallet.go +++ b/lnwallet/btcwallet/btcwallet.go @@ -14,6 +14,7 @@ import ( "github.com/btcsuite/btcd/btcutil/hdkeychain" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/rpcclient" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcwallet/chain" @@ -1262,6 +1263,18 @@ func (b *BtcWallet) PublishTransaction(tx *wire.MsgTx, label string) error { // or 10,000 sat/vb. results, err := b.chain.TestMempoolAccept([]*wire.MsgTx{tx}, 0) if err != nil { + // If the chain backend doesn't support the mempool acceptance + // test RPC, we'll just attempt to publish the transaction. + if errors.Is(err, rpcclient.ErrBackendVersion) { + log.Warnf("TestMempoolAccept not supported by "+ + "backend, consider upgrading %s to a newer "+ + "version", b.chain.BackEnd()) + + err := b.wallet.PublishTransaction(tx, label) + + return handleErr(err) + } + return err }