Merge pull request #4341 from wpaulino/log-raw-funding-tx

fundingmanager: log raw transaction on broadcast
This commit is contained in:
Wilmer Paulino 2020-06-03 15:45:22 -07:00 committed by GitHub
commit c7dad7a8dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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