public Result EncryptWallet(string pwd) { ApiResponse response = WalletManagementApi.EncryptWallet(pwd).Result; var result = GetResult(response); return(result); }
/// <summary> /// /// </summary> /// <param name="path">*.dat</param> /// <returns></returns> public Result ExportBackupWallet(string path) { ApiResponse response = WalletManagementApi.BackupWallet(path).Result; var result = GetResult(response); return(result); }
public Result ImportBackupWallet(string path, string password = null) { ApiResponse response = WalletManagementApi.RestoreWalletBackup(path, password).Result; var result = GetResult(response); return(result); }
public Result <bool> UnLockWallet(string passphrase, long seconds = 50000) { ApiResponse response = WalletManagementApi.WalletPassphrase(passphrase).Result; var result = GetResult <bool>(response); return(result); }
public Result ChangeWalletPassword(string oldPwd, string newPwd) { ApiResponse response = WalletManagementApi.WalletPassphraseChange(oldPwd, newPwd).Result; var result = GetResult(response); return(result); }
public async Task Transfer() { bool isEncrypt = false; //先调用接口判断是否加密 ApiResponse response = await TransactionApi.GetTxSettings(); if (!response.HasError) { TransactionFeeSetting setting = response.GetResult <TransactionFeeSetting>(); isEncrypt = setting.Encrypt; } if (isEncrypt) { //先解锁 string password = "******"; ApiResponse unlockResponse = await WalletManagementApi.WalletPassphrase(password); if (!unlockResponse.HasError) { //write your logic /* 三处需要锁定, * 1、备份前解锁,备份后锁定 * 2、备份还原后需要锁定 * 3、转账交易前解锁,交易后锁定 */ } //锁定 ApiResponse lockResponse = await WalletManagementApi.WalletLock(); } }
public Result LockWallet() { ApiResponse response = WalletManagementApi.WalletLock().Result; var result = GetResult(response); return(result); }
public async Task BackupWallet() { //钱包备份保存路径(加密文件:.fcdatx,非加密文件:.fcdat) ApiResponse response = await WalletManagementApi.BackupWallet("D:\\wallet.fcdat"); Assert.IsFalse(response.HasError); }
public async Task RestoreWalletBackup() { //钱包路径(加密文件:.fcdatx,非加密文件:.fcdat) //fcdatx需要输入密钥 ApiResponse response = await WalletManagementApi.BackupWallet("D:\\wallet.fcdat"); Assert.IsFalse(response.HasError); }
public async Task WalletPassphrase() { //ApiResponse response = await WalletManagementApi.WalletPassphrase("P@ssw0rd$"); ApiResponse response = await WalletManagementApi.WalletPassphrase("P@ssw0rd$"); if (!response.HasError) { bool result = response.GetResult <bool>(); } Assert.IsFalse(response.HasError); }
public async Task TestSendToAddress() { ApiResponse blockChainResponse = await BlockChainEngineApi.GetBlockChainStatus(); if (!blockChainResponse.HasError) { //地址 string address = "fiiitCPyohiEPn9q11AXCdvVDouoVvgojXBcVj"; //地址校验 BlockChainStatus blockChainStatus = blockChainResponse.GetResult <BlockChainStatus>(); //验证address if (AddressTools.AddressVerfy(blockChainStatus.ChainNetwork, address)) { //判断是否加密 ApiResponse transactionResponse = await TransactionApi.GetTxSettings(); if (!transactionResponse.HasError) { TransactionFeeSetting settingResult = transactionResponse.GetResult <TransactionFeeSetting>(); if (settingResult.Encrypt) { //先解锁 string password = "******"; ApiResponse unlockResponse = await WalletManagementApi.WalletPassphrase(password); if (!unlockResponse.HasError) { ApiResponse response = await TransactionApi.SendToAddress(address, 50000000, "this is your request", "John", false); Assert.IsFalse(response.HasError); string result = response.GetResult <string>(); Assert.IsNotNull(result); } ApiResponse lockResponse = await WalletManagementApi.WalletLock(); } else { ApiResponse response = await TransactionApi.SendToAddress(address, 50000000, "this is your request", "John", false); Assert.IsFalse(response.HasError); string result = response.GetResult <string>(); Assert.IsNotNull(result); } } } } }
public async Task EncryptWallet() { string input = "P@ssw0rd$"; var regex = new Regex(@" (?=.*[0-9]) #必须包含数字 (?=.*[a-z]) #必须包含小写字母 (?=.*[A-Z]) #必须包含大写字母 (?=([\x21-\x7e]+)[^a-zA-Z0-9]) #必须包含特殊符号 .{8,30} #至少8个字符,最多30个字符 ", RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace); Assert.IsTrue(regex.IsMatch(input)); ApiResponse response = await WalletManagementApi.EncryptWallet("P@ssw0rd$"); Assert.IsFalse(response.HasError); }
public async Task WalletPassphraseChange() { ApiResponse response = await WalletManagementApi.WalletPassphraseChange("P@ssw0rd$", "P@ssw0rd$"); Assert.IsFalse(response.HasError); }
public async Task WalletLock() { ApiResponse response = await WalletManagementApi.WalletLock(); Assert.IsFalse(response.HasError); }