@@ -17,9 +17,9 @@ import (
17
17
18
18
"github.com/btcsuite/btcd/chaincfg"
19
19
"github.com/btcsuite/btcd/chaincfg/chainhash"
20
- "github.com/btcsuite/btcd/rpcclient"
21
20
"github.com/btcsuite/btcd/wire"
22
21
"github.com/btcsuite/btclog"
22
+ "github.com/btcsuite/btcwallet/chain"
23
23
"github.com/btcsuite/btcwallet/waddrmgr"
24
24
"github.com/btcsuite/btcwallet/wallet"
25
25
"github.com/btcsuite/btcwallet/walletdb"
@@ -708,9 +708,9 @@ func (d *DefaultWalletImpl) BuildChainControl(
708
708
// The broadcast is already always active for neutrino nodes, so we
709
709
// don't want to create a rebroadcast loop.
710
710
if partialChainControl .Cfg .NeutrinoCS == nil {
711
+ cs := partialChainControl .ChainSource
711
712
broadcastCfg := pushtx.Config {
712
713
Broadcast : func (tx * wire.MsgTx ) error {
713
- cs := partialChainControl .ChainSource
714
714
_ , err := cs .SendRawTransaction (
715
715
tx , true ,
716
716
)
@@ -724,7 +724,10 @@ func (d *DefaultWalletImpl) BuildChainControl(
724
724
// In case the backend is different from neutrino we
725
725
// make sure that broadcast backend errors are mapped
726
726
// to the neutrino broadcastErr.
727
- MapCustomBroadcastError : broadcastErrorMapper ,
727
+ MapCustomBroadcastError : func (err error ) error {
728
+ rpcErr := cs .MapRPCErr (err )
729
+ return broadcastErrorMapper (rpcErr )
730
+ },
728
731
}
729
732
730
733
lnWalletConfig .Rebroadcaster = newWalletReBroadcaster (
@@ -1475,41 +1478,40 @@ func parseHeaderStateAssertion(state string) (*headerfs.FilterHeader, error) {
1475
1478
// the neutrino BroadcastError which allows the Rebroadcaster which currently
1476
1479
// resides in the neutrino package to use all of its functionalities.
1477
1480
func broadcastErrorMapper (err error ) error {
1478
- returnErr := rpcclient . MapRPCErr ( err )
1481
+ var returnErr error
1479
1482
1480
1483
// We only filter for specific backend errors which are relevant for the
1481
1484
// Rebroadcaster.
1482
1485
switch {
1483
1486
// This makes sure the tx is removed from the rebroadcaster once it is
1484
1487
// confirmed.
1485
- case errors .Is (returnErr , rpcclient .ErrTxAlreadyKnown ),
1486
- errors .Is (err , rpcclient .ErrTxAlreadyConfirmed ):
1488
+ case errors .Is (err , chain .ErrTxAlreadyKnown ),
1489
+ errors .Is (err , chain .ErrTxAlreadyConfirmed ):
1487
1490
1488
1491
returnErr = & pushtx.BroadcastError {
1489
1492
Code : pushtx .Confirmed ,
1490
- Reason : returnErr .Error (),
1493
+ Reason : err .Error (),
1491
1494
}
1492
1495
1493
1496
// Transactions which are still in mempool but might fall out because
1494
1497
// of low fees are rebroadcasted despite of their backend error.
1495
- case errors .Is (returnErr , rpcclient .ErrTxAlreadyInMempool ):
1498
+ case errors .Is (err , chain .ErrTxAlreadyInMempool ):
1496
1499
returnErr = & pushtx.BroadcastError {
1497
1500
Code : pushtx .Mempool ,
1498
- Reason : returnErr .Error (),
1501
+ Reason : err .Error (),
1499
1502
}
1500
1503
1501
1504
// Transactions which are not accepted into mempool because of low fees
1502
1505
// in the first place are rebroadcasted despite of their backend error.
1503
1506
// Mempool conditions change over time so it makes sense to retry
1504
1507
// publishing the transaction. Moreover we log the detailed error so the
1505
1508
// user can intervene and increase the size of his mempool.
1506
- case errors .Is (err , rpcclient .ErrMempoolMinFeeNotMet ):
1507
- ltndLog .Warnf ("Error while broadcasting transaction: %v" ,
1508
- returnErr )
1509
+ case errors .Is (err , chain .ErrMempoolMinFeeNotMet ):
1510
+ ltndLog .Warnf ("Error while broadcasting transaction: %v" , err )
1509
1511
1510
1512
returnErr = & pushtx.BroadcastError {
1511
1513
Code : pushtx .Mempool ,
1512
- Reason : returnErr .Error (),
1514
+ Reason : err .Error (),
1513
1515
}
1514
1516
}
1515
1517
0 commit comments