From 600cccf1158e994104a849169c5c760df50cc87a Mon Sep 17 00:00:00 2001 From: webwarrior Date: Tue, 16 Jul 2024 12:41:02 +0200 Subject: [PATCH] Backend,scripts: remove nested segwit code Remove NATIVE_SEGWIT compile-time constant and all code that was disabled when NATIVE_SEGWIT was defined. Also remove readonly accounts migration to native segwit. --- scripts/configure.fsx | 7 +--- src/GWallet.Backend/Account.fs | 13 +------- src/GWallet.Backend/Config.fs | 4 --- .../UtxoCoin/UtxoCoinAccount.fs | 32 ------------------- 4 files changed, 2 insertions(+), 54 deletions(-) diff --git a/scripts/configure.fsx b/scripts/configure.fsx index 1de5d5ae4..8559b56e6 100644 --- a/scripts/configure.fsx +++ b/scripts/configure.fsx @@ -211,16 +211,11 @@ let configFileToBeWritten = | Some theTool -> initialConfigFile.Add("LegacyBuildTool", theTool) | None -> initialConfigFile - let configFileStageThree = + let finalConfigFile = match buildTool with | Some theTool -> configFileStageTwo.Add("BuildTool", theTool) | None -> configFileStageTwo - let finalConfigFile = - // native segwit is enabled by default - configFileStageThree - |> AddToDefinedConstants "NATIVE_SEGWIT" - finalConfigFile let lines = diff --git a/src/GWallet.Backend/Account.fs b/src/GWallet.Backend/Account.fs index 6f39dc7d4..9fad24398 100644 --- a/src/GWallet.Backend/Account.fs +++ b/src/GWallet.Backend/Account.fs @@ -17,19 +17,8 @@ type UnhandledCurrencyServerException(currency: Currency, module Account = - let private isInitialized (accounts: seq) = lazy( + let private isInitialized (_accounts: seq) = lazy( Config.Init() - -#if !NATIVE_SEGWIT - let _readonlyUtxoAccounts = -#else - let readonlyUtxoAccounts = -#endif - accounts.Where(fun acc -> acc.Currency.IsUtxo()).OfType() -#if NATIVE_SEGWIT - UtxoCoin.Account.MigrateReadOnlyAccountsToNativeSegWit readonlyUtxoAccounts -#endif - () ) let private GetShowableBalanceAndImminentPaymentInternal (account: IAccount) diff --git a/src/GWallet.Backend/Config.fs b/src/GWallet.Backend/Config.fs index 9ccbf1ccf..a0acf9d70 100644 --- a/src/GWallet.Backend/Config.fs +++ b/src/GWallet.Backend/Config.fs @@ -38,11 +38,7 @@ module Config = let internal NoNetworkBalanceForDebuggingPurposes = false let internal UseNativeSegwit = -#if NATIVE_SEGWIT true -#else - false -#endif let IsWindowsPlatform() = RuntimeInformation.IsOSPlatform OSPlatform.Windows diff --git a/src/GWallet.Backend/UtxoCoin/UtxoCoinAccount.fs b/src/GWallet.Backend/UtxoCoin/UtxoCoinAccount.fs index 6adb43f4c..ccaba5d12 100644 --- a/src/GWallet.Backend/UtxoCoin/UtxoCoinAccount.fs +++ b/src/GWallet.Backend/UtxoCoin/UtxoCoinAccount.fs @@ -700,38 +700,6 @@ module Account = Config.AddAccount conceptAccountForReadOnlyAccount AccountKind.ReadOnly |> ignore -#if NATIVE_SEGWIT - let internal MigrateReadOnlyAccountsToNativeSegWit (readOnlyUtxoAccounts: seq): unit = - let utxoAccountsToMigrate = - seq { - for utxoAccount in readOnlyUtxoAccounts do - let accountFile = utxoAccount.AccountFile - let prefix = - match (utxoAccount :> IAccount).Currency with - | Currency.BTC -> - BITCOIN_ADDRESS_BECH32_PREFIX - | Currency.LTC -> - LITECOIN_ADDRESS_BECH32_PREFIX - | otherCurrency -> failwith <| SPrintF1 "Missed UTXO currency %A when implementing NativeSegwit migration?" otherCurrency - if not (accountFile.Name.StartsWith prefix) then - yield utxoAccount - } - - let utxoPublicKeys = - seq { - for utxoReadOnlyAccount in utxoAccountsToMigrate do - let accountFile = utxoReadOnlyAccount.AccountFile - let utxoPublicKey = accountFile.Content() - yield utxoPublicKey - } |> Set.ofSeq - - for utxoPublicKey in utxoPublicKeys do - CreateReadOnlyAccounts utxoPublicKey - - for utxoReadOnlyAccount in utxoAccountsToMigrate do - Config.RemoveReadOnlyAccount utxoReadOnlyAccount -#endif - let GetSignedTransactionDetails<'T when 'T :> IBlockchainFeeInfo>(rawTransaction: string) (currency: Currency) (readonlyUtxoAccounts: seq)