public void GetUtxoOutputByIndex(out Span <byte> commitment, out Span <byte> destinationKey, ulong tagId, int index) { if (!_utxoOutputsIndiciesMap.ContainsKey(index)) { throw new ArgumentOutOfRangeException(nameof(index)); } UtxoOutput utxoOutput = null; if (tagId == 0) { ulong utxoOutputId = _utxoOutputsIndiciesMap[index]; lock (_sync) { utxoOutput = _dataContext.UtxoOutputs.FirstOrDefault(u => u.UtxoOutputId == utxoOutputId); } } else { lock (_sync) { utxoOutput = _dataContext.UtxoOutputs.Skip(index).FirstOrDefault(); } } commitment = utxoOutput.Commitment; destinationKey = utxoOutput.DestinationKey; }
private UtxoOutput GetOrAddUtxoOutput(ulong tagId, Span <byte> commitment, Span <byte> destinationKey) { lock (_sync) { byte[] commitmentBytes = commitment.ToArray(); byte[] destinationKeyBytes = destinationKey.ToArray(); UtxoOutput utxoOutput = _dataContext.UtxoOutputs.FirstOrDefault(b => b.Commitment.Equals32(commitmentBytes) && b.DestinationKey.Equals32(destinationKeyBytes)); if (utxoOutput == null) { utxoOutput = new UtxoOutput { TagId = tagId, Commitment = commitmentBytes, DestinationKey = destinationKeyBytes }; _dataContext.UtxoOutputs.Add(utxoOutput); _dataContext.SaveChanges(); _utxoOutputsIndiciesMap.Add(_utxoOutputsIndiciesMap.Count, utxoOutput.UtxoOutputId); } return(utxoOutput); } }
public UtxoView(UtxoOutput utxo) { Title = "UTXO"; Content = new StackLayout { Margin = 5, Children = { new Label { Text = utxo.ToString(), } } }; }
public UtxoDisplay(UtxoOutput u) { this.utxo = u; this.Header = "Value: " + u.value; this.Detail = "Script: " + Convert.ToBase64String(u.script); }