funding: properly display pending chan ID within logs

This commit corrects a minor formatting error when logging the pending
channel ID within the logs. Previously, the logging directives and
parameter could cause the pending chan ID to display in a double-hex
encoded format. We fix this by ensuring that we properly slice the chan
ID before printing it, and also ensure that we use the %x formatting
(which will hex encode the bytes) everywhere.

Fixes #331.
This commit is contained in:
Olaoluwa Osuntokun 2017-09-18 19:33:37 +02:00
parent d97575d6d2
commit 31d53c6070
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

@ -852,7 +852,7 @@ func (f *fundingManager) handleFundingAccept(fmsg *fundingAcceptMsg) {
return return
} }
fndgLog.Infof("Recv'd fundingResponse for pendingID(%x)", pendingChanID) fndgLog.Infof("Recv'd fundingResponse for pendingID(%x)", pendingChanID[:])
// We'll also specify the responder's preference for the number of // We'll also specify the responder's preference for the number of
// required confirmations, and also the set of channel constraints // required confirmations, and also the set of channel constraints
@ -908,7 +908,7 @@ func (f *fundingManager) handleFundingAccept(fmsg *fundingAcceptMsg) {
} }
fndgLog.Infof("pendingChan(%x): remote party proposes num_confs=%v, "+ fndgLog.Infof("pendingChan(%x): remote party proposes num_confs=%v, "+
"csv_delay=%v", pendingChanID, msg.MinAcceptDepth, msg.CsvDelay) "csv_delay=%v", pendingChanID[:], msg.MinAcceptDepth, msg.CsvDelay)
fndgLog.Debugf("Remote party accepted commitment constraints: %v", fndgLog.Debugf("Remote party accepted commitment constraints: %v",
spew.Sdump(remoteContribution.ChannelConfig.ChannelConstraints)) spew.Sdump(remoteContribution.ChannelConfig.ChannelConstraints))
@ -945,7 +945,7 @@ func (f *fundingManager) handleFundingAccept(fmsg *fundingAcceptMsg) {
f.resMtx.Unlock() f.resMtx.Unlock()
fndgLog.Infof("Generated ChannelPoint(%v) for pendingID(%x)", outPoint, fndgLog.Infof("Generated ChannelPoint(%v) for pendingID(%x)", outPoint,
pendingChanID) pendingChanID[:])
fundingCreated := &lnwire.FundingCreated{ fundingCreated := &lnwire.FundingCreated{
PendingChannelID: pendingChanID, PendingChannelID: pendingChanID,
@ -980,8 +980,8 @@ func (f *fundingManager) handleFundingCreated(fmsg *fundingCreatedMsg) {
resCtx, err := f.getReservationCtx(peerKey, pendingChanID) resCtx, err := f.getReservationCtx(peerKey, pendingChanID)
if err != nil { if err != nil {
fndgLog.Warnf("can't find reservation (peerID:%v, chanID:%v)", fndgLog.Warnf("can't find reservation (peerID:%v, chanID:%x)",
peerKey, pendingChanID) peerKey, pendingChanID[:])
return return
} }
@ -992,7 +992,7 @@ func (f *fundingManager) handleFundingCreated(fmsg *fundingCreatedMsg) {
// TODO(roasbeef): make case (p vs P) consistent throughout // TODO(roasbeef): make case (p vs P) consistent throughout
fundingOut := fmsg.msg.FundingPoint fundingOut := fmsg.msg.FundingPoint
fndgLog.Infof("completing pendingID(%x) with ChannelPoint(%v)", fndgLog.Infof("completing pendingID(%x) with ChannelPoint(%v)",
pendingChanID, fundingOut) pendingChanID[:], fundingOut)
// With all the necessary data available, attempt to advance the // With all the necessary data available, attempt to advance the
// funding workflow to the next stage. If this succeeds then the // funding workflow to the next stage. If this succeeds then the
@ -1037,7 +1037,7 @@ func (f *fundingManager) handleFundingCreated(fmsg *fundingCreatedMsg) {
f.barrierMtx.Unlock() f.barrierMtx.Unlock()
fndgLog.Infof("sending signComplete for pendingID(%x) over ChannelPoint(%v)", fndgLog.Infof("sending signComplete for pendingID(%x) over ChannelPoint(%v)",
pendingChanID, fundingOut) pendingChanID[:], fundingOut)
// With their signature for our version of the commitment transaction // With their signature for our version of the commitment transaction
// verified, we can now send over our signature to the remote peer. // verified, we can now send over our signature to the remote peer.
@ -1143,8 +1143,8 @@ func (f *fundingManager) handleFundingSigned(fmsg *fundingSignedMsg) {
resCtx, err := f.getReservationCtx(fmsg.peerAddress.IdentityKey, resCtx, err := f.getReservationCtx(fmsg.peerAddress.IdentityKey,
pendingChanID) pendingChanID)
if err != nil { if err != nil {
fndgLog.Warnf("Unable to find reservation (peerID:%v, chanID:%v)", fndgLog.Warnf("Unable to find reservation (peerID:%v, chanID:%x)",
peerKey, pendingChanID) peerKey, pendingChanID[:])
f.failFundingFlow(fmsg.peerAddress.IdentityKey, f.failFundingFlow(fmsg.peerAddress.IdentityKey,
pendingChanID, []byte(err.Error())) pendingChanID, []byte(err.Error()))
return return
@ -1173,7 +1173,7 @@ func (f *fundingManager) handleFundingSigned(fmsg *fundingSignedMsg) {
} }
fndgLog.Infof("Finalizing pendingID(%x) over ChannelPoint(%v), "+ fndgLog.Infof("Finalizing pendingID(%x) over ChannelPoint(%v), "+
"waiting for channel open on-chain", pendingChanID, fundingPoint) "waiting for channel open on-chain", pendingChanID[:], fundingPoint)
// Send an update to the upstream client that the negotiation process // Send an update to the upstream client that the negotiation process
// is over. // is over.
@ -1964,7 +1964,7 @@ func (f *fundingManager) cancelReservationCtx(peerKey *btcec.PublicKey,
pendingChanID [32]byte) (*reservationWithCtx, error) { pendingChanID [32]byte) (*reservationWithCtx, error) {
fndgLog.Infof("Cancelling funding reservation for node_key=%x, "+ fndgLog.Infof("Cancelling funding reservation for node_key=%x, "+
"chan_id=%x", peerKey.SerializeCompressed(), pendingChanID) "chan_id=%x", peerKey.SerializeCompressed(), pendingChanID[:])
ctx, err := f.getReservationCtx(peerKey, pendingChanID) ctx, err := f.getReservationCtx(peerKey, pendingChanID)
if err != nil { if err != nil {
@ -2006,7 +2006,7 @@ func (f *fundingManager) getReservationCtx(peerKey *btcec.PublicKey,
if !ok { if !ok {
return nil, errors.Errorf("unknown channel (id: %x)", return nil, errors.Errorf("unknown channel (id: %x)",
pendingChanID) pendingChanID[:])
} }
return resCtx, nil return resCtx, nil