Paymetheus.Decred.Wallet.Wallet.OutputDestination C# (CSharp) Method

OutputDestination() public method

public OutputDestination ( Paymetheus.Decred.Wallet.WalletTransaction output ) : string
output Paymetheus.Decred.Wallet.WalletTransaction
return string
        public string OutputDestination(WalletTransaction.Output output)
        {
            if (output == null)
                throw new ArgumentNullException(nameof(output));

            if (output is WalletTransaction.Output.ControlledOutput)
            {
                var controlledOutput = (WalletTransaction.Output.ControlledOutput)output;
                if (controlledOutput.Change)
                    return "Change";
                else
                    return LookupAccountProperties(controlledOutput.Account).AccountName;
            }
            else
            {
                var uncontrolledOutput = (WalletTransaction.Output.UncontrolledOutput)output;
                Address address;
                if (Address.TryFromOutputScript(uncontrolledOutput.PkScript, ActiveChain, out address))
                    return address.Encode();
                else
                    return "Non-address output";
            }
        }

Usage Example

コード例 #1
0
        public TransactionViewModel(Wallet wallet, WalletTransaction transaction, BlockIdentity transactionLocation)
        {
            _transaction = transaction;
            _location = transactionLocation;

            var groupedOutputs = _transaction.NonChangeOutputs.Select(o =>
            {
                var destination = wallet.OutputDestination(o);
                return new GroupedOutput(o.Amount, destination);
            }).Aggregate(new List<GroupedOutput>(), (items, next) =>
            {
                var item = items.Find(a => a.Destination == next.Destination);
                if (item == null)
                    items.Add(next);
                else
                    item.Amount += next.Amount;

                return items;
            });

            Depth = BlockChain.Depth(wallet.ChainTip.Height, transactionLocation);
            Inputs = _transaction.Inputs.Select(input => new Input(-input.Amount, wallet.AccountName(input.PreviousAccount))).ToArray();
            Outputs = _transaction.Outputs.Select(output => new Output(output.Amount, wallet.OutputDestination(output))).ToArray();
            GroupedOutputs = groupedOutputs;
        }