コード例 #1
0
        private void DoCoinControl(List <UnspentResponse> unspentInNeedOfCoinControl)
        {
            decimal fee = GetFee();

            if (fee < 0)
            {
                return;
            }

            string errorMessage;

            if (!TryUnlockWallet(out errorMessage))
            {
                MessageService.Error(errorMessage);
                return;
            }

            CreateRawTransactionRequest createRequest = new CreateRawTransactionRequest();

            createRequest.Inputs = new List <TransactionInput>();

            foreach (UnspentResponse transaction in unspentInNeedOfCoinControl)
            {
                createRequest.Inputs.Add(TransactionInput.CreateFromUnspent(transaction));
            }

            createRequest.SendFullAmountTo(m_config.AddressToCoinControl, fee);

            MessageService.Info(string.Format("Amount: {0} LINDA.", createRequest.AmountAfterFee + fee));
            MessageService.Info(string.Format("Amount After Fee: {0} LINDA.", createRequest.AmountAfterFee));

            TransactionHelper helper = new TransactionHelper(m_dataConnector);
            string            transactionId;

            if (!helper.TrySendRawTransaction(
                    createRequest,
                    out transactionId,
                    out errorMessage))
            {
                MessageService.Error(errorMessage);
                return;
            }

            MessageService.Info(string.Format("Coin control transaction sent: {0}.", transactionId));
            MessageService.Info("Coin control complete!");

            if (!TryUnlockWalletForStakingOnly(out errorMessage))
            {
                MessageService.Error(string.Format(
                                         "Failed to unlock wallet for staking only!  Wallet may remain entirely unlocked for up to 5 more seconds.  See error: {0}",
                                         errorMessage));
            }
        }