File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -73,10 +73,15 @@ def create_buffer_account(
73
73
space : int ,
74
74
lamports : int ,
75
75
) -> Tuple [PublicKey , TransactionInstruction ]:
76
- # The seed should be str but later is used in rust as
77
- # &str and therefore we use latin1 encoding to map byte
78
- # i to char i
79
- seed = bytes (publisher_pubkey ).decode ("latin-1" )
76
+ # Since the string representation of the PublicKey is 44 bytes long (base58 encoded)
77
+ # and we use 32 bytes of it, the chances of collision are very low.
78
+ #
79
+ # The seed has a max length of 32 and although the publisher_pubkey is 32 bytes,
80
+ # it is impossible to convert it to a string with a length of 32 that the
81
+ # underlying library (solders) can handle. We don't know exactly why, but it
82
+ # seems to be related to str -> &str conversion in pyo3 that solders uses to
83
+ # interact with the Rust implementation of the logic.
84
+ seed = str (publisher_pubkey )[:32 ]
80
85
new_account_pubkey = PublicKey .create_with_seed (
81
86
base_pubkey ,
82
87
seed ,
You can’t perform that action at this time.
0 commit comments