Exemple #1
0
        public static (Output, TxKernel) Reward_output(Keychain keychain, Identifier keyId, ulong fees)
        {
            var secp = keychain.Secp;

            var commit           = keychain.Commit(Consensus.Reward(fees), keyId);
            var switchCommit     = keychain.Switch_commit(keyId);
            var switchCommitHash = SwitchCommitHash.From_switch_commit(switchCommit);

            Log.Verbose(
                "Block reward - Pedersen Commit is: {commit}, Switch Commit is: {switch_commit}",
                commit,
                switchCommit
                );

            Log.Verbose(
                "Block reward - Switch Commit Hash is: {  switch_commit_hash}",
                switchCommitHash
                );

            var msg    = ProofMessage.Empty();
            var rproof = keychain.Range_proof(Consensus.Reward(fees), keyId, commit, msg);

            var output = new Output
            {
                Features         = OutputFeatures.CoinbaseOutput,
                Commit           = commit,
                SwitchCommitHash = switchCommitHash,
                Proof            = rproof
            };

            var overCommit = secp.commit_value(Consensus.Reward(fees));
            var outCommit  = output.Commit;
            var excess     = secp.commit_sum(new[] { outCommit }, new[] { overCommit });

            var msg2 = Message.from_slice(new byte[Constants.MessageSize]);
            var sig  = keychain.Sign(msg2, keyId);

            var proof = new TxKernel
            {
                Features   = KernelFeatures.CoinbaseKernel,
                Excess     = excess,
                ExcessSig  = sig.serialize_der(secp),
                Fee        = 0,
                LockHeight = 0
            };

            return(output, proof);
        }