From ca897f149af1a8ad63902723e37ade3eddac8e54 Mon Sep 17 00:00:00 2001 From: Patrick Maslana <79757486+pmaslana@users.noreply.github.com> Date: Tue, 30 Apr 2024 15:23:00 -0700 Subject: [PATCH] Fix memo plotid (#17856) * Convert hex to a string for memo and plotid * Create a check for converting bytes to a string and remove the 32 bytes check for memo and plotid args in create_plots.py * Return the args.plotid bytes32.fromhex(plot_str) instead of bytes.fromhex(plot_str) * Remove debugging print that was used to print out the type * Fix invalid type annotation * Start using bytes32 for the type to prevent errors * Change bytes32 to bytes --- chia/plotting/create_plots.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/chia/plotting/create_plots.py b/chia/plotting/create_plots.py index ac33b5723153..c6321d792cb5 100644 --- a/chia/plotting/create_plots.py +++ b/chia/plotting/create_plots.py @@ -202,7 +202,7 @@ async def create_plots( # The plot id is based on the harvester, farmer, and pool keys if keys.pool_public_key is not None: plot_id: bytes32 = calculate_plot_id_pk(keys.pool_public_key, plot_public_key) - plot_memo: bytes32 = stream_plot_info_pk(keys.pool_public_key, keys.farmer_public_key, sk) + plot_memo: bytes = stream_plot_info_pk(keys.pool_public_key, keys.farmer_public_key, sk) else: assert keys.pool_contract_puzzle_hash is not None plot_id = calculate_plot_id_ph(keys.pool_contract_puzzle_hash, plot_public_key) @@ -210,11 +210,21 @@ async def create_plots( if args.plotid is not None: log.info(f"Debug plot ID: {args.plotid}") - plot_id = bytes32(bytes.fromhex(args.plotid)) + # Check if args.memo is of type bytes and convert it to a string if so + if isinstance(args.plotid, bytes): + plot_str = args.plotid.hex() # Convert bytes to hex string + else: + plot_str = args.plotid + plot_id = bytes32.fromhex(plot_str) if args.memo is not None: log.info(f"Debug memo: {args.memo}") - plot_memo = bytes32.fromhex(args.memo) + # Check if args.memo is of type bytes and convert it to a string if so + if isinstance(args.memo, bytes): + memo_str = args.memo.hex() # Convert bytes to hex string + else: + memo_str = args.memo + plot_memo = bytes.fromhex(memo_str) dt_string = datetime.now().strftime("%Y-%m-%d-%H-%M")