Skip to content

Commit

Permalink
multi: remove ErrDoubleSpend check for PublishTransaction
Browse files Browse the repository at this point in the history
In this commit, we address a lingering issue within some subsystems that
are responsible for broadcasting transactions. Previously,
ErrDoubleSpend indicated that a transaction was already included in the
mempool/chain. This error was then modified to actually be returned for
conflicting transactions, but its callers were not modified accordingly.
This would lead to conflicting transactions to be interpreted as valid,
when they shouldn't be.
  • Loading branch information
wpaulino committed Mar 14, 2019
1 parent 5c5c542 commit 7946d0a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
5 changes: 2 additions & 3 deletions contractcourt/htlc_success_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/btcsuite/btcd/wire"
"github.com/davecgh/go-spew/spew"

"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lntypes"
Expand Down Expand Up @@ -148,7 +147,7 @@ func (h *htlcSuccessResolver) Resolve() (ContractResolver, error) {
// constructed, we'll broadcast the sweep transaction to the
// network.
err := h.PublishTx(h.sweepTx)
if err != nil && err != lnwallet.ErrDoubleSpend {
if err != nil {
log.Infof("%T(%x): unable to publish tx: %v",
h, h.payHash[:], err)
return nil, err
Expand Down Expand Up @@ -200,7 +199,7 @@ func (h *htlcSuccessResolver) Resolve() (ContractResolver, error) {
//
// TODO(roasbeef): after changing sighashes send to tx bundler
err := h.PublishTx(h.htlcResolution.SignedSuccessTx)
if err != nil && err != lnwallet.ErrDoubleSpend {
if err != nil {
return nil, err
}

Expand Down
2 changes: 1 addition & 1 deletion fundingmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ func (f *fundingManager) Start() error {
channel.IsInitiator {

err := f.cfg.PublishTransaction(channel.FundingTxn)
if err != nil && err != lnwallet.ErrDoubleSpend {
if err != nil {
fndgLog.Errorf("Unable to rebroadcast funding "+
"tx for ChannelPoint(%v): %v",
channel.FundingOutpoint, err)
Expand Down
2 changes: 1 addition & 1 deletion utxonursery.go
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ func (u *utxoNursery) sweepCribOutput(classHeight uint32, baby *babyOutput) erro
// We'll now broadcast the HTLC transaction, then wait for it to be
// confirmed before transitioning it to kindergarten.
err := u.cfg.PublishTransaction(baby.timeoutTx)
if err != nil && err != lnwallet.ErrDoubleSpend {
if err != nil {
utxnLog.Errorf("Unable to broadcast baby tx: "+
"%v, %v", err, spew.Sdump(baby.timeoutTx))
return err
Expand Down
3 changes: 1 addition & 2 deletions watchtower/lookout/punisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package lookout

import (
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/lnwallet"
)

// PunisherConfig houses the resources required by the Punisher.
Expand Down Expand Up @@ -44,7 +43,7 @@ func (p *BreachPunisher) Punish(desc *JusticeDescriptor, quit <-chan struct{}) e
desc.SessionInfo.ID, justiceTxn.TxHash())

err = p.cfg.PublishTx(justiceTxn)
if err != nil && err != lnwallet.ErrDoubleSpend {
if err != nil {
log.Errorf("Unable to publish justice txn for client=%s"+
"with breach-txid=%s: %v",
desc.SessionInfo.ID, desc.BreachedCommitTx.TxHash(), err)
Expand Down

0 comments on commit 7946d0a

Please sign in to comment.