Skip to content

Commit

Permalink
Fix memo plotid (#17856)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
pmaslana committed Apr 30, 2024
1 parent e979ed1 commit ca897f1
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions chia/plotting/create_plots.py
Expand Up @@ -202,19 +202,29 @@ 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)
plot_memo = stream_plot_info_ph(keys.pool_contract_puzzle_hash, keys.farmer_public_key, sk)

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")

Expand Down

0 comments on commit ca897f1

Please sign in to comment.