예제 #1
0
 def getVerkey(self, identifier):
     nym = self.clients.get(identifier)
     if not nym:
         # Querying uncommitted identities since a batch might contain
         # both identity creation request and a request by that newly
         # created identity, also its possible to have multiple uncommitted
         # batches in progress and identity creation request might
         # still be in an earlier uncommited batch
         nym = DomainRequestHandler.getNymDetails(
             self.state, identifier, isCommitted=False)
         if not nym:
             raise UnknownIdentifier(identifier)
     return nym.get(VERKEY)
예제 #2
0
 def getVerkey(self, identifier):
     nym = self.clients.get(identifier)
     if not nym:
         # Querying uncommitted identities since a batch might contain
         # both identity creation request and a request by that newly
         # created identity, also its possible to have multiple uncommitted
         # batches in progress and identity creation request might
         # still be in an earlier uncommited batch
         nym = DomainRequestHandler.getNymDetails(
             self.state, identifier, isCommitted=False)
         if not nym:
             raise UnknownIdentifier(identifier)
     return nym.get(VERKEY)
예제 #3
0
def validate_multi_sig_txn(request, required_role, domain_state, threshold: int):
    # Takes a request, a provided role and expects to find at least a threshold number
    # senders roles with provided role. Can raise an exception
    senders = request.all_identifiers
    error = ''
    if len(senders) >= threshold:
        authorized_sender_count = 0
        for idr in senders:
            if DomainRequestHandler.get_role(domain_state, idr, required_role):
                authorized_sender_count += 1
                if authorized_sender_count == threshold:
                    return
        error = 'only {} can send this transaction'. \
            format(Roles(required_role).name)
    else:
        error = 'Request needs at least {} signers but only {} found'. \
            format(threshold, len(senders))

    if error:
        raise UnauthorizedClientRequest(senders, getattr(request, f.REQ_ID.nm, None), error)
예제 #4
0
 def isSteward(self, nym, isCommitted: bool = True):
     return DomainRequestHandler.isSteward(self.states[DOMAIN_LEDGER_ID],
                                           nym, isCommitted)
 def isSteward(self, nym, isCommitted: bool = True):
     return DomainRequestHandler.isSteward(
         self.domainState, nym, isCommitted)
예제 #6
0
 def _is_trustee(self, nym: str):
     return bool(
         DomainRequestHandler.get_role(self._domain_state,
                                       nym,
                                       TRUSTEE,
                                       isCommitted=False))
예제 #7
0
 def isSteward(self, nym, isCommitted: bool = True):
     return DomainRequestHandler.isSteward(
         self.states[DOMAIN_LEDGER_ID], nym, isCommitted)