neo3.wallet.account
Classes to work with account key material.
Account— Container class for handling key material. Can be used to sign transactions.AccountContract— Generic contract.MultiSigContext— Signing context for use with multi signature accounts.
neo3.wallet.account.Account(private_key=None, watch_only=False, address=None, label=None, lock=False, contract_=None, extra=None, scrypt_parameters=None)
Container class for handling key material. Can be used to sign transactions.
is_multisig(bool) — Return if the account requires multiple signers.is_single_sig(bool) — Return if the account requires a single signer.is_watchonly(bool) — Return if the account can only be used for observing or in test transactions.script_hash(UInt160) — Return account script hash.
add_as_sender(tx,scope)— Add the account as sender of the transaction.sign(data)(bytes) — Sign arbitrary data using the SECP256R1 curve.sign_multisig_tx(tx,context,magic)— Sign a transaction with a multi-signature account.sign_tx(tx,magic)— Helper function that signs the TX, adds the Witness and Sender.to_json(password,scrypt_parameters)(dict) — Encode account into NEP-6 JSON formatcreate_new(scrypt_parameters)(Account) — Instantiate and returns a new account.from_encrypted_key(encrypted_key,password,scrypt_parameters)(Account) — Instantiate and returns an account from a given key and password.Default settings assume a NEP-2 encrypted key.from_json(json,password,scrypt_parameters)(Account) — Parse object out of JSON data.from_private_key(private_key,scrypt_parameters)(Account) — Instantiate and returns an account from a given private key and password.from_wif(wif,_scrypt_parameters)(Account) — Instantiate and returns an account from a given wif and password.watch_only(script_hash)(Account) — Instantiate and returns a watch-only account from a given script hash.watch_only_from_address(address)(Account) — Instantiate and returns a watch-only account from a given address.private_key_from_nep2(nep2_key,passphrase,_scrypt_parameters)(bytes) — Decrypt a nep2 key into a private key.private_key_from_wif(wif)(bytes) — Decrypt a private key from a wif.private_key_to_nep2(private_key,passphrase,_scrypt_parameters)(bytes) — Encrypt a private key into a nep2 key.
add_as_sender(tx, scope=None)
Add the account as sender of the transaction.
tx(Transaction) — the transaction to modify.scope(Optional, optional) — the type of scope the signature of the sender has. Defaults to CALLED_BY_ENTRY.See Also: WitnessScope.
create_new(scrypt_parameters=None)
Instantiate and returns a new account.
scrypt_parameters(Optional, optional) — supply custom Scrypt parameters.
The newly created account.
from_encrypted_key(encrypted_key, password, scrypt_parameters=None)
Instantiate and returns an account from a given key and password.Default settings assume a NEP-2 encrypted key.
encrypted_key(str) — the encrypted private key.password(str) — the password to decrypt the nep2 key.scrypt_parameters(Optional, optional) — supply custom Scrypt parameters.
The newly created account.
from_json(json, password, scrypt_parameters=None) → Account
Parse object out of JSON data.
json(dict) — a dictionary.password(Optional) — the password to decrypt the json data.scrypt_parameters(Optional, optional) — the Scrypt parameters to use to encode the private key. Default conforms to NEP-2.
KeyError— if the data supplied does not contain the necessary key.
from_private_key(private_key, scrypt_parameters=None)
Instantiate and returns an account from a given private key and password.
private_key(bytes) — the private key that will be used to create an encrypted key.scrypt_parameters(Optional, optional) — optional custom parameters to be used in the Scrypt algorithm. Default settings conform
the newly created account.
from_wif(wif, _scrypt_parameters=None)
Instantiate and returns an account from a given wif and password.
wif(str) — the wif that will be decrypted to get a private key and generate an encrypted key._scrypt_parameters(Optional, optional) — the Scrypt parameters to use to encode the private key. Default conforms to NEP-2.
the newly created account.
private_key_from_nep2(nep2_key, passphrase, _scrypt_parameters=None)
Decrypt a nep2 key into a private key.
nep2_key(str) — the key that will be decrypted.passphrase(str) — the password to decrypt the nep2 key._scrypt_parameters(Optional, optional) — a ScryptParameters object that will be passed to the key derivation function.
ValueError— if the length of the nep2_key is not valid.ValueError— if it's not possible to decode the nep2_key.ValueError— if the passphrase is incorrect or the version of the account is not valid.
the private key.
private_key_from_wif(wif) → bytes
Decrypt a private key from a wif.
wif(str) — the wif that will be decrypted.
ValueError— if the wif is not valid.
private_key_to_nep2(private_key, passphrase, _scrypt_parameters=None)
Encrypt a private key into a nep2 key.
private_key(bytes) — the key that will be encrypted.passphrase(str) — the password to encrypt the nep2 key._scrypt_parameters(Optional, optional) — a ScryptParameters object that will be passed to the key derivation function.
the encrypted nep2 key.
sign(data)
Sign arbitrary data using the SECP256R1 curve.
data(bytes) — data to be signed.
signature of the signed data.
sign_multisig_tx(tx, context, magic=None)
Sign a transaction with a multi-signature account.
tx(Transaction) — the transaction to sign.context(MultiSigContext) — the signing context.magic(Optional, optional) — override network magic.
sign_tx(tx, magic=None)
Helper function that signs the TX, adds the Witness and Sender.
tx(Transaction) — transaction to sign.magic(Optional, optional) — the network magic.
ValueError— if transaction validation fails.
to_json(password, scrypt_parameters=None) → dict
Encode account into NEP-6 JSON format
password(str) — passphrase to use to encode the private key using NEP-2.scrypt_parameters(Optional, optional) — the Scrypt parameters to use to encode the private key. Default conforms to NEP-2.
watch_only(script_hash)
Instantiate and returns a watch-only account from a given script hash.
script_hash(UInt160) — the script hash that will identify an account to be watched.
the account that will be monitored.
watch_only_from_address(address)
Instantiate and returns a watch-only account from a given address.
address(str) — the address that will identify an account to be watched.
the account that will be monitored.
neo3.wallet.account.AccountContract(script, parameter_list)
Generic contract.
script— The contract instructions (OpCodes)script_hash(UInt160) — The contract script hash.
to_json()(dict) — Convert object into JSON representation.create_multisig_contract(m,public_keys)(Contract) — Create a multi-signature contract requiringmsignatures from the listpublic_keys.create_signature_contract(public_key)(Contract) — Create a signature contract.from_json(json)(AccountContract) — Parse object out of JSON data.
create_multisig_contract(m, public_keys) → Contract
Create a multi-signature contract requiring m signatures from the list public_keys.
m(int) — minimum number of signature required for signing. Can't be lower than 2.public_keys(Sequence) — public keys to use during verification.
create_signature_contract(public_key) → Contract
Create a signature contract.
public_key(ECPoint) — the public key to use during verification.
from_json(json) → AccountContract
Parse object out of JSON data.
json(dict) — a dictionary.
to_json() → dict
Convert object into JSON representation.
neo3.wallet.account.MultiSigContext()
Signing context for use with multi signature accounts.
expected_public_keys(list) — list of valid public keys for signing.initialised— indicates if the context has been initialised for usage.signature_pairs(dict) — completed pairs.signing_threshold— minimum of signatures required for signing.