def create_crc_tracking(self, register_private_key: str, nickname: str,
                         url: str, location: int):
     cr_info = CRInfo(private_key=register_private_key,
                      nickname=nickname,
                      url=url,
                      location=location)
     Logger.info("{} create create_crc_tracking on success. \n{}".format(
         self.tag, cr_info))
     return cr_info
def create_cr_redeem_transaction(payload: CRInfo, output_address: str, amount: int, rpc_port: int):
    # create outputs
    outputs, total_amount = create_normal_outputs(
        output_addresses=[output_address],
        amount=amount,
        fee=util.TX_FEE,
        output_lock=0
    )

    # create inputs

    deposit_address = payload.get_deposit_address()
    inputs, change_outputs = create_normal_inputs(deposit_address, total_amount, rpc_port)
    if inputs is None or change_outputs is None:
        Logger.error("Create normal inputs failed")
        return None
    outputs.extend(change_outputs)

    # create program
    programs = list()
    redeem_script = bytes.fromhex(payload.account.redeem_script())
    program = Program(code=redeem_script, params=None)
    programs.append(program)

    # create attributes
    attributes = list()
    attribute = Attribute(
        usage=Attribute.NONCE,
        data=bytes("attributes".encode())
    )
    attributes.append(attribute)

    tx = Transaction()
    tx.version = Transaction.TX_VERSION_09
    tx.tx_type = Transaction.RETURN_CR_DEPOSIT_COIN
    tx.payload_version = 0
    tx.payload = Payload(Payload.DEFAULT_VERSION)
    tx.attributes = attributes
    tx.inputs = inputs
    tx.outputs = outputs
    tx.lock_time = 0
    tx.programs = programs

    return tx