Skip to content

Commit

Permalink
revert changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dangershony committed Dec 21, 2024
1 parent 0930bdd commit 31bfa73
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 22 deletions.
22 changes: 3 additions & 19 deletions faucet-api/Controllers/FaucetController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ public FaucetController(IOptions<BitcoinSettings> bitcoinSettings, IIndexerServi
_indexerService = indexerService ?? throw new ArgumentNullException(nameof(indexerService), "IndexerService is not provided.");
}

[HttpGet("send/{address}/{address2}/{amount?}")]
public async Task<IActionResult> SendFunds(string address, string address2, long? amount)
{
return await SendFunds(new SendRequest { ToAddress = address, Amount = amount ?? 20, ToAddress2 = address2, Amount2 = amount ?? 20 });
}

[HttpGet("send/{address}/{amount?}")]
public async Task<IActionResult> SendFunds(string address, long? amount)
{
Expand All @@ -89,9 +83,6 @@ public async Task<IActionResult> SendFunds([FromBody] SendRequest request)
var toAddress = BitcoinAddress.Create(request.ToAddress, _network);
var amount = Money.Coins(request.Amount);

BitcoinAddress? toAddress2 = !string.IsNullOrEmpty(request.ToAddress2) ? BitcoinAddress.Create(request.ToAddress2, _network) : null;
Money amount2 = Money.Coins(request.Amount2 > 0 ? request.Amount2 : request.Amount);

var keyPath = new KeyPath($"m/84'/1'/0'/0/{_bitcoinSettings.ChangeAddressIndex}");
var privateKey = _masterKey.Derive(keyPath).PrivateKey;
var fromAddress = privateKey.PubKey.GetAddress(ScriptPubKeyType.Segwit, _network);
Expand All @@ -109,18 +100,13 @@ public async Task<IActionResult> SendFunds([FromBody] SendRequest request)
}).Take(2).ToList();

var txBuilder = _network.CreateTransactionBuilder();
var txbuilder = txBuilder
var tx = txBuilder
.AddCoins(coins)
.AddKeys(privateKey)
.Send(toAddress, amount)
.SetChange(fromAddress)
.SendFees(Money.Satoshis(_bitcoinSettings.FeeRate));


if (toAddress2 != null)
txbuilder.Send(toAddress2, amount2);

var tx = txbuilder.BuildTransaction(true);
.SendFees(Money.Satoshis(_bitcoinSettings.FeeRate))
.BuildTransaction(true);

if (!txBuilder.Verify(tx))
{
Expand Down Expand Up @@ -220,9 +206,7 @@ public async Task<IActionResult> CheckNetworkStatus()
public class SendRequest
{
public string ToAddress { get; set; }
public string ToAddress2 { get; set; }
public decimal Amount { get; set; }
public decimal Amount2 { get; set; }
}
}
}
2 changes: 1 addition & 1 deletion faucet-api/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>1.0.14</Version>
<Version>1.0.15</Version>
<Authors>Blockcore</Authors>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/block-core/bitcoin-custom-signet</PackageProjectUrl>
Expand Down
2 changes: 1 addition & 1 deletion faucet-api/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: '3.8'
services:
faucet-api:
container_name: faucet-api
image: blockcore/faucet-api:1.0.14
image: blockcore/faucet-api:1.0.15
mem_limit: 1024m
cpus: 0.200
environment:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "faucet-api",
"version": "1.0.14",
"version": "1.0.15",
"description": "Claim free Bitcoin instantly with your Testnet wallet address. Simple and secure!",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 31bfa73

Please sign in to comment.