I am running into a problem with the LogicSig
class in the transaction.py file in the SDK.
Error:
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/algosdk/transaction.py", line 2653, in sign
self.sig = LogicSig.sign_program(self.logic, private_key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/algosdk/transaction.py", line 2614, in sign_program
private_key = base64.b64decode(private_key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/base64.py", line 83, in b64decode
s = _bytes_from_decode_data(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/base64.py", line 45, in _bytes_from_decode_data
raise TypeError("argument should be a bytes-like object or ASCII "
TypeError: argument should be a bytes-like object or ASCII string, not 'LogicSig'
Code failing in transaction.py
file.
@staticmethod
def sign_program(program, private_key):
private_key = base64.b64decode(private_key)
signing_key = SigningKey(private_key[: constants.key_len_bytes])
to_sign = constants.logic_prefix + program
signed = signing_key.sign(to_sign)
return base64.b64encode(signed.signature).decode()
def sign(self, private_key, multisig=None):
"""
Creates signature (if no pk provided) or multi signature
Args:
private_key (str): private key of signing account
multisig (Multisig): optional multisig account without signatures
to sign with
Raises:
InvalidSecretKeyError: if no matching private key in multisig\
object
LogicSigOverspecifiedSignature: if the opposite signature type has
already been provided
"""
if not multisig:
if self.msig:
raise error.LogicSigOverspecifiedSignature
self.sig = LogicSig.sign_program(self.logic, private_key)
else:
if self.sig:
raise error.LogicSigOverspecifiedSignature
sig, index = LogicSig.single_sig_multisig(
self.logic, private_key, multisig
)
multisig.subsigs[index].signature = base64.b64decode(sig)
self.msig = multisig