def get_memos_from(self, t): """ """ txs = NetworkAPI.get_transactions_by_address_from(self._address, t) memos = [ Memo.form_transaction_dict(tx) for tx in txs if Memo.is_memo(tx) ] self.memos_send = [ memo for memo in memos if memo.sender == self._address ] self.memos_receive = [ memo for memo in memos if memo.sender != self._address ] self.memos_post = [ memo for memo in self.memos_send if memo.prefix == PRIFIX_BY_ACTION_NAME['Post memo'] ] self.memos_like = [ memo for memo in self.memos_send if memo.prefix == PRIFIX_BY_ACTION_NAME['Like / tip memo'] ] for memo in reversed(self.memos_send): if memo.prefix == PRIFIX_BY_ACTION_NAME['Set name']: self.name = memo.name USER_NAME_DICT[memo.sender] = memo.name if memo.prefix == PRIFIX_BY_ACTION_NAME['Follow user']: self.following.add(memo.address) if memo.prefix == PRIFIX_BY_ACTION_NAME['Unfollow user']: self.following.remove(memo.address)
def like_memo_tx(self, liked_memo, tip_amount=None, sender_of_liked_memo=None): """ :param liked_memo: the memo or to tip or like, or, the transaction hash of that memo :type liked_memo: ``Memo`` or ``str`` :param tip_amount: 0 for like, >546 for tip, in satoshi :type tip_amount: ``int`` :param sender_of_liked_memo: sender's address of liked memo.If liked_memo is transaction hash and this is None, this need be get from NetworkAPI :type sender_of_liked_memo: ``str`` :return: """ if isinstance(liked_memo, Memo): memo = Memo.like_memo(liked_memo, self._address, tip_amount=tip_amount) elif isinstance(liked_memo, str): if sender_of_liked_memo is None: liked_memo = Memo.from_txhash(liked_memo) memo = Memo.like_memo(liked_memo, self._address, tip_amount=tip_amount) else: memo = Memo.like_memo( liked_memo, self._address, tip_amount=tip_amount, sender_of_liked_memo=sender_of_liked_memo) else: raise TypeError('liked_memo should be Memo object or string!') return self.__send_new_memo(memo)
def unfollow(self, address): """ :param address: no more than 76 bytes :type address: ``str`` :return: transaction id """ memo=Memo.unfollow(address,self._address) return self.__send_new_memo(memo)
def post_memo(self, message): """ :param message: no more than 76 bytes :type message: ``str`` :return: transaction id """ memo=Memo.post_memo(message,self._address) return self.__send_new_memo(memo)
def set_name(self, name): """ :param name: no more than 76 bytes :type name: ``str`` :return: transaction id """ memo=Memo.set_name(name,self._address) return self.__send_new_memo(memo)
def follow(self, address): """ :param address: :type address: ``str`` :return: transaction id """ memo=Memo.follow(address,self._address) return self.__send_new_memo(memo)
def like_memo(self, liked_memo,tip_amount=None): memo=Memo.like_memo(liked_memo,self._address,tip_amount=tip_amount) return self.__send_new_memo(memo)