multi: update RPC error import path
These errors are now defined in `btcwallet/chain` instead of `btcd/rpcclient`.
This commit is contained in:
6 files changed
+24
-21
No files matched your search
@@ -1202,15 +1202,15 @@ func mapRpcclientError(err error) error {
|
||||
switch {
|
||||
// If the wallet reports a double spend, convert it to our internal
|
||||
// ErrDoubleSpend and return.
|
||||
case errors.Is(err, rpcclient.ErrMempoolConflict),
|
||||
errors.Is(err, rpcclient.ErrMissingInputs):
|
||||
case errors.Is(err, chain.ErrMempoolConflict),
|
||||
errors.Is(err, chain.ErrMissingInputs):
|
||||
|
||||
return lnwallet.ErrDoubleSpend
|
||||
|
||||
// If the wallet reports that fee requirements for accepting the tx
|
||||
// into mempool are not met, convert it to our internal ErrMempoolFee
|
||||
// and return.
|
||||
case errors.Is(err, rpcclient.ErrMempoolMinFeeNotMet):
|
||||
case errors.Is(err, chain.ErrMempoolMinFeeNotMet):
|
||||
return fmt.Errorf("%w: %v", lnwallet.ErrMempoolFee, err.Error())
|
||||
}
|
||||
|
||||
@@ -1295,9 +1295,9 @@ func (b *BtcWallet) PublishTransaction(tx *wire.MsgTx, label string) error {
|
||||
// `PublishTransaction` again because we need to mark the label in the
|
||||
// wallet. We can remove this exception once we have the above TODO
|
||||
// fixed.
|
||||
case errors.Is(err, rpcclient.ErrTxAlreadyInMempool),
|
||||
errors.Is(err, rpcclient.ErrTxAlreadyKnown),
|
||||
errors.Is(err, rpcclient.ErrTxAlreadyConfirmed):
|
||||
case errors.Is(err, chain.ErrTxAlreadyInMempool),
|
||||
errors.Is(err, chain.ErrTxAlreadyKnown),
|
||||
errors.Is(err, chain.ErrTxAlreadyConfirmed):
|
||||
|
||||
err := b.wallet.PublishTransaction(tx, label)
|
||||
return mapRpcclientError(err)
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/btcsuite/btcwallet/wallet"
|
||||
"github.com/lightningnetwork/lnd/lnmock"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
"github.com/stretchr/testify/mock"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -204,10 +205,12 @@ func TestCheckMempoolAcceptance(t *testing.T) {
|
||||
}}
|
||||
mockChain.On("TestMempoolAccept", []*wire.MsgTx{tx}, maxFeeRate).Return(
|
||||
results, nil).Once()
|
||||
mockChain.On("MapRPCErr", mock.Anything).Return(
|
||||
chain.ErrInsufficientFee).Once()
|
||||
|
||||
// Now call the method under test.
|
||||
err = wallet.CheckMempoolAcceptance(tx)
|
||||
rt.ErrorIs(err, rpcclient.ErrInsufficientFee)
|
||||
rt.ErrorIs(err, chain.ErrInsufficientFee)
|
||||
|
||||
// Assert that when the tx is accepted, no error is returned.
|
||||
//
|
||||
|
||||
@@ -1808,7 +1808,7 @@ func testPublishTransaction(r *rpctest.Harness,
|
||||
// If RBF is enabled, we expect it to be rejected
|
||||
// because it doesn't pay enough fees.
|
||||
if rbf {
|
||||
expectedErr = rpcclient.ErrInsufficientFee
|
||||
expectedErr = chain.ErrInsufficientFee
|
||||
}
|
||||
|
||||
// Assert the expected error.
|
||||
@@ -1891,7 +1891,7 @@ func testPublishTransaction(r *rpctest.Harness,
|
||||
// Now broadcast the transaction, we should get an error that
|
||||
// the weight is too large.
|
||||
err := alice.PublishTransaction(testTx, labels.External)
|
||||
require.ErrorIs(t, err, rpcclient.ErrOversizeTx)
|
||||
require.ErrorIs(t, err, chain.ErrOversizeTx)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user