private void InitData(UnsignTransactionResult txInfo) { this.OperationId = txInfo.OperationId; this.Transaction = txInfo.Transaction; this.SpentCoins = txInfo.ToSpentCoins; this.TxJson = this.Transaction.ToString(); }
public string SerailizeUnsignedTxResult(UnsignTransactionResult txInfo) { var joint = new UnsignedTxJoint { OperationId = txInfo.OperationId, TransactionHex = txInfo.Transaction.ToHex(), ToSpentCoins = txInfo.ToSpentCoins }; var json = Serializer.ToString(joint); var result = CryptHelper.AESEncryptText(json, EncryptUnsignedTxKey); return(result); }
public async Task <UnsignTransactionResult> CreateUnsignedTransaction(BTCTransferVM transferInfo) { var allUnspentCoins = await BTCOperator.Instance.ListUnspentAsync(transferInfo.FromAddress); var network = NetworkOperator.Instance.Network; var to = BitcoinAddress.Create(transferInfo.ToAddress, network); var change = BitcoinAddress.Create(transferInfo.ChangeAddress, network); var buildInfo = this.Build(to, change, allUnspentCoins, transferInfo.Amount, transferInfo.EstimateFeeRate); var txInfo = new BaseTransactionInfo { Id = Guid.NewGuid().ToString("N"), TransactionId = buildInfo.Transaction.GetHash().ToString(), TransactionType = (short)TransactionType.BTC, FromAddress = transferInfo.FromAddress, ToAddress = transferInfo.ToAddress, ChangeAddress = transferInfo.ChangeAddress, FeeAddress = transferInfo.FromAddress, FeeRate = transferInfo.EstimateFeeRate.SatoshiPerByte, EstimateSize = buildInfo.TransactionSize, Amount = transferInfo.Amount.ToDecimal(MoneyUnit.BTC), IsSigned = false, CreateDate = DateTime.Now }; TransactionDao.Create(txInfo); var result = new UnsignTransactionResult { OperationId = txInfo.Id, Transaction = buildInfo.Transaction, ToSpentCoins = buildInfo.InputCoins }; return(result); }