Ejemplo n.º 1
0
        protected virtual void CreatePayloadOutputs(Transaction tx, Money reward)
        {
            if (coinbasepayloadParameters.CoinbasePayload != null)
            {
                CoinbasePayload[] coinbasepayloads;
                if (coinbasepayloadParameters.CoinbasePayload.Type == JTokenType.Array)
                {
                    coinbasepayloads = coinbasepayloadParameters.CoinbasePayload.ToObject <CoinbasePayload[]>();
                }
                else
                {
                    coinbasepayloads = new[] { coinbasepayloadParameters.CoinbasePayload.ToObject <CoinbasePayload>() }
                };

                foreach (var CoinbasePayee in coinbasepayloads)
                {
                    if (!string.IsNullOrEmpty(CoinbasePayee.Payee))
                    {
                        var payeeAddress = BitcoinUtils.CashAddrToDestination(CoinbasePayee.Payee, network, true);
                        var payeeReward  = CoinbasePayee.Amount;

                        tx.Outputs.Add(payeeReward, payeeAddress);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected virtual Money CreateMasternodeOutputs(Transaction tx, Money reward)
        {
            if (masterNodeParameters.Masternode != null)
            {
                Masternode[] masternodes;

                // Dash v13 Multi-Master-Nodes
                if (masterNodeParameters.Masternode.Type == JTokenType.Array)
                {
                    masternodes = masterNodeParameters.Masternode.ToObject <Masternode[]>();
                }
                else
                {
                    masternodes = new[] { masterNodeParameters.Masternode.ToObject <Masternode>() }
                };

                foreach (var masterNode in masternodes)
                {
                    if (!string.IsNullOrEmpty(masterNode.Payee))
                    {
                        var payeeAddress = BitcoinUtils.AddressToDestination(masterNode.Payee, network);
                        var payeeReward  = masterNode.Amount;

                        reward       -= payeeReward;
                        rewardToPool -= payeeReward;

                        tx.Outputs.Add(payeeReward, payeeAddress);
                    }
                }
            }

            if (masterNodeParameters.SuperBlocks != null && masterNodeParameters.SuperBlocks.Length > 0)
            {
                foreach (var superBlock in masterNodeParameters.SuperBlocks)
                {
                    var payeeAddress = BitcoinUtils.AddressToDestination(superBlock.Payee, network);
                    var payeeReward  = superBlock.Amount;

                    reward       -= payeeReward;
                    rewardToPool -= payeeReward;

                    tx.Outputs.Add(payeeReward, payeeAddress);
                }
            }

            if (!string.IsNullOrEmpty(masterNodeParameters.Payee))
            {
                var payeeAddress = BitcoinUtils.AddressToDestination(masterNodeParameters.Payee, network);
                var payeeReward  = masterNodeParameters.PayeeAmount ?? (reward / 5);

                reward       -= payeeReward;
                rewardToPool -= payeeReward;

                tx.Outputs.Add(payeeReward, payeeAddress);
            }

            return(reward);
        }
Ejemplo n.º 3
0
        protected virtual Transaction CreatePayeeOutputTransaction()
        {
            rewardToPool = new Money(BlockTemplate.CoinbaseValue, MoneyUnit.Satoshi);

            var tx = Transaction.Create(network);

            if (payeeParameters?.PayeeAmount > 0)
            {
                var payeeReward = new Money(payeeParameters.PayeeAmount.Value, MoneyUnit.Satoshi);
                rewardToPool -= payeeReward;

                tx.Outputs.Add(payeeReward, BitcoinUtils.AddressToDestination(payeeParameters.Payee, network));
            }

            tx.Outputs.Insert(0, new TxOut(rewardToPool, poolAddressDestination));

            return(tx);
        }
Ejemplo n.º 4
0
        protected virtual void CreateCoinbaseDevRewardOutputs(Transaction tx)
        {
            if (CoinbaseDevRewardParams.CoinbaseDevReward != null)
            {
                CoinbaseDevReward[] CBRewards;
                CBRewards = new[] { CoinbaseDevRewardParams.CoinbaseDevReward.ToObject <CoinbaseDevReward>() };

                foreach (var CBReward in CBRewards)
                {
                    if (!string.IsNullOrEmpty(CBReward.Payee))
                    {
                        var payeeAddress = BitcoinUtils.AddressToDestination(CBReward.Payee, network);
                        var payeeReward  = CBReward.Value;
                        tx.Outputs.Add(payeeReward, payeeAddress);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        protected virtual Money CreateMasternodeOutputs(Transaction tx, Money reward)
        {
            if (masterNodeParameters.Masternode != null && masterNodeParameters.SuperBlocks != null)
            {
                if (!string.IsNullOrEmpty(masterNodeParameters.Masternode.Payee))
                {
                    var payeeAddress = BitcoinUtils.AddressToDestination(masterNodeParameters.Masternode.Payee);
                    var payeeReward  = masterNodeParameters.Masternode.Amount;

                    reward       -= payeeReward;
                    rewardToPool -= payeeReward;

                    tx.AddOutput(payeeReward, payeeAddress);
                }

                else if (masterNodeParameters.SuperBlocks.Length > 0)
                {
                    foreach (var superBlock in masterNodeParameters.SuperBlocks)
                    {
                        var payeeAddress = BitcoinUtils.AddressToDestination(superBlock.Payee);
                        var payeeReward  = superBlock.Amount;

                        reward       -= payeeReward;
                        rewardToPool -= payeeReward;

                        tx.AddOutput(payeeReward, payeeAddress);
                    }
                }
            }

            if (!string.IsNullOrEmpty(masterNodeParameters.Payee))
            {
                var payeeAddress = BitcoinUtils.AddressToDestination(masterNodeParameters.Payee);
                var payeeReward  = masterNodeParameters.PayeeAmount ?? (reward / 5);

                reward       -= payeeReward;
                rewardToPool -= payeeReward;

                tx.AddOutput(payeeReward, payeeAddress);
            }

            return(reward);
        }
Ejemplo n.º 6
0
 protected virtual Money CreateFounderOutputs(Transaction tx, Money reward)
 {
     if (FounderParameters.Founder != null)
     {
         Founder[] founders = new[] { FounderParameters.Founder.ToObject <Founder>() };
         foreach (var Founder in founders)
         {
             if (!string.IsNullOrEmpty(Founder.Payee))
             {
                 var payeeAddress = coin.IsFounderPayeeMultisig ? BitcoinUtils.MultiSigAddressToDestination(Founder.Payee, network) : BitcoinUtils.AddressToDestination(Founder.Payee, network);
                 var payeeReward  = Founder.Amount;
                 reward       -= payeeReward;
                 rewardToPool -= payeeReward;
                 tx.Outputs.Add(payeeReward, payeeAddress);
             }
         }
     }
     return(reward);
 }
Ejemplo n.º 7
0
        protected virtual Money CreateTreasuryOutputs(Transaction tx, Money reward)
        {
            if (TreasuryParams.Treasury != null)
            {
                Treasury[] CBRewards;
                CBRewards = new[] { TreasuryParams.Treasury.ToObject <Treasury>() };

                foreach (var CBReward in CBRewards)
                {
                    if (!string.IsNullOrEmpty(CBReward.Payee))
                    {
                        var payeeAddress = BitcoinUtils.AddressToDestination(CBReward.Payee, network);
                        var payeeReward  = CBReward.Amount;
                        tx.Outputs.Add(payeeReward, payeeAddress);
                    }
                }
            }
            return(reward);
        }
Ejemplo n.º 8
0
        protected virtual Money CreateFounderOutputs(Transaction tx, Money reward)
        {
            if (FounderParameters.Founder != null)
            {
                Founder[] founders;
                if (FounderParameters.Founder.Type == JTokenType.Array)
                {
                    founders = FounderParameters.Founder.ToObject <Founder[]>();
                }
                else
                {
                    founders = new[] { FounderParameters.Founder.ToObject <Founder>() }
                };

                foreach (var Founder in founders)
                {
                    if (!string.IsNullOrEmpty(Founder.Payee))
                    {
                        var payeeAddress = BitcoinUtils.AddressToDestination(Founder.Payee, network);
                        var payeeReward  = Founder.Amount;
                        reward       -= payeeReward;
                        rewardToPool -= payeeReward;
                        tx.Outputs.Add(payeeReward, payeeAddress);
                    }
                }
            }

            if (!string.IsNullOrEmpty(FounderParameters.Payee))
            {
                var payeeAddress = BitcoinUtils.AddressToDestination(FounderParameters.Payee, network);
                var payeeReward  = FounderParameters.PayeeAmount;
                reward       -= payeeReward;
                rewardToPool -= payeeReward;
                tx.Outputs.Add(payeeReward, payeeAddress);
            }

            return(reward);
        }