public async Task <BlockAPIResult> CreateStakingAccountAsync(string Name, string voteFor, int daysToStake, bool compoundMode) { var tags = new Dictionary <string, string> { { Block.REQSERVICETAG, BrokerActions.BRK_STK_CRSTK }, { "name", Name }, { "voting", voteFor }, { "days", daysToStake.ToString() }, { "compound", compoundMode.ToString() } }; var amounts = new Dictionary <string, decimal> { { LyraGlobal.OFFICIALTICKERCODE, PoolFactoryBlock.StakingAccountCreateFee } }; var result = await SendExAsync(PoolFactoryBlock.FactoryAccount, amounts, tags); if (result.ResultCode != APIResultCodes.Success) { return new BlockAPIResult { ResultCode = result.ResultCode } } ; for (int i = 0; i < 10; i++) { // then find by RelatedTx var blocks = await _node.GetBlocksByRelatedTxAsync((await GetLatestBlockAsync()).Hash); if (blocks.Successful()) { var txs = blocks.GetBlocks(); var gen = txs.FirstOrDefault(a => a is IBrokerAccount pb && pb.OwnerAccountId == AccountId); if (gen != null) { var ret = new BlockAPIResult { ResultCode = APIResultCodes.Success, }; ret.SetBlock(gen); return(ret); } } await Task.Delay(500); } return(new BlockAPIResult { ResultCode = APIResultCodes.ConsensusTimeout }); }
public async Task <BlockAPIResult> CreateProfitingAccountAsync(string Name, ProfitingType ptype, decimal shareRito, int maxVoter) { var tags = new Dictionary <string, string> { { Block.REQSERVICETAG, BrokerActions.BRK_PFT_CRPFT }, { "name", Name }, // get by name. name can't duplicate { "ptype", ptype.ToString() }, { "share", $"{shareRito}" }, { "seats", $"{maxVoter}" } }; var amounts = new Dictionary <string, decimal> { { LyraGlobal.OFFICIALTICKERCODE, PoolFactoryBlock.ProfitingAccountCreateFee } }; var result = await SendExAsync(PoolFactoryBlock.FactoryAccount, amounts, tags); if (result.ResultCode != APIResultCodes.Success) { return new BlockAPIResult { ResultCode = result.ResultCode } } ; for (int i = 0; i < 10; i++) { // then find by RelatedTx var blocks = await _node.GetBlocksByRelatedTxAsync((await GetLatestBlockAsync()).Hash); if (blocks.Successful()) { var txs = blocks.GetBlocks(); var gen = txs.FirstOrDefault(a => a is ProfitingBlock pb && pb.OwnerAccountId == AccountId); if (gen != null) { var ret = new BlockAPIResult { ResultCode = APIResultCodes.Success, }; ret.SetBlock(gen); return(ret); } } await Task.Delay(500); } return(new BlockAPIResult { ResultCode = APIResultCodes.ConsensusTimeout }); }