示例#1
0
 def make_solution(
     self,
     primaries: Optional[List[Dict[str, bytes32]]] = None,
     min_time=0,
     me=None,
     announcements=None,
     announcements_to_consume=None,
     fee=0,
 ) -> Program:
     assert fee >= 0
     condition_list = []
     if primaries:
         for primary in primaries:
             condition_list.append(
                 make_create_coin_condition(primary["puzzlehash"],
                                            primary["amount"]))
     if min_time > 0:
         condition_list.append(
             make_assert_seconds_now_exceeds_condition(min_time))
     if me:
         condition_list.append(make_assert_my_coin_id_condition(me["id"]))
     if fee:
         condition_list.append(make_reserve_fee_condition(fee))
     if announcements:
         for announcement in announcements:
             condition_list.append(make_create_announcement(announcement))
     if announcements_to_consume:
         for announcement_hash in announcements_to_consume:
             condition_list.append(
                 make_assert_announcement(announcement_hash))
     return solution_for_conditions(condition_list)
示例#2
0
 def make_solution(
     self,
     primaries=None,
     min_time=0,
     me=None,
     announcements=None,
     announcements_to_consume=None,
     fee=0,
 ):
     assert fee >= 0
     condition_list = []
     if primaries:
         for primary in primaries:
             condition_list.append(make_create_coin_condition(primary["puzzlehash"], primary["amount"]))
     if min_time > 0:
         condition_list.append(make_assert_time_exceeds_condition(min_time))
     if me:
         condition_list.append(make_assert_my_coin_id_condition(me["id"]))
     if fee:
         condition_list.append(make_assert_fee_condition(fee))
     if announcements:
         for announcement in announcements:
             condition_list.append(make_create_announcement(announcement))
     if announcements_to_consume:
         for announcement_hash in announcements_to_consume:
             condition_list.append(make_assert_announcement(announcement_hash))
     return solution_for_conditions(condition_list)
    def make_solution(
        self, condition_dic: Dict[ConditionOpcode,
                                  List[ConditionVarPair]]) -> Program:
        ret = []

        for con_list in condition_dic.values():
            for cvp in con_list:
                if cvp.opcode == ConditionOpcode.CREATE_COIN:
                    ret.append(
                        make_create_coin_condition(cvp.vars[0], cvp.vars[1]))
                if cvp.opcode == ConditionOpcode.CREATE_ANNOUNCEMENT:
                    ret.append(make_create_announcement(cvp.vars[0]))
                if cvp.opcode == ConditionOpcode.AGG_SIG:
                    ret.append(make_assert_aggsig_condition(cvp.vars[0]))
                if cvp.opcode == ConditionOpcode.ASSERT_ANNOUNCEMENT:
                    ret.append(make_assert_announcement(cvp.vars[0]))
                if cvp.opcode == ConditionOpcode.ASSERT_SECONDS_NOW_EXCEEDS:
                    ret.append(
                        make_assert_seconds_now_exceeds_condition(cvp.vars[0]))
                if cvp.opcode == ConditionOpcode.ASSERT_MY_COIN_ID:
                    ret.append(make_assert_my_coin_id_condition(cvp.vars[0]))
                if cvp.opcode == ConditionOpcode.ASSERT_HEIGHT_NOW_EXCEEDS:
                    ret.append(
                        make_assert_height_now_exceeds_condition(cvp.vars[0]))
                if cvp.opcode == ConditionOpcode.ASSERT_HEIGHT_AGE_EXCEEDS:
                    ret.append(
                        make_assert_height_age_exceeds_condition(cvp.vars[0]))
                if cvp.opcode == ConditionOpcode.RESERVE_FEE:
                    ret.append(make_reserve_fee_condition(cvp.vars[0]))
        return solution_for_conditions(Program.to(ret))
示例#4
0
    def make_solution(
        self, condition_dic: Dict[ConditionOpcode,
                                  List[ConditionVarPair]]) -> Program:
        ret = []

        for con_list in condition_dic.values():
            for cvp in con_list:
                if cvp.opcode == ConditionOpcode.CREATE_COIN:
                    ret.append(
                        make_create_coin_condition(cvp.vars[0], cvp.vars[1]))
                if cvp.opcode == ConditionOpcode.CREATE_ANNOUNCEMENT:
                    ret.append(make_create_announcement(cvp.vars[0]))
                if cvp.opcode == ConditionOpcode.AGG_SIG:
                    ret.append(make_assert_aggsig_condition(cvp.vars[0]))
                if cvp.opcode == ConditionOpcode.ASSERT_ANNOUNCEMENT:
                    ret.append(make_assert_announcement(cvp.vars[0]))
                if cvp.opcode == ConditionOpcode.ASSERT_TIME_EXCEEDS:
                    ret.append(make_assert_time_exceeds_condition(cvp.vars[0]))
                if cvp.opcode == ConditionOpcode.ASSERT_MY_COIN_ID:
                    ret.append(make_assert_my_coin_id_condition(cvp.vars[0]))
                if cvp.opcode == ConditionOpcode.ASSERT_BLOCK_INDEX_EXCEEDS:
                    ret.append(
                        make_assert_block_index_exceeds_condition(cvp.vars[0]))
                if cvp.opcode == ConditionOpcode.ASSERT_BLOCK_AGE_EXCEEDS:
                    ret.append(
                        make_assert_block_age_exceeds_condition(cvp.vars[0]))
                if cvp.opcode == ConditionOpcode.ASSERT_FEE:
                    ret.append(make_assert_fee_condition(cvp.vars[0]))
        return solution_for_conditions(Program.to(ret))