fundingmanager: log raw transaction on braodcast

This commit is contained in:
Wilmer Paulino 2020-06-01 12:41:05 -07:00
parent 595bb7c1ff
commit 96dc30ae70
No known key found for this signature in database
GPG Key ID: 6DF57B9F9514972F

@ -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)
}
}
@ -1991,14 +2011,24 @@ 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))
// Clear the buffer of any bytes that were written
// before the serialization error to prevent logging an
// incomplete transaction.
fundingTxBuf.Reset()
}
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