Skip to content

Memo encoding/decoding bug #61

@ABCProgger

Description

@ABCProgger

Memo encoding/decoding often raises UnicodeDecodeError, when i try decode memo message. Look on my example:

from bitsharesbase.memo import encode_memo, decode_memo
from bitsharesbase.account import PrivateKey, PublicKey

sender_private_key = '5H***********************************************'
sender_memo_key = 'BTS7***********************************************'

receiver_private_key = '5K**********************************************'
receiver_memo_key = 'BTS6***********************************************'

nonce = 389577592240607
message = 'test'

encoded_memo = encode_memo(
    priv=PrivateKey(sender_private_key, prefix='BTS'),
    pub=PublicKey(receiver_memo_key, prefix='BTS'),
    nonce=nonce,
    message='my secret message 1!'
)

result = decode_memo(
    priv=PrivateKey(receiver_private_key, prefix='BTS'),
    pub=PublicKey(sender_memo_key, prefix='BTS'),
    nonce=nonce,
    message=encoded_memo
)

assert message == result

this code raises exception:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8d in position 0: invalid start byte

in function bitsharesbase.memo.decode_memo at line 116

        return _unpad(message.decode('utf8'), 16)

Private keys and memo keys definitely correct for sender and receiver accounts, because i successfully signed and sent transactions, using this keys and your library.

Also i tried send memo transaction using cli_wallet and web wallet, and all works fine.

I need implement transaction processing for some exchange, and memo decoding very important for me, so i will use cli_wallet instead this useless library.

If memo module not works, it must be removed or marked as deprecated, because many developers may spend many days in bug search like me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions