From 10b976187d92c9ae7cf0a8d58d61efe161b990a5 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Sat, 15 Sep 2018 11:07:27 +0200 Subject: [PATCH] rpcserver: handle unconfirmed TX properly when listing all transactions --- rpcserver.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rpcserver.go b/rpcserver.go index 9fcaa75d3..903d4f2da 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -3014,11 +3014,18 @@ func (r *rpcServer) GetTransactions(ctx context.Context, destAddresses = append(destAddresses, destAddress.EncodeAddress()) } + // We also get unconfirmed transactions, so BlockHash can be + // nil. + blockHash := "" + if tx.BlockHash != nil { + blockHash = tx.BlockHash.String() + } + txDetails.Transactions[i] = &lnrpc.Transaction{ TxHash: tx.Hash.String(), Amount: int64(tx.Value), NumConfirmations: tx.NumConfirmations, - BlockHash: tx.BlockHash.String(), + BlockHash: blockHash, BlockHeight: tx.BlockHeight, TimeStamp: tx.Timestamp, TotalFees: tx.TotalFees,