Exemplo n.º 1
0
 async def pw_status(
         self,
         wallet_id: str) -> Tuple[PoolWalletInfo, List[TransactionRecord]]:
     json_dict = await self.fetch("pw_status", {"wallet_id": wallet_id})
     return (
         PoolWalletInfo.from_json_dict(json_dict["state"]),
         [
             TransactionRecord.from_json_dict(tr)
             for tr in json_dict["unconfirmed_transactions"]
         ],
     )
Exemplo n.º 2
0
    async def get_current_state(self) -> PoolWalletInfo:
        history: List[Tuple[uint32,
                            CoinSpend]] = await self.get_spend_history()
        all_spends: List[CoinSpend] = [cs for _, cs in history]

        # We must have at least the launcher spend
        assert len(all_spends) >= 1

        launcher_coin: Coin = all_spends[0].coin
        delayed_seconds, delayed_puzhash = get_delayed_puz_info_from_launcher_spend(
            all_spends[0])
        tip_singleton_coin: Optional[
            Coin] = get_most_recent_singleton_coin_from_coin_spend(
                all_spends[-1])
        launcher_id: bytes32 = launcher_coin.name()
        p2_singleton_puzzle_hash = launcher_id_to_p2_puzzle_hash(
            launcher_id, delayed_seconds, delayed_puzhash)
        assert tip_singleton_coin is not None

        curr_spend_i = len(all_spends) - 1
        extra_data: Optional[PoolState] = None
        last_singleton_spend_height = uint32(0)
        while extra_data is None:
            full_spend: CoinSpend = all_spends[curr_spend_i]
            extra_data = solution_to_extra_data(full_spend)
            last_singleton_spend_height = uint32(history[curr_spend_i][0])
            curr_spend_i -= 1

        assert extra_data is not None
        current_inner = pool_state_to_inner_puzzle(
            extra_data,
            launcher_coin.name(),
            self.wallet_state_manager.constants.GENESIS_CHALLENGE,
            delayed_seconds,
            delayed_puzhash,
        )
        return PoolWalletInfo(
            extra_data,
            self.target_state,
            launcher_coin,
            launcher_id,
            p2_singleton_puzzle_hash,
            current_inner,
            tip_singleton_coin.name(),
            last_singleton_spend_height,
        )