Merge pull request #1916 from guggero/crash-on-listchaintxns

rpcserver: handle unconfirmed TX properly when listing all transactions
This commit is contained in:
Johan T. Halseth 2018-09-17 20:05:26 +02:00 committed by GitHub
commit 9a3e19b77f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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