neo-mamba
neo-mamba copied to clipboard
wallet - token support
from https://github.com/CityOfZion/neo-mamba/pull/80#issuecomment-828387475
def token_add(self, token_hash: UInt160) -> bool:
# true if added, false if already exists
def token_delete(self, token_hash: UInt160) -> bool:
# true if deleted, false if failed if not found
def token_delete_by_name(self, token_name: str) -> bool:
# true if deleted, false if e.g. not found
My current view is that a Wallet
is merely as a container holding Account
s. Therefore adding these functions to account means an Account
is associated with 0 or more tokens. There can be helpers for Wallet
to aggregate balances of a certain token in all available accounts, but that is beyond the scope. The extra
field of the Account
can be used for storing the token hashes when exporting.
The alternative is to add these functions to Wallet
. The upside is that from a wallet you do a single import/add/delete. The downside is you're forced to use a Wallet
and it has to search all accounts for balance every time, even though you might know certain accounts will never have any.
How should the token_delete_by_name(self, token_name: str)
method be implemented? Currently, the only way to add a token is using token_add(self, token_hash: UInt160)
.