public static XlsxTransactionsReportData Create(
     IEnumerable <GetTransactionResponse> transactions,
     IDictionary <string, IAssetDefinition> assetDictionary,
     Network network)
 {
     return(new XlsxTransactionsReportData
     {
         TransactionInputOutputs = transactions.SelectMany(p => XlsxTransactionInputOutput.Create(p, assetDictionary, network)).ToList()
     });
 }
            private static XlsxTransactionInputOutput Create(BitcoinAddress address,
                                                             ICoin source,
                                                             BlockInformation block,
                                                             uint256 transactionHash,
                                                             IDictionary <string, IAssetDefinition> assetDictionary,
                                                             int index,
                                                             Network network,
                                                             CoinType coinType)
            {
                string coloredAddress = null;

                try
                {
                    coloredAddress = address?.ToColoredAddress()?.ToWif();
                }
                catch
                {
                }
                var result = new XlsxTransactionInputOutput
                {
                    Address         = address?.ToString(),
                    ColoredAddress  = coloredAddress,
                    TransactionHash = transactionHash.ToString(),
                    Index           = index,
                    CoinType        = coinType,
                };

                if (block != null)
                {
                    result.BlockDate = block.BlockTime.UtcDateTime;
                    result.BlockHash = block.BlockId.ToString();
                }
                if (source is ColoredCoin colored)
                {
                    var assetId = colored.AssetId.GetWif(network).ToString();

                    var asset        = assetDictionary.ContainsKey(assetId) ? assetDictionary[assetId] : null;
                    var divisibility = asset?.Divisibility ?? 0;

                    result.ColouredAssetValue = BitcoinUtils.CalculateColoredAssetQuantity(colored.Amount.Quantity, divisibility);
                    result.BtcValue           = BitcoinUtils.SatoshiToBtc(colored.Bearer.Amount.Satoshi);

                    result.ColouredAssetName = asset != null ? asset.Name : assetId;
                }

                if (source is Coin uncolored)
                {
                    result.BtcValue = BitcoinUtils.SatoshiToBtc(uncolored.Amount.Satoshi);
                }

                return(result);
            }
            private static XlsxTransactionInputOutput CreateFees(Money fees, BlockInformation block, uint256 transactionHash, int index)
            {
                var result = new XlsxTransactionInputOutput
                {
                    TransactionHash = transactionHash.ToString(),
                    Index           = index,
                    CoinType        = CoinType.Fees,
                    BtcValue        = BitcoinUtils.SatoshiToBtc(fees.Satoshi)
                };

                if (block != null)
                {
                    result.BlockDate = block.BlockTime.UtcDateTime;
                    result.BlockHash = block.BlockId.ToString();
                }

                return(result);
            }