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() && if chanType.IsSingleFunder() && chanType.HasFundingTx() &&
channel.IsInitiator { 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, "", channel.FundingTxn, "",
) )
if err != nil { if err != nil {
fndgLog.Errorf("Unable to rebroadcast "+ fndgLog.Errorf("Unable to rebroadcast "+
"funding tx for "+ "funding tx %x for "+
"ChannelPoint(%v): %v", "ChannelPoint(%v): %v",
fundingTxBuf.Bytes(),
channel.FundingOutpoint, err) channel.FundingOutpoint, err)
} }
} }
@ -1991,14 +2011,24 @@ func (f *fundingManager) handleFundingSigned(fmsg *fundingSignedMsg) {
// if we actually have the funding transaction. // if we actually have the funding transaction.
if completeChan.ChanType.HasFundingTx() { if completeChan.ChanType.HasFundingTx() {
fundingTx := completeChan.FundingTxn 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", // Clear the buffer of any bytes that were written
completeChan.FundingOutpoint, spew.Sdump(fundingTx)) // 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, "") err = f.cfg.PublishTransaction(fundingTx, "")
if err != nil { if err != nil {
fndgLog.Errorf("Unable to broadcast funding tx for "+ fndgLog.Errorf("Unable to broadcast funding tx %x for "+
"ChannelPoint(%v): %v", "ChannelPoint(%v): %v", fundingTxBuf.Bytes(),
completeChan.FundingOutpoint, err) completeChan.FundingOutpoint, err)
// We failed to broadcast the funding transaction, but // We failed to broadcast the funding transaction, but