コード例 #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 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);
        }