bitshares.memo module

class bitshares.memo.Memo(*args, **kwargs)[source]

Bases: bitshares.instance.BlockchainInstance, bitshares.memo.Memo

Deals with Memos that are attached to a transfer.

Parameters:

A memo is encrypted with a shared secret derived from a private key of the sender and a public key of the receiver. Due to the underlying mathematics, the same shared secret can be derived by the private key of the receiver and the public key of the sender. The encrypted message is perturbed by a nonce that is part of the transmitted message.

from bitshares.memo import Memo
m = Memo("bitshareseu", "wallet.xeroc")
m.unlock_wallet("secret")
enc = (m.encrypt("foobar"))
print(enc)
>> {'nonce': '17329630356955254641', 'message': '8563e2bb2976e0217806d642901a2855'}
print(m.decrypt(enc))
>> foobar

To decrypt a memo, simply use

from bitshares.memo import Memo
m = Memo()
m.blockchain.wallet.unlock("secret")
print(memo.decrypt(op_data["memo"]))

if op_data being the payload of a transfer operation.

bitshares

Alias for the specific blockchain.

blockchain
blockchain_instance_class

alias of bitshares.instance.BlockchainInstance

chain

Short form for blockchain (for the lazy)

decrypt(message)[source]

Decrypt a message

Parameters:message (dict) – encrypted memo message
Returns:decrypted message
Return type:str
define_classes()[source]

Needs to define instance variables that provide classes

encrypt(message)[source]

Encrypt a memo

Parameters:message (str) – clear text memo message
Returns:encrypted message
Return type:str
get_instance_class()

Should return the Chain instance class, e.g. bitshares.BitShares

classmethod inject(cls)
classmethod set_shared_blockchain_instance(instance)

This method allows us to override default instance for all users of SharedInstance.instance.

Parameters:instance (chaininstance) – Chain instance
classmethod set_shared_config(config)

This allows to set a config that will be used when calling shared_blockchain_instance and allows to define the configuration without requiring to actually create an instance

set_shared_instance()

This method allows to set the current instance as default

shared_blockchain_instance()

This method will initialize SharedInstance.instance and return it. The purpose of this method is to have offer single default instance that can be reused by multiple classes.

unlock_wallet(*args, **kwargs)[source]

Unlock the library internal wallet