Skip to content

Commit

Permalink
WIP: addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
webwarrior-ws committed Jul 22, 2024
1 parent 8af58c9 commit db04387
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 31 deletions.
5 changes: 1 addition & 4 deletions src/GWallet.Backend/UtxoCoin/ImportedAccount.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ type ImportedAccount(mnemonic: string) =
let firstReceivingAddressKey = rootKey.Derive(0u).Derive(0u)
let firstReceivingAddressPubKey = firstReceivingAddressKey.GetPublicKey().ToHex()
let publicAddress = firstReceivingAddressKey.GetPublicKey().GetAddress(ScriptPubKeyType.Segwit, Network.Main).ToString()

do ignore firstReceivingAddressPubKey

interface IAccount with
member self.Currency = Currency.BTC
member self.PublicAddress = publicAddress
#if !LEGACY_FRAMEWORK

member self.GetTotalBalance() =
async {
let! maybeBalance =
Expand All @@ -32,4 +30,3 @@ type ImportedAccount(mnemonic: string) =
destinationAccount.PublicAddress
amount
firstReceivingAddressKey.PrivateKey
#endif
52 changes: 25 additions & 27 deletions src/GWallet.Frontend.Console/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ module Program =
()

let TransferFundsFromWalletUsingMenmonic() =
#if !LEGACY_FRAMEWORK
let rec askForMnemonic() : UtxoCoin.ImportedAccount =
Console.WriteLine "Enter mnemonic seed phrase (12, 15, 18, 21 or 24 words):"
let mnemonic = Console.ReadLine()
Expand All @@ -373,29 +372,32 @@ module Program =
printfn "Balance on imported account: %s BTC" (balance.ToString())

let rec chooseAccount() =
Console.WriteLine "Choose account to send funds to"
Console.WriteLine "Available accounts:"
let btcAccounts =
Account.GetAllActiveAccounts()
|> Seq.filter (fun acc -> acc.Currency = currency)
|> Seq.toList
Console.WriteLine "Choose account to send funds to:"
Console.WriteLine()
let allAccounts = Account.GetAllActiveAccounts() |> Seq.toList
let btcAccounts = allAccounts |> List.filter (fun acc -> acc.Currency = currency)

UserInteraction.DisplayAccountStatuses(WhichAccount.All btcAccounts)
|> Async.RunSynchronously
|> Seq.iter Console.WriteLine

Console.Write("Write the account number (or 0 to cancel): ")
let accountNumber = Console.ReadLine()
match Int32.TryParse(accountNumber) with
| false, _ -> chooseAccount()
| true, 0 -> None
| true, accountParsed ->
let theAccountChosen =
try
Some btcAccounts.[accountParsed - 1]
with
| _ -> chooseAccount()
theAccountChosen
match btcAccounts with
| [ singleAccount ] -> Some singleAccount
| [] -> failwith "No BTC accounts found"
| _ ->
for account in btcAccounts do
UserInteraction.DisplayAccountStatuses(WhichAccount.MatchingWith account)
|> Async.RunSynchronously
|> Seq.iter Console.WriteLine

Console.Write("Write the account number (or 0 to cancel): ")
let accountNumber = Console.ReadLine()
match Int32.TryParse(accountNumber) with
| false, _ -> chooseAccount()
| true, 0 -> None
| true, accountParsed ->
let theAccountChosen =
try
Some allAccounts.[accountParsed - 1]
with
| _ -> chooseAccount()
theAccountChosen

match chooseAccount() with
| Some targetAccount ->
Expand All @@ -409,10 +411,6 @@ module Program =
let uri = BlockExplorer.GetTransaction currency txId
printfn "Transaction successful:\n%s" (uri.ToString())
| None -> ()
#else
let x = UtxoCoin.ImportedAccount ""
ignore x
#endif

let WalletOptions(): unit =
let rec AskWalletOption(): GenericWalletOption =
Expand Down

0 comments on commit db04387

Please sign in to comment.