示例#1
0
 def download_squeaks(
     self,
     addresses: List[str],
     min_block: int,
     max_block: int,
     replyto_hash: Optional[bytes],
 ) -> DownloadResult:
     interest = CInterested(
         addresses=[CSqueakAddress(address) for address in addresses],
         nMinBlockHeight=min_block,
         nMaxBlockHeight=max_block,
         replyto_squeak_hash=replyto_hash,
     ) if replyto_hash else CInterested(
         addresses=[CSqueakAddress(address) for address in addresses],
         nMinBlockHeight=min_block,
         nMaxBlockHeight=max_block,
     )
     return self.active_download_manager.download_interest(10, interest)
示例#2
0
def create_contact_profile(profile_name: str, squeak_address: str) -> SqueakProfile:
    validate_profile_name(profile_name)
    try:
        CSqueakAddress(squeak_address)
    except (Base58ChecksumError, CBitcoinAddressError):
        raise Exception(
            "Invalid squeak address: {}".format(
                squeak_address
            ),
        )
    return SqueakProfile(
        profile_name=profile_name,
        address=squeak_address,
    )
示例#3
0
 def get_interested_locator(self) -> CSqueakLocator:
     block_range = self.get_block_range()
     followed_addresses = self.get_followed_addresses()
     if len(followed_addresses) == 0:
         return CSqueakLocator(vInterested=[], )
     interests = [
         CInterested(
             addresses=[
                 CSqueakAddress(address) for address in followed_addresses
             ],
             nMinBlockHeight=block_range.min_block,
             nMaxBlockHeight=block_range.max_block,
         )
     ]
     return CSqueakLocator(vInterested=interests, )
示例#4
0
def create_signing_profile(profile_name: str, private_key: Optional[str] = None) -> SqueakProfile:
    validate_profile_name(profile_name)
    if private_key is None:
        signing_key = CSigningKey.generate()
    else:
        signing_key = CSigningKey(private_key)
    verifying_key = signing_key.get_verifying_key()
    address = CSqueakAddress.from_verifying_key(verifying_key)
    signing_key_str = str(signing_key)
    signing_key_bytes = signing_key_str.encode()
    return SqueakProfile(
        profile_name=profile_name,
        private_key=signing_key_bytes,
        address=str(address),
        following=True,
    )
示例#5
0
 def download_address_squeaks(self, squeak_address: str) -> DownloadResult:
     logger.info("Downloading address squeaks for address: {}".format(
         squeak_address, ))
     interest = CInterested(addresses=[CSqueakAddress(squeak_address)], )
     return self.active_download_manager.download_interest(10, interest)
示例#6
0
def get_address(signing_key):
    verifying_key = signing_key.get_verifying_key()
    address = CSqueakAddress.from_verifying_key(verifying_key)
    return str(address)
示例#7
0
def address(signing_key):
    verifying_key = signing_key.get_verifying_key()
    yield CSqueakAddress.from_verifying_key(verifying_key)
示例#8
0
def address_from_signing_key(signing_key):
    verifying_key = signing_key.get_verifying_key()
    return CSqueakAddress.from_verifying_key(verifying_key)