Esempio n. 1
0
        public override IFederationMember DeserializeFederationMember(byte[] serializedBytes)
        {
            string json = Encoding.ASCII.GetString(serializedBytes);

            CollateralFederationMemberModel model = Serializer.ToObject <CollateralFederationMemberModel>(json);

            var member = new CollateralFederationMember(new PubKey(model.PubKeyHex), false, new Money(model.CollateralAmountSatoshis), model.CollateralMainchainAddress);

            return(member);
        }
        public CollateralFederationMember CollateralAddressOwner(VotingManager votingManager, VoteKey voteKey, string address)
        {
            CollateralFederationMember member = (this.federationMembers.Cast <CollateralFederationMember>().FirstOrDefault(x => x.CollateralMainchainAddress == address));

            if (member != null)
            {
                return(member);
            }

            List <Poll> approvedPolls = votingManager.GetApprovedPolls();

            member = approvedPolls
                     .Where(x => !x.IsExecuted && x.VotingData.Key == voteKey)
                     .Select(x => this.GetMember(x.VotingData))
                     .FirstOrDefault(x => x.CollateralMainchainAddress == address);

            if (member != null)
            {
                return(member);
            }

            List <Poll> pendingPolls = votingManager.GetPendingPolls();

            member = pendingPolls
                     .Where(x => x.VotingData.Key == voteKey)
                     .Select(x => this.GetMember(x.VotingData))
                     .FirstOrDefault(x => x.CollateralMainchainAddress == address);

            if (member != null)
            {
                return(member);
            }

            List <VotingData> scheduledVotes = votingManager.GetScheduledVotes();

            member = scheduledVotes
                     .Where(x => x.Key == voteKey)
                     .Select(x => this.GetMember(x))
                     .FirstOrDefault(x => x.CollateralMainchainAddress == address);

            return(member);
        }