diff --git a/src/Data/DbInitializer.cs b/src/Data/DbInitializer.cs index d6a86482..6d74f82d 100644 --- a/src/Data/DbInitializer.cs +++ b/src/Data/DbInitializer.cs @@ -214,7 +214,7 @@ public static void Initialize(IServiceProvider serviceProvider) { ChannelAdminMacaroon = "0201036c6e6402f801030a108cdfeb2614b8335c11aebb358f888d6d1201301a160a0761646472657373120472656164120577726974651a130a04696e666f120472656164120577726974651a170a08696e766f69636573120472656164120577726974651a210a086d616361726f6f6e120867656e6572617465120472656164120577726974651a160a076d657373616765120472656164120577726974651a170a086f6666636861696e120472656164120577726974651a160a076f6e636861696e120472656164120577726974651a140a057065657273120472656164120577726974651a180a067369676e6572120867656e657261746512047265616400000620c999e1a30842cbae3f79bd633b19d5ec0d2b6ebdc4880f6f5d5c230ce38f26ab", - Endpoint = Constants.ALICE_HOST, + Endpoint = Constants.ALICE_HOST, Name = "Alice", CreationDatetime = DateTimeOffset.UtcNow, PubKey = "02dc2ae598a02fc1e9709a23b68cd51d7fa14b1132295a4d75aa4f5acd23ee9527", @@ -240,7 +240,7 @@ public static void Initialize(IServiceProvider serviceProvider) }; _ = Task.Run(() => nodeRepository.AddAsync(carol)).Result; - + //Bob node from Polar (BOB) LND 0.15.5 -> check devnetwork.zip polar file var bob = new Node { @@ -253,7 +253,7 @@ public static void Initialize(IServiceProvider serviceProvider) Users = new List(), AutosweepEnabled = false }; - + _ = Task.Run(() => nodeRepository.AddAsync(bob)).Result; //Add user to the channel @@ -262,13 +262,13 @@ public static void Initialize(IServiceProvider serviceProvider) var carolUpdateResult = applicationDbContext.Update(adminUser); } - + var internalWallet = applicationDbContext.InternalWallets.FirstOrDefault(); if (internalWallet == null) { //Default Internal Wallet internalWallet = CreateWallet.CreateInternalWallet(logger); - + applicationDbContext.Add(internalWallet); applicationDbContext.SaveChanges(); } @@ -280,14 +280,14 @@ public static void Initialize(IServiceProvider serviceProvider) "social mango annual basic work brain economy one safe physical junk other toy valid load cook napkin maple runway island oil fan legend stem"; var wallet2Seed = "solar goat auto bachelor chronic input twin depth fork scale divorce fury mushroom column image sauce car public artist announce treat spend jacket physical"; - + logger?.LogInformation("Wallet 1 seed: {MnemonicString}", wallet1Seed); logger?.LogInformation("Wallet 2 seed: {MnemonicString}", wallet2Seed); - + var user1Key = CreateWallet.CreateUserKey("Key 1", adminUser.Id, wallet1Seed); var user2Key = CreateWallet.CreateUserKey("Key 2", financeUser.Id, wallet2Seed); - - var testingLegacyMultisigWallet = CreateWallet.LegacyMultiSig(internalWallet, "1'", user1Key, user2Key); + + var testingLegacyMultisigWallet = CreateWallet.LegacyMultiSig(internalWallet, "1'", user1Key, user2Key); var testingMultisigWallet = CreateWallet.MultiSig(internalWallet, "0", user1Key, user2Key); var testingSinglesigWallet = CreateWallet.SingleSig(internalWallet, "1"); var testingSingleSigBIP39Wallet = CreateWallet.BIP39Singlesig(); @@ -329,6 +329,16 @@ public static void Initialize(IServiceProvider serviceProvider) minerRPC.SendToAddress(singlesigAddress, singlesigFundCoins); minerRPC.SendToAddress(singleSigBIP39Address, singleSigBIP39FundCoins); + // Create a lot of utxos and send them to the single sig wallet + // Random r = new Random(); + // for (var i = 0; i < 1000; i++) + // { + // var keypath = nbxplorerClient.GetUnused(singlesigDerivationStrategy, DerivationFeature.Deposit); + // decimal coin = r.Next(536, 10000000); + // var randomCoint = Money.Coins(coin / 100000000); //20BTC + // minerRPC.SendToAddress(keypath.Address, randomCoint); + // } + //6 blocks to confirm minerRPC.Generate(6); @@ -368,7 +378,7 @@ public static void Initialize(IServiceProvider serviceProvider) applicationDbContext.Add(testingSingleSigBIP39Wallet); } } - + applicationDbContext.SaveChanges(); } diff --git a/src/Helpers/Constants.cs b/src/Helpers/Constants.cs index a137c02b..6bfb77e5 100644 --- a/src/Helpers/Constants.cs +++ b/src/Helpers/Constants.cs @@ -27,6 +27,7 @@ public class Constants public static readonly bool ENABLE_REMOTE_SIGNER; public static readonly bool PUSH_NOTIFICATIONS_ONESIGNAL_ENABLED; public static readonly bool ENABLE_HW_SUPPORT; + public static readonly bool NBXPLORER_ENABLE_CUSTOM_BACKEND = false; // Connections public static readonly string POSTGRES_CONNECTIONSTRING = "Host=localhost;Port=5432;Database=fundsmanager;Username=rw_dev;Password=rw_dev"; @@ -102,6 +103,8 @@ static Constants() ENABLE_HW_SUPPORT = Environment.GetEnvironmentVariable("ENABLE_HW_SUPPORT") != "false"; // We default to true + NBXPLORER_ENABLE_CUSTOM_BACKEND = Environment.GetEnvironmentVariable("NBXPLORER_ENABLE_CUSTOM_BACKEND") == "true"; + // Connections POSTGRES_CONNECTIONSTRING = Environment.GetEnvironmentVariable("POSTGRES_CONNECTIONSTRING") ?? POSTGRES_CONNECTIONSTRING; diff --git a/src/Helpers/ValidationHelper.cs b/src/Helpers/ValidationHelper.cs index 8315462f..b4a19928 100644 --- a/src/Helpers/ValidationHelper.cs +++ b/src/Helpers/ValidationHelper.cs @@ -64,14 +64,16 @@ public static void ValidateUsername(ValidatorEventArgs obj, List Constants.MAXIMUM_CHANNEL_CAPACITY_SATS_REGTEST && network == Network.RegTest) + else if ((decimal)obj.Value > maxChannelRegtestValue && network == Network.RegTest) { - obj.ErrorText = "The amount selected must be lower than 16.777.215"; + obj.ErrorText = $"The amount selected must be lower than {maxChannelRegtestValue:f8} BTC"; obj.Status = ValidationStatus.Error; } } diff --git a/src/Pages/ChannelRequests.razor b/src/Pages/ChannelRequests.razor index dd1627ef..18b11cc5 100644 --- a/src/Pages/ChannelRequests.razor +++ b/src/Pages/ChannelRequests.razor @@ -131,15 +131,15 @@ - + - @{ - @($"Amount in Satoshis. Minimum 20.000. Current amount: {Math.Round(PriceConversionHelper.SatToUsdConversion(_amount, _btcPrice), 2)} USD") - } + + @($"Amount in Satoshis. Minimum {_minimumChannelCapacity:f8}. Current amount: {Math.Round(PriceConversionHelper.SatToUsdConversion(new Money(_amount, MoneyUnit.BTC).Satoshi, _btcPrice), 2)} USD") +
@@ -423,7 +423,8 @@ private Node? _selectedDestNode; private int? _selectedWalletId; private string? _destNodeName; - private long _amount = Constants.MINIMUM_CHANNEL_CAPACITY_SATS; + private static readonly decimal _minimumChannelCapacity = new Money(Constants.MINIMUM_CHANNEL_CAPACITY_SATS).ToUnit(MoneyUnit.BTC); + private decimal _amount { get; set; } = _minimumChannelCapacity; private bool _selectedPrivate = false; //Validation @@ -475,7 +476,8 @@ _destNodeName = ""; _selectedDestNode = null; _selectedPrivate = false; - _amount = Constants.MINIMUM_CHANNEL_CAPACITY_SATS; + _selectedWalletId = null; + _amount = _minimumChannelCapacity; } private async Task ResetChannelCancelModal() @@ -578,7 +580,7 @@ var amount = SelectedUTXOs.Count > 0 ? SelectedUTXOsValue() : _amount; var request = new ChannelOperationRequest() { - SatsAmount = amount, + SatsAmount = new Money(amount, MoneyUnit.BTC).Satoshi, RequestType = OperationRequestType.Open, Description = "Created by user via Funds Manager", WalletId = _selectedWalletId, @@ -913,9 +915,9 @@ StateHasChanged(); } - private long SelectedUTXOsValue() + private decimal SelectedUTXOsValue() { - return SelectedUTXOs.Sum(x => ((Money)x.Value).Satoshi); + return SelectedUTXOs.Sum(x => ((Money)x.Value).ToUnit(MoneyUnit.BTC)); } private void ClearSelectedUTXOs() diff --git a/src/Pages/_Layout.cshtml b/src/Pages/_Layout.cshtml index a2517a4e..e61a3a0e 100644 --- a/src/Pages/_Layout.cshtml +++ b/src/Pages/_Layout.cshtml @@ -22,7 +22,7 @@