From 9314aa2e7dc152eeee94d5493209878b6e8eb22d Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 30 Nov 2017 22:53:19 -0800 Subject: [PATCH] funding: route back full lnwire.Error to caller upon funding flow failure --- fundingmanager.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/fundingmanager.go b/fundingmanager.go index c1e7216f..107cf9b0 100644 --- a/fundingmanager.go +++ b/fundingmanager.go @@ -8,6 +8,8 @@ import ( "sync/atomic" "time" + "google.golang.org/grpc" + "golang.org/x/crypto/salsa20" "github.com/boltdb/bolt" @@ -23,7 +25,6 @@ import ( "github.com/roasbeef/btcd/chaincfg/chainhash" "github.com/roasbeef/btcd/wire" "github.com/roasbeef/btcutil" - "google.golang.org/grpc" ) const ( @@ -2214,9 +2215,22 @@ func (f *fundingManager) handleErrorMsg(fmsg *fundingErrorMsg) { // error back to the caller (if any), and cancel the workflow itself. lnErr := lnwire.ErrorCode(protocolErr.Data[0]) fndgLog.Errorf("Received funding error from %x: %v", - peerKey.SerializeCompressed(), lnErr, + peerKey.SerializeCompressed(), string(protocolErr.Data), ) - resCtx.err <- grpc.Errorf(lnErr.ToGrpcCode(), lnErr.String()) + + // If this isn't a simple error code, then we'll display the entire + // thing. + if len(protocolErr.Data) > 0 { + resCtx.err <- grpc.Errorf( + lnErr.ToGrpcCode(), string(protocolErr.Data), + ) + } else { + // Otherwise, we'll attempt tto display just the error code + // itself. + resCtx.err <- grpc.Errorf( + lnErr.ToGrpcCode(), lnErr.String(), + ) + } if _, err := f.cancelReservationCtx(peerKey, chanID); err != nil { fndgLog.Warnf("unable to delete reservation: %v", err)