BitcoinValueToFriendlyString() public static method

Returns the given value in nanocoins as a 0.12 type string.
public static BitcoinValueToFriendlyString ( long value ) : string
value long
return string
Example #1
0
        /// <returns>A human readable version of the transaction useful for debugging.</returns>
        public override string ToString()
        {
            var s = new StringBuilder();

            s.Append("  ");
            s.Append(HashAsString);
            s.AppendLine();
            if (IsCoinBase)
            {
                string script;
                string script2;
                try
                {
                    script  = _inputs[0].ScriptSig.ToString();
                    script2 = _outputs[0].ScriptPubKey.ToString();
                }
                catch (ScriptException)
                {
                    script  = "???";
                    script2 = "???";
                }
                return("     == COINBASE TXN (scriptSig " + script + ")  (scriptPubKey " + script2 + ")");
            }
            foreach (var @in in _inputs)
            {
                s.Append("     ");
                s.Append("from ");

                try
                {
                    s.Append(@in.ScriptSig.FromAddress.ToString());
                }
                catch (Exception e)
                {
                    s.Append("[exception: ").Append(e.Message).Append("]");
                    throw;
                }
                s.AppendLine();
            }
            foreach (var @out in _outputs)
            {
                s.Append("       ");
                s.Append("to ");
                try
                {
                    var toAddr = new Address(Params, @out.ScriptPubKey.PubKeyHash);
                    s.Append(toAddr.ToString());
                    s.Append(" ");
                    s.Append(Utils.BitcoinValueToFriendlyString(@out.Value));
                    s.Append(" BTC");
                }
                catch (Exception e)
                {
                    s.Append("[exception: ").Append(e.Message).Append("]");
                }
                s.AppendLine();
            }
            return(s.ToString());
        }
Example #2
0
 /// <summary>
 /// Returns a human readable debug string.
 /// </summary>
 public override string ToString()
 {
     return("TxOut of " + Utils.BitcoinValueToFriendlyString(_value) + " to " + ScriptPubKey.ToAddress +
            " script:" + ScriptPubKey);
 }