예제 #1
0
 async def get_additions_and_removals(self, header_hash: bytes32) -> Tuple[List[CoinRecord], List[CoinRecord]]:
     try:
         response = await self.fetch("get_additions_and_removals", {"header_hash": header_hash.hex()})
     except Exception:
         return [], []
     removals = []
     additions = []
     for coin_record in response["removals"]:
         removals.append(CoinRecord.from_json_dict(coin_record))
     for coin_record in response["additions"]:
         additions.append(CoinRecord.from_json_dict(coin_record))
     return additions, removals
 async def get_unspent_coins(
     self, puzzle_hash: bytes32, header_hash: Optional[bytes32] = None
 ) -> List:
     if header_hash is not None:
         d = {"puzzle_hash": puzzle_hash.hex(), "header_hash": header_hash.hex()}
     else:
         d = {"puzzle_hash": puzzle_hash.hex()}
     return [
         CoinRecord.from_json_dict(coin)
         for coin in ((await self.fetch("get_unspent_coins", d))["coin_records"])
     ]
 async def get_coin_records_by_puzzle_hash(
     self,
     puzzle_hash: bytes32,
     include_spent_coins: bool = True,
     start_height: Optional[int] = None,
     end_height: Optional[int] = None,
 ) -> List:
     d = {
         "puzzle_hash": puzzle_hash.hex(),
         "include_spent_coins": include_spent_coins
     }
     if start_height is not None:
         d["start_height"] = start_height
     if end_height is not None:
         d["end_height"] = end_height
     return [
         CoinRecord.from_json_dict(coin) for coin in ((await self.fetch(
             "get_coin_records_by_puzzle_hash", d))["coin_records"])
     ]
 async def get_unspent_coins(self, puzzle_hash: bytes32) -> List:
     d = {"puzzle_hash": puzzle_hash.hex()}
     return [
         CoinRecord.from_json_dict(coin) for coin in ((
             await self.fetch("get_unspent_coins", d))["coin_records"])
     ]