public RecentAccountViewModel(ViewModelBase parent, Account account, string accountName, Amount balance)
     : base(parent)
 {
     Account = account;
     AccountName = accountName;
     Balance = balance;
 }
Example #2
0
            public Output(Amount amount, byte[] pkScript)
            {
                if (pkScript == null)
                    throw new ArgumentNullException(nameof(pkScript));

                Amount = amount;
                PkScript = pkScript;
            }
Example #3
0
        public string FormatAmount(Amount amount)
        {
            var negativeSign = "";
            var negative = amount < 0;
            if (negative)
            {
                amount = -amount;
                negativeSign = "-";
            }

            var wholePart = amount / _satoshisPerUnit;
            var decimalPart = (double)(amount % _satoshisPerUnit) / _satoshisPerUnit;

            return string.Format(_formatString, negativeSign, wholePart, decimalPart);
        }
Example #4
0
        public string FormatAmount(Amount amount)
        {
            // The negative sign has to be printed separately.  It can not be displayed as a
            // negative whole part, since there is no such thing as negative zero for longs.
            var negativeSign = "";
            var negative = amount < 0;
            if (negative)
            {
                amount = -amount;
                negativeSign = "-";
            }

            var wholePart = amount / _satoshisPerUnit;
            var decimalPart = (double)(amount % _satoshisPerUnit) / _satoshisPerUnit;

            return string.Format(_formatString, negativeSign, wholePart, decimalPart);
        }
Example #5
0
 public async Task<Tuple<List<UnspentOutput>, Amount, OutputScript>> FundTransactionAsync(
     Account account, Amount targetAmount, int requiredConfirmations)
 {
     var client = WalletService.NewClient(_channel);
     var request = new FundTransactionRequest
     {
         Account = account.AccountNumber,
         TargetAmount = targetAmount,
         RequiredConfirmations = requiredConfirmations,
         IncludeImmatureCoinbases = false,
         IncludeChangeScript = true,
     };
     var response = await client.FundTransactionAsync(request, cancellationToken: _tokenSource.Token);
     var outputs = response.SelectedOutputs.Select(MarshalUnspentOutput).ToList();
     var total = (Amount)response.TotalAmount;
     var changeScript = (OutputScript)null;
     if (response.ChangePkScript?.Length != 0)
     {
         changeScript = OutputScript.ParseScript(response.ChangePkScript.ToByteArray());
     }
     return Tuple.Create(outputs, total, changeScript);
 }
Example #6
0
 public async Task<Tuple<List<UnspentOutput>, Amount>> SelectUnspentOutputs(Account account, Amount targetAmount,
     int requiredConfirmations)
 {
     var client = WalletService.NewClient(_channel);
     var request = new FundTransactionRequest
     {
         Account = account.AccountNumber,
         TargetAmount = targetAmount,
         RequiredConfirmations = requiredConfirmations,
         IncludeImmatureCoinbases = false,
         IncludeChangeScript = false,
     };
     var response = await client.FundTransactionAsync(request, cancellationToken: _tokenSource.Token);
     var outputs = response.SelectedOutputs.Select(MarshalUnspentOutput).ToList();
     var total = (Amount)response.TotalAmount;
     return Tuple.Create(outputs, total);
 }
Example #7
0
 public AccountTransactionViewModel(WalletTransaction transaction, Amount runningBalanceDelta, Amount runningBalance)
 {
     _transaction = transaction;
     BalanceDelta = runningBalanceDelta;
     _balance = runningBalance;
 }
 public Output(Amount amount, string destination)
 {
     Amount = amount;
     Destination = destination;
 }
 public Input(Amount amount, string previousAccount)
 {
     Amount = amount;
     PreviousAccount = previousAccount;
 }
Example #10
0
 /// <summary>
 /// Perform a preliminary check that the Amount is within the bounds of valid
 /// transaction output values.  Additional checks are required before authoring
 /// a valid transaction to ensure the total output amount does not exceed the
 /// total previous output amount referenced by the inputs.
 /// </summary>
 public static bool IsSaneOutputValue(Amount a) => a >= 0 && a <= MaxOutputValue;