Exemple #1
0
 /// <summary>
 /// Default constructor which requires an environment and an optional commitmenttype
 /// </summary>
 /// <param name="environment">The environment of the agent</param>
 /// <param name="comType">The commimenttype of the agent and if not given, is set to blind commitment</param>
 public Agent(TEnvironment environment, CommitmentType?comType = null)
 {
     Environment = environment;
     if (comType.HasValue)
     {
         _commitmentType = comType.Value;
     }
 }
        public async Task <ICommitment> CreateCommitment(CommitmentType type, Guid channelTransactionId, string multisig, string asset,
                                                         string revokePubKey, string initialTr, decimal clientAmount, decimal hubAmount, string lockedAddress, string lockedScript)
        {
            var entity = CommitmentEntity.Create(channelTransactionId, type, multisig, asset, revokePubKey,
                                                 initialTr, clientAmount, hubAmount, lockedAddress, lockedScript);
            await _table.InsertAsync(entity);

            return(entity);
        }
 public static CommitmentEntity Create(Guid channelTransactionId, CommitmentType type, string multisig,
                                       string asset,
                                       string revokePubKey, string initialTr, decimal clientAmount, decimal hubAmount, string lockedAddress, string lockedScript)
 {
     return(new CommitmentEntity
     {
         BsonId = GenerateId(),
         ChannelId = channelTransactionId,
         Multisig = multisig,
         AssetId = asset,
         Type = type,
         RevokePubKey = revokePubKey,
         InitialTransaction = initialTr,
         ClientAmount = clientAmount,
         HubAmount = hubAmount,
         LockedAddress = lockedAddress,
         LockedScript = lockedScript,
         CreateDt = DateTime.UtcNow,
         Actual = true
     });
 }
 public async Task <ICommitment> GetLastCommitment(string multisig, string asset, CommitmentType type)
 {
     return(await _table.GetTopRecordAsync(o => o.Multisig == multisig && o.AssetId == asset && o.Type == type &&
                                           o.Actual,
                                           o => o.CreateDt, SortDirection.Descending));
 }