Exemplo n.º 1
0
        public bool TryGetChainUtxoImpl(uint256 genesisBlockHash, ulong utxoId, ref ChainError error, out Script script,
                                        out Money amountSatoshi)
        {
            script        = null;
            amountSatoshi = null;
            var shortChannelId = Primitives.ShortChannelId.FromUInt64(utxoId);

            _logger.LogDebug($"query block by shortchannel id {shortChannelId}");
            var b = NbxplorerClient.RPCClient.GetBlock(shortChannelId.BlockHeight.Item);

            if (b.Transactions.Count < shortChannelId.BlockIndex.Item)
            {
                _logger.LogError($"Tx not found in block {shortChannelId.BlockHeight.Item}. block index was{shortChannelId.BlockIndex.Item}. but actual tx number in block is {b.Transactions.Count}");
                error = ChainError.UnknownTx;
                return(false);
            }
            var tx = b.Transactions[(int)shortChannelId.BlockIndex.Item];

            if (tx.Outputs.Count < shortChannelId.TxOutIndex.Item)
            {
                _logger.LogError($"Tx not found in block {shortChannelId.BlockHeight.Item}. txout index was {shortChannelId.TxOutIndex.Item}. but actual tx number of txout is {tx.Outputs.Count}");
                error = ChainError.UnknownTx;
                return(false);
            }

            var txOut = tx.Outputs[shortChannelId.TxOutIndex.Item];

            script        = txOut.ScriptPubKey;
            amountSatoshi = (ulong)txOut.Value.Satoshi;
            return(true);
        }
Exemplo n.º 2
0
 public bool TryGetChainUtxoImpl(uint256 genesisBlockHash, ulong utxoId, ref ChainError error, out Script scriptPubKey,
                                 out Money amount)
 {
     error        = ChainError.NotWatched;
     scriptPubKey = null;
     amount       = null;
     return(false);
 }
Exemplo n.º 3
0
 bool IChainWatchInterface.TryGetChainUtxoImpl(uint256 genesisBlockHash, ulong utxoId, ref ChainError error, out Script scriptPubKey,
                                               out Money amount)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 4
0
 public ChainErrorException(ChainError error) : base(error.ToString())
 {
 }
Exemplo n.º 5
0
 public ChainErrorException(ChainError error, Exception innerException) : base(error.ToString(), innerException)
 {
 }