コード例 #1
0
    def test_getTransaction(self):
        with set_qrl_dir("wallet_ver1"):
            walletd = WalletD()
            service = WalletAPIService(walletd)

            tx = qrl_pb2.Transaction()
            tx.fee = 10
            tx.transaction_hash = b'1234'
            tx.message.message_hash = b'hello'
            pk = '01020016ecb9f39b9f4275d5a49e232346a15ae2fa8c50a2927daeac189b8c5f2d1' \
                 '8bc4e3983bd564298c49ae2e7fa6e28d4b954d8cd59398f1225b08d6144854aee0e'
            tx.public_key = bytes(hstr2bin(pk))

            walletd._public_stub.GetTransaction = Mock(
                return_value=qrl_pb2.GetTransactionResp(tx=tx,
                                                        confirmations=10))

            resp = service.GetTransaction(
                qrlwallet_pb2.TransactionReq(tx_hash=tx.transaction_hash),
                context=None)

            self.assertEqual(resp.code, 0)
            self.assertIsNotNone(resp.tx)
            self.assertEqual(bin2hstr(tx.transaction_hash),
                             resp.tx.transaction_hash)
コード例 #2
0
ファイル: qrlnode.py プロジェクト: theQRL/QRL
    def get_multi_sig_spend_txs_by_address(self,
                                           address: bytes,
                                           item_per_page: int,
                                           page_number: int,
                                           filter_type: int):
        # filter_type = 0 |  No Filter (default)
        # filter_type = 1 |  Executed Only (All executed are considered to be expired)
        # filter_type = 2 |  Non Executed
        # filter_type = 3 |  Expired
        # filter_type = 4 |  Non Expired
        # filter_type = 5 |  Non Executed & Expired
        # filter_type = 6 |  Non Executed & Non Expired

        if item_per_page == 0:
            return None

        transaction_hashes = self._load_multi_sig_spend_txn_hashes(address,
                                                                   item_per_page,
                                                                   page_number,
                                                                   filter_type)

        response = qrl_pb2.GetMultiSigSpendTxsByAddressResp()

        for tx_hash in transaction_hashes:
            if filter_type in (1, 2, 5, 6):
                vote_stats = self._chain_manager.get_vote_stats(tx_hash)
                if filter_type == 1 and not vote_stats.executed:
                    continue
                if filter_type in (2, 5, 6) and vote_stats.executed:
                    continue
            tx, block_number = self._chain_manager.get_tx_metadata(tx_hash)

            current_block_number = self._chain_manager.height

            is_expired = tx.expiry_block_number <= current_block_number
            if filter_type in (4, 6):
                if is_expired:
                    continue

            if filter_type in (3, 5):
                if not is_expired:
                    continue

            b = self.get_block_from_index(block_number)
            transaction_detail = qrl_pb2.GetTransactionResp(tx=tx.pbdata,
                                                            confirmations=self.block_height - block_number + 1,
                                                            block_number=block_number,
                                                            block_header_hash=b.headerhash,
                                                            timestamp=b.timestamp,
                                                            addr_from=tx.addr_from)
            response.transactions_detail.extend([transaction_detail])

        return response
コード例 #3
0
ファイル: PublicAPIService.py プロジェクト: LordGenry/QRL
    def GetTransaction(self, request: qrl_pb2.GetTransactionReq, context) -> qrl_pb2.GetTransactionResp:
        logger.debug("[PublicAPI] GetTransaction")
        response = qrl_pb2.GetTransactionResp()
        tx_blocknumber = self.qrlnode.get_transaction(request.tx_hash)
        if tx_blocknumber:
            response.tx.MergeFrom(tx_blocknumber[0].pbdata)
            response.confirmations = self.qrlnode.block_height - tx_blocknumber[1] + 1
            response.block_number = tx_blocknumber[1]
            response.block_header_hash = self.qrlnode.get_block_header_hash_by_number(tx_blocknumber[1])
        else:
            tx_timestamp = self.qrlnode.get_unconfirmed_transaction(request.tx_hash)
            if tx_timestamp:
                response.tx.MergeFrom(tx_timestamp[0].pbdata)
                response.confirmations = 0

        return response
コード例 #4
0
ファイル: qrlnode.py プロジェクト: theQRL/QRL
    def get_inbox_messages_by_address(self, address: bytes, item_per_page: int, page_number: int):
        if item_per_page == 0:
            return None
        transaction_hashes = self._load_inbox_message_transaction_hashes(address,
                                                                         item_per_page,
                                                                         page_number)

        response = qrl_pb2.GetTransactionsByAddressResp()
        for tx_hash in transaction_hashes:
            tx, block_number = self._chain_manager.get_tx_metadata(tx_hash)
            b = self.get_block_from_index(block_number)
            transaction_detail = qrl_pb2.GetTransactionResp(tx=tx.pbdata,
                                                            confirmations=self.block_height - block_number + 1,
                                                            block_number=block_number,
                                                            block_header_hash=b.headerhash,
                                                            timestamp=b.timestamp,
                                                            addr_from=tx.addr_from)
            response.transactions_detail.extend([transaction_detail])

        return response