ToNanoCoins() public static method

Convert an amount expressed in the way humans are used to into nanocoins.
This takes string in a format understood by System.Double.Parse(string), for example "0", "1", "0.10", "1.23E3", "1234.5E-5".
If you try to specify fractional nanocoins.
public static ToNanoCoins ( string coins ) : ulong
coins string
return ulong
示例#1
0
        /// <summary>
        /// Returns a solved block that builds on top of this one. This exists for unit tests.
        /// </summary>
        internal Block CreateNextBlock(Address to, uint time)
        {
            var b = new Block(Params);

            b.DifficultyTarget = _difficultyTarget;
            b.AddCoinbaseTransaction(_emptyBytes);

            // Add a transaction paying 50 coins to the "to" address.
            var t = new Transaction(Params);

            t.AddOutput(new TransactionOutput(Params, t, Utils.ToNanoCoins(50, 0), to));
            // The input does not really need to be a valid signature, as long as it has the right general form.
            var input = new TransactionInput(Params, t, Script.CreateInputScript(_emptyBytes, _emptyBytes));
            // Importantly the outpoint hash cannot be zero as that's how we detect a coinbase transaction in isolation
            // but it must be unique to avoid 'different' transactions looking the same.
            var counter = new byte[32];

            counter[0]          = (byte)_txCounter++;
            input.Outpoint.Hash = new Sha256Hash(counter);
            t.AddInput(input);
            b.AddTransaction(t);

            b.PrevBlockHash = Hash;
            b.TimeSeconds   = time;
            b.Solve();
            b.VerifyHeader();
            return(b);
        }
示例#2
0
 /// <summary>
 /// Used only in creation of the genesis blocks and in unit tests.
 /// </summary>
 internal TransactionOutput(NetworkParameters @params, Transaction parent, byte[] scriptBytes)
     : base(@params)
 {
     _scriptBytes          = scriptBytes;
     _value                = Utils.ToNanoCoins(50, 0);
     ParentTransaction     = parent;
     _availableForSpending = true;
 }