Skip to content

Commit

Permalink
Merge ec256cc into 9f32942
Browse files Browse the repository at this point in the history
  • Loading branch information
wpaulino committed Jun 2, 2020
2 parents 9f32942 + ec256cc commit fb24413
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions fundingmanager.go
Expand Up @@ -552,13 +552,33 @@ func (f *fundingManager) start() error {
if chanType.IsSingleFunder() && chanType.HasFundingTx() &&
channel.IsInitiator {

err := f.cfg.PublishTransaction(
var fundingTxBuf bytes.Buffer
err := channel.FundingTxn.Serialize(&fundingTxBuf)
if err != nil {
fndgLog.Errorf("Unable to serialize "+
"funding transaction %v: %v",
channel.FundingTxn.TxHash(), err)

// Clear the buffer of any bytes that
// were written before the serialization
// error to prevent logging an
// incomplete transaction.
fundingTxBuf.Reset()
}

fndgLog.Debugf("Rebroadcasting funding tx for "+
"ChannelPoint(%v): %x",
channel.FundingOutpoint,
fundingTxBuf.Bytes())

err = f.cfg.PublishTransaction(
channel.FundingTxn, "",
)
if err != nil {
fndgLog.Errorf("Unable to rebroadcast "+
"funding tx for "+
"funding tx %x for "+
"ChannelPoint(%v): %v",
fundingTxBuf.Bytes(),
channel.FundingOutpoint, err)
}
}
Expand Down Expand Up @@ -1991,14 +2011,19 @@ func (f *fundingManager) handleFundingSigned(fmsg *fundingSignedMsg) {
// if we actually have the funding transaction.
if completeChan.ChanType.HasFundingTx() {
fundingTx := completeChan.FundingTxn
var fundingTxBuf bytes.Buffer
if err := fundingTx.Serialize(&fundingTxBuf); err != nil {
fndgLog.Errorf("Unable to serialize funding "+
"transaction %v: %v", fundingTx.TxHash(), err)
}

fndgLog.Infof("Broadcasting funding tx for ChannelPoint(%v): %v",
completeChan.FundingOutpoint, spew.Sdump(fundingTx))
fndgLog.Infof("Broadcasting funding tx for ChannelPoint(%v): %x",
completeChan.FundingOutpoint, fundingTxBuf.Bytes())

err = f.cfg.PublishTransaction(fundingTx, "")
if err != nil {
fndgLog.Errorf("Unable to broadcast funding tx for "+
"ChannelPoint(%v): %v",
fndgLog.Errorf("Unable to broadcast funding tx %x for "+
"ChannelPoint(%v): %v", fundingTxBuf.Bytes(),
completeChan.FundingOutpoint, err)

// We failed to broadcast the funding transaction, but
Expand Down

0 comments on commit fb24413

Please sign in to comment.