コード例 #1
0
        public bool SendMogs(MogwaiKeys mogwaiKey, string[] toAddresses, decimal amount, decimal txFee, out string txid)
        {
            Log.Debug($"send mogs {mogwaiKey.Address}, [{string.Join(",", toAddresses)}] for {amount} with {txFee}.");

            txid = string.Empty;

            List <UnspentTx> unspentTxList = GetUnspent(0, 9999999, mogwaiKey.Address);
            var unspentAmount = unspentTxList.Sum(p => p.Amount);

            if (unspentAmount < amount * toAddresses.Length + txFee)
            {
                Log.Debug($"Address hasn't enough funds {unspentAmount} to burn that amount of mogs {amount * toAddresses.Length + txFee}!");
                return(false);
            }

            // create transaction
            NBitcoin.Transaction tx = mogwaiKey.CreateTransaction(unspentTxList, unspentAmount, toAddresses, amount, txFee);

            Log.Info($"signedRawTx: {tx.ToHex()}");

            txid = SendRawTransaction(tx.ToHex());

            Log.Info($"sendRawTx[{(txid.Length != 0 ? "SUCCESS" : "FAILED")}]: {txid}");

            return(txid.Length != 0);
        }
コード例 #2
0
        public bool BurnMogs(MogwaiKeys mogwaiKey, decimal burnMogs, decimal txFee, out string txid)
        {
            if (SendMogs(mogwaiKey, new[] { mogwaiKey.MirrorAddress }, burnMogs, txFee, out txid))
            {
                var trackingurl =
                    "https://analytics.mogwaicoin.org/matomo.php?idsite=3&rec=1&e_c=MOG&e_a=Burned&e_n=MOG+Burned&e_v=" +
                    burnMogs.ToString(CultureInfo.InvariantCulture);
                new WebClient().DownloadData(trackingurl);
                return(true);
            }

            return(false);
        }
コード例 #3
0
ファイル: Wallet.cs プロジェクト: WorldOfMogwais/WoMNetCore
        /// <summary>
        ///
        /// </summary>
        /// <param name="mogwaiKeys"></param>
        /// <param name="tries"></param>
        /// <returns></returns>
        public bool GetNewMogwaiKey(out MogwaiKeys mogwaiKeys, int tries = 10)
        {
            // TODO this function should try till it finds a valid mirror address

            mogwaiKeys = null;

            if (!IsUnlocked)
            {
                return(false);
            }

            uint seed = 1000;

            if (_walletFile.EncryptedSecrets.Values.Count > 0)
            {
                seed = _walletFile.EncryptedSecrets.Values.Max() + 1;
            }

            for (var i = seed; i < seed + tries; i++)
            {
                var mogwaiKeysTemp = GetMogwaiKeys(i);
                if (mogwaiKeysTemp.HasMirrorAddress)
                {
                    var wif = mogwaiKeysTemp.GetEncryptedSecretWif();
                    if (!_walletFile.EncryptedSecrets.ContainsKey(wif))
                    {
                        _walletFile.EncryptedSecrets[wif] = i;
                        mogwaiKeys = mogwaiKeysTemp;
                        // add to the current mogwai keys
                        MogwaiKeyDict[mogwaiKeys.Address] = mogwaiKeys;
                        // persist to not loose
                        Caching.Persist(_path, _walletFile);
                        return(true);
                    }
                }
            }

            return(false);
        }
コード例 #4
0
ファイル: Wallet.cs プロジェクト: darkfriend77/wom
        /// <summary>
        ///
        /// </summary>
        /// <param name="mogwaiKeys"></param>
        /// <param name="tryes"></param>
        /// <returns></returns>
        public bool GetNewMogwaiKey(out MogwaiKeys mogwaiKeys, int tryes = 10)
        {
            mogwaiKeys = null;

            if (!IsUnlocked)
            {
                return(false);;
            }

            uint seed = 1000;

            if (walletFile.EncryptedSecrets.Values.Count > 0)
            {
                seed = walletFile.EncryptedSecrets.Values.Max() + 1;
            }

            for (uint i = seed; i < seed + tryes; i++)
            {
                var mogwayKeysTemp = GetMogwaiKeys(i);
                if (mogwayKeysTemp.HasMirrorAddress)
                {
                    var wif = mogwayKeysTemp.GetEncryptedSecretWif();
                    if (!walletFile.EncryptedSecrets.ContainsKey(wif))
                    {
                        walletFile.EncryptedSecrets[wif] = i;
                        mogwaiKeys = mogwayKeysTemp;
                        // add to the current mogwai keys
                        MogwaiKeyDict[mogwaiKeys.Address] = mogwaiKeys;
                        // persist to not loose
                        Caching.Persist(path, walletFile);
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #5
0
        public bool SendMogs(MogwaiKeys mogwaiKey, string[] toAddresses, decimal amount, decimal txFee)
        {
            _log.Debug($"send mogs {mogwaiKey.Address}, [{string.Join(",", toAddresses)}] for {amount} with {txFee}.");

            var unspentTxList = GetUnspent(0, 9999999, mogwaiKey.Address);
            var unspentAmount = unspentTxList.Sum(p => p.Amount);

            if (unspentAmount < ((amount * toAddresses.Length) + txFee))
            {
                _log.Debug($"Address hasn't enough funds {unspentAmount} to burn that amount of mogs {((amount * toAddresses.Length) + txFee)}!");
                return(false);
            }

            // create transaction
            Transaction tx = mogwaiKey.CreateTransaction(unspentTxList, unspentAmount, toAddresses, amount, txFee);

            _log.Info($"signedRawTx: {tx.ToHex()}");

            var answer = SendRawTransaction(tx.ToHex());

            _log.Info($"sendRawTx[{(answer.Length != 0 ? "SUCCESS":"FAILED")}]: {answer}");

            return(answer.Length != 0);
        }
コード例 #6
0
 public bool BurnMogs(MogwaiKeys mogwaiKey, decimal burnMogs, decimal txFee)
 {
     return(SendMogs(mogwaiKey, new string[] { mogwaiKey.MirrorAddress }, burnMogs, txFee));
 }
コード例 #7
0
 public bool BindMogwai(MogwaiKeys mogwaiKey)
 {
     return(BurnMogs(mogwaiKey, mogwaiCost, txFee));
 }
コード例 #8
0
 public bool Interaction(MogwaiKeys mogwaiKey, Interaction interaction, out string txid)
 {
     return(BurnMogs(mogwaiKey, interaction.GetValue1(), TxFee + interaction.GetValue2(), out txid));
 }
コード例 #9
0
 public bool BindMogwai(MogwaiKeys mogwaiKey, out string txid)
 {
     return(BurnMogs(mogwaiKey, MogwaiCost, TxFee, out txid));
 }
コード例 #10
0
 public bool BurnMogs(MogwaiKeys mogwaiKey, decimal burnMogs, decimal txFee, out string txid)
 {
     return(SendMogs(mogwaiKey, new[] { mogwaiKey.MirrorAddress }, burnMogs, txFee, out txid));
 }
コード例 #11
0
 public bool Interaction(MogwaiKeys mogwaiKey, Interaction interaction, out string txid)
 {
     return(SendMogs(mogwaiKey, new[] { mogwaiKey.MirrorAddress }, interaction.GetValue1(), TxFee + interaction.GetValue2(), out txid));
 }