peerplays.memo module¶
-
class
peerplays.memo.
Memo
(*args, **kwargs)¶ Bases:
peerplays.instance.BlockchainInstance
,peerplays.memo.Memo
Deals with Memos that are attached to a transfer
Parameters: - from_account (peerplays.account.Account) – Account that has sent the memo
- to_account (peerplays.account.Account) – Account that has received the memo
- blockchain_instance (peerplays.peerplays.PeerPlays) – instance
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 peerplays.memo import Memo m = Memo("from", "to") 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 peerplays.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.-
blockchain
¶
-
blockchain_instance_class
¶
-
chain
¶ Short form for blockchain (for the lazy)
-
decrypt
(message)¶ Decrypt a message
Parameters: message (dict) – encrypted memo message Returns: decrypted message Return type: str
-
define_classes
()¶ Needs to define instance variables that provide classes
-
encrypt
(message)¶ 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. peerplays.PeerPlays
-
classmethod
inject
(cls)¶
-
peerplays
¶ Alias for the specific blockchain
This method allows us to override default instance for all users of
SharedInstance.instance
.Parameters: instance (chaininstance) – Chain instance
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
This method allows to set the current instance as default
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)¶ Unlock the library internal wallet