Exemple #1
0
 def load(self):
     """Load masternodes from wallet storage."""
     masternodes = self.wallet.storage.get('masternodes', {})
     self.masternodes = [MasternodeAnnounce.from_dict(d) for d in masternodes.values()]
     proposals = self.wallet.storage.get('budget_proposals', {})
     self.proposals = [BudgetProposal.from_dict(d) for d in proposals.values()]
     self.budget_votes = [BudgetVote.from_dict(d) for d in self.wallet.storage.get('budget_votes', [])]
Exemple #2
0
    def vote(self, alias, proposal_name, vote_choice):
        """Vote on a budget proposal."""
        self.check_can_vote(alias, proposal_name)
        # Validate vote choice.
        if vote_choice.upper() not in ('YES', 'NO'):
            raise ValueError('Invalid vote choice: "%s"' % vote_choice)

        # Create the vote.
        mn = self.get_masternode(alias)
        vote = BudgetVote(vin=mn.vin, proposal_hash=proposal_hash, vote=vote_choice)

        # Sign the vote with delegate key.
        sig = self.wallet.sign_budget_vote(vote, mn.delegate_key)

        return self.send_vote(vote, base64.b64encode(sig))