Skip to content

Commit

Permalink
Backend,scripts: remove nested segwit code
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
webwarrior-ws committed Jul 24, 2024
1 parent bc88cdc commit 600cccf
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 54 deletions.
7 changes: 1 addition & 6 deletions scripts/configure.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
13 changes: 1 addition & 12 deletions src/GWallet.Backend/Account.fs
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,8 @@ type UnhandledCurrencyServerException(currency: Currency,

module Account =

let private isInitialized (accounts: seq<IAccount>) = lazy(
let private isInitialized (_accounts: seq<IAccount>) = lazy(
Config.Init()

#if !NATIVE_SEGWIT
let _readonlyUtxoAccounts =
#else
let readonlyUtxoAccounts =
#endif
accounts.Where(fun acc -> acc.Currency.IsUtxo()).OfType<ReadOnlyAccount>()
#if NATIVE_SEGWIT
UtxoCoin.Account.MigrateReadOnlyAccountsToNativeSegWit readonlyUtxoAccounts
#endif
()
)

let private GetShowableBalanceAndImminentPaymentInternal (account: IAccount)
Expand Down
4 changes: 0 additions & 4 deletions src/GWallet.Backend/Config.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 0 additions & 32 deletions src/GWallet.Backend/UtxoCoin/UtxoCoinAccount.fs
Original file line number Diff line number Diff line change
Expand Up @@ -700,38 +700,6 @@ module Account =
Config.AddAccount conceptAccountForReadOnlyAccount AccountKind.ReadOnly
|> ignore<FileRepresentation>

#if NATIVE_SEGWIT
let internal MigrateReadOnlyAccountsToNativeSegWit (readOnlyUtxoAccounts: seq<ReadOnlyAccount>): 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<ReadOnlyUtxoAccount>)
Expand Down

0 comments on commit 600cccf

Please sign in to comment.