lnwallet: skip TestMempoolAccept for old backend versions

This commit is contained in:
yyforyongyu 2024-02-28 13:53:49 +08:00
parent a21e6610f2
commit 0d4472c5ea
No known key found for this signature in database
GPG key ID: 9BCD95C4FF296868

View file

@ -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
}