Skip to content

Commit

Permalink
WIP: trying to make CI green
Browse files Browse the repository at this point in the history
  • Loading branch information
webwarrior-ws committed Jul 17, 2024
1 parent 2a860f1 commit 8af58c9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
4 changes: 3 additions & 1 deletion src/GWallet.Backend/AccountTypes.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ namespace GWallet.Backend

open System.IO

type UtxoPublicKey = string

type WatchWalletInfo =
{
UtxoCoinPublicKey: string
UtxoCoinPublicKey: UtxoPublicKey
EtherPublicAddress: string
}

Expand Down
20 changes: 9 additions & 11 deletions src/GWallet.Backend/UtxoCoin/ImportedAccount.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,29 @@ open NBitcoin
type ImportedAccount(mnemonic: string) =
let rootKey = Mnemonic(mnemonic).DeriveExtKey().Derive(KeyPath("m/84'/0'/0'"))
let firstReceivingAddressKey = rootKey.Derive(0u).Derive(0u)
let firstReceivingAddressPubKey = firstReceivingAddressKey.GetPublicKey()
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 = firstReceivingAddressPubKey.GetAddress(ScriptPubKeyType.Segwit, Network.Main).ToString()

member private self.AsIUtxoAccount =
{ new IUtxoAccount with
member self.Currency = (self :> IAccount).Currency
member self.PublicAddress = (self :> IAccount).PublicAddress
member self.PublicKey = firstReceivingAddressPubKey }

member self.PublicAddress = publicAddress
#if !LEGACY_FRAMEWORK
member self.GetTotalBalance() =
async {
let! maybeBalance =
Account.GetShowableBalanceAndImminentIncomingPayment
self.AsIUtxoAccount
(Account.GetIUtxoAccount self firstReceivingAddressPubKey)
ServerSelectionMode.Fast
None
return maybeBalance |> Option.map (fun (balance, _) -> balance)
}

member self.SendFunds (destinationAccount: IAccount) (amount: TransferAmount) =
Account.SendPaymentFromImportedAccount
self.AsIUtxoAccount
(Account.GetIUtxoAccount self firstReceivingAddressPubKey)
destinationAccount.PublicAddress
amount
firstReceivingAddressKey.PrivateKey
#endif
6 changes: 6 additions & 0 deletions src/GWallet.Backend/UtxoCoin/UtxoCoinAccount.fs
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,12 @@ module Account =
let finalTransaction = SignTransaction account txMetadata destination amount password
BroadcastRawTransaction baseAccount.Currency finalTransaction ignoreHigherMinerFeeThanAmount

let internal GetIUtxoAccount (account: IAccount) (publicKey: UtxoPublicKey) =
{ new IUtxoAccount with
member self.Currency = account.Currency
member self.PublicAddress = account.PublicAddress
member self.PublicKey = PubKey(publicKey) }

let internal SendPaymentFromImportedAccount (account: IUtxoAccount)
(destination: string)
(amount: TransferAmount)
Expand Down
5 changes: 5 additions & 0 deletions src/GWallet.Frontend.Console/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ 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 Down Expand Up @@ -408,6 +409,10 @@ 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 8af58c9

Please sign in to comment.