Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions faucet-api/Models/BitcoinSettings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

public class BitcoinSettings
{
public string Indexer { get; set; }
public string IndexerUrl { get; set; }
public string Mnemonic { get; set; }
public string Network { get; set; }
Expand Down
93 changes: 93 additions & 0 deletions faucet-api/Models/MempoolModels.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
public class AddressStats
{
public int FundedTxoCount { get; set; }
public long FundedTxoSum { get; set; }
public int SpentTxoCount { get; set; }
public long SpentTxoSum { get; set; }
public int TxCount { get; set; }
}
public class AddressResponse
{
public string Address { get; set; }
public AddressStats ChainStats { get; set; }
public AddressStats MempoolStats { get; set; }
}

public class OutspentResponse
{
public bool Spent { get; set; }
public string Txid { get; set; }
public int Vin { get; set; }
public UtxoStatus Status { get; set; }

}

public class AddressUtxo
{
public string Txid { get; set; }
public int Vout { get; set; }
public UtxoStatus Status { get; set; }
public long Value { get; set; }
}

public class UtxoStatus
{
public bool Confirmed { get; set; }
public int BlockHeight { get; set; }
public string BlockHash { get; set; }
public long BlockTime { get; set; }
}

public class RecommendedFees
{
public int FastestFee { get; set; }
public int HalfHourFee { get; set; }
public int HourFee { get; set; }
public int EconomyFee { get; set; }
public int MinimumFee { get; set; }
}

public class Vin
{
public bool IsCoinbase { get; set; }
public PrevOut Prevout { get; set; }
public string Scriptsig { get; set; }
public string Asm { get; set; }
public long Sequence { get; set; }
public string Txid { get; set; }
public int Vout { get; set; }
public List<string> Witness { get; set; }
public string InnserRedeemscriptAsm { get; set; }
public string InnerWitnessscriptAsm { get; set; }
}
public class PrevOut
{
public long Value { get; set; }
public string Scriptpubkey { get; set; }
public string ScriptpubkeyAddress { get; set; }
public string ScriptpubkeyAsm { get; set; }
public string ScriptpubkeyType { get; set; }
}

public class MempoolTransaction
{
public string Txid { get; set; }

public int Version { get; set; }

public int Locktime { get; set; }
public int Size { get; set; }
public int Weight { get; set; }
public int Fee { get; set; }
public List<Vin> Vin { get; set; }
public List<PrevOut> Vout { get; set; }
public UtxoStatus Status { get; set; }
}

public class Outspent
{
public bool Spent { get; set; }
public string Txid { get; set; }
public int Vin { get; set; }
public UtxoStatus Status { get; set; }
}
31 changes: 24 additions & 7 deletions faucet-api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,32 @@

builder.Services.AddControllers();

builder.Services.AddHttpClient<IIndexerService, IndexerService>(client =>
var bitcoinSettings = new BitcoinSettings();
builder.Configuration.GetSection("Bitcoin").Bind(bitcoinSettings);
if (bitcoinSettings.Indexer == "Mempool")
{
var indexerUrl = builder.Configuration.GetSection("Bitcoin")["IndexerUrl"];
if (string.IsNullOrEmpty(indexerUrl))
builder.Services.AddHttpClient<IIndexerService, MempoolService>(client =>
{
throw new ArgumentException("IndexerUrl is not configured in appsettings.json.");
}
client.BaseAddress = new Uri(indexerUrl);
});
var indexerUrl = builder.Configuration.GetSection("Bitcoin")["IndexerUrl"];
if (string.IsNullOrEmpty(indexerUrl))
{
throw new ArgumentException("IndexerUrl is not configured in appsettings.json.");
}
client.BaseAddress = new Uri(indexerUrl);
});
}
else
{
builder.Services.AddHttpClient<IIndexerService, IndexerService>(client =>
{
var indexerUrl = builder.Configuration.GetSection("Bitcoin")["IndexerUrl"];
if (string.IsNullOrEmpty(indexerUrl))
{
throw new ArgumentException("IndexerUrl is not configured in appsettings.json.");
}
client.BaseAddress = new Uri(indexerUrl);
});
}

builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(options =>
Expand Down
Loading