-
Notifications
You must be signed in to change notification settings - Fork 12
Wallet
SubstrateNetWallet is a Wallet built on top of the SubstrateNetApi, it offers common functionalities. This is a basic implementation and hasn't currently be audited or reviewed on security issues. If you have any bug or security issues, please get in touch with us or create a pull request.
This is an implementation in progress, feedback is welcome!
- Key derivation, currently only for ED25519
- Private keystore with AES encryption (please verify code before using in a productive environment)
- Sign message & verify message
- Transfer balance
- realtime (subscription) updated newHeads and finalizedHeads
- realtime (subscription) updated extrinsicUpdate
For Password and Wallet validation, please look at the inline code description in the Wallet.cs.
To create the wallet the SubstrateNetWallet offers two kinds of creations, one is with Mnemonic and one is without. Both creation methods will encrypt their private key with a random salted AES encryption into a wallet file, the creation method without the mnemonic seed is depending on the wallet file and if that is lost the wallet isn't accessible anymore. creating with the mnemonic seed will allow recreating a lost wallet file.
Without the mnemonic seed the basic wallet will use the Ed25519 key type.
public async Task<bool> CreateAsync(string password, string walletName = DefaultWalletName)
With the mnemonic seed the basic wallet will use the Sr25519 key type.
public async Task<bool> CreateAsync(string password, string mnemonic, string walletName = DefaultWalletName)
The current implementation of Mnemonic allows to add a mnemonic, from the application side, to be sure to be in line with what is allowed and whatnot, please refer to the implementation and the tests in the SubstrateNetApi under Mnemonic and MnemonicTest.
The creation from mnemonic is deterministic and is reproducable, so a restore of a lost wallet, of which the owner still has the mnemonic can be just recreated by using the create function.
public async Task<bool> CreateAsync(string password, string mnemonic, string walletName = DefaultWalletName)
The process of unlocking a wallet file changes the state of the wallet to IsUnlocked = true.
The WalletFile is held in the format of JSON, and has the following structure.
{
"KeyType":0,
"PublicKey": "n54B....Wk4=",
"EncryptedSeed": "F+Oa....dRPqKQ=",
"Salt": "NPBi....ulQ=="
}
This API is being developed and maintained by the BloGa Tech AG (Switzerland) and is part of Open Grants Program of the Web3 Foundation.