geewallet icon indicating copy to clipboard operation
geewallet copied to clipboard

BIP-39 import

Open webwarrior-ws opened this issue 1 year ago • 10 comments

Implement the import in the backend using NBitcoin (BIP84 derivation path), with option to sweep the funds to a bitcoin account of geewallet with a transaction.

webwarrior-ws avatar Jul 22 '24 10:07 webwarrior-ws

Still receiving this exception when testing:

Write the account number (or 0 to cancel): 1
System.Exception: Currency BTC not ether based and not UTXO either? not supported, report this bug (estimatefee)
   at [email protected](Unit unitVar) in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Backend/Account.fs:line 221
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 510
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 112
--- End of stack trace from previous location ---
   at Microsoft.FSharp.Control.AsyncResult`1.Commit() in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 454
   at Microsoft.FSharp.Control.AsyncPrimitives.QueueAsyncAndWaitForResultSynchronously[a](CancellationToken token, FSharpAsync`1 computation, FSharpOption`1 timeout) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1139
   at Microsoft.FSharp.Control.AsyncPrimitives.RunSynchronously[T](CancellationToken cancellationToken, FSharpAsync`1 computation, FSharpOption`1 timeout) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1166
   at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T](FSharpAsync`1 computation, FSharpOption`1 timeout, FSharpOption`1 cancellationToken) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1515
   at GWallet.Frontend.Console.UserInteraction.AskFee(IAccount account, TransferAmount amount, String destination) in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/UserInteraction.fs:line 608
   at GWallet.Frontend.Console.Program.TransferFundsFromWalletUsingMenmonic() in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/Program.fs:line 408
   at GWallet.Frontend.Console.Program.WalletOptions() in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/Program.fs:line 448
   at GWallet.Frontend.Console.Program.PerformOperation(UInt32 numActiveAccounts, UInt32 numHotAccounts) in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/Program.fs:line 487
   at GWallet.Frontend.Console.Program.ProgramMainLoop[a]() in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/Program.fs:line 564
   at GWallet.Frontend.Console.Program.NormalStartWithNoParameters() in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/Program.fs:line 576

knocte avatar Jul 22 '24 11:07 knocte

Another crash:

System.Exception: account 33deiowdoijdeiwjoiddeiowjodijew(BTC) not found in config, or more than one with same public address?
   at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail@1448.Invoke(String message)
   at GWallet.Frontend.Console.UserInteraction.DisplayAccountStatuses@386-14.Invoke(Currency arg20)
   at GWallet.Frontend.Console.UserInteraction.DisplayAccountStatuses@380-12.Invoke(Unit unitVar) in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/UserInteraction.fs:line 386
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 510
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 112
--- End of stack trace from previous location ---
   at Microsoft.FSharp.Control.AsyncResult`1.Commit() in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 454
   at Microsoft.FSharp.Control.AsyncPrimitives.QueueAsyncAndWaitForResultSynchronously[a](CancellationToken token, FSharpAsync`1 computation, FSharpOption`1 timeout) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1139
   at Microsoft.FSharp.Control.AsyncPrimitives.RunSynchronously[T](CancellationToken cancellationToken, FSharpAsync`1 computation, FSharpOption`1 timeout) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1166
   at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T](FSharpAsync`1 computation, FSharpOption`1 timeout, FSharpOption`1 cancellationToken) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1515
   at [email protected](Unit unitVar0) in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/Program.fs:line 386
   at GWallet.Frontend.Console.Program.TransferFundsFromWalletUsingMenmonic() in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/Program.fs:line 406
   at GWallet.Frontend.Console.Program.WalletOptions() in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/Program.fs:line 450
   at GWallet.Frontend.Console.Program.PerformOperation(UInt32 numActiveAccounts, UInt32 numHotAccounts) in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/Program.fs:line 489
   at GWallet.Frontend.Console.Program.ProgramMainLoop[a]() in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/Program.fs:line 566
   at GWallet.Frontend.Console.Program.NormalStartWithNoParameters() in /Users/knocte/Documents/Code/geewalletMASTERclean/src/GWallet.Frontend.Console/Program.fs:line 578

Please take in account the above address of mine corresponds to a READONLY account of mine.

knocte avatar Jul 22 '24 12:07 knocte

@knocte So we can't reuse DisplayAccountStatuses function. Easiest fix would be to make GetAccountBalance internal instead of private and use it together with DisplayAccountStatus to display account.

webwarrior-ws avatar Jul 22 '24 12:07 webwarrior-ws

Or maybe list only normal (not readonly) accounts?

webwarrior-ws avatar Jul 22 '24 12:07 webwarrior-ws

Easiest fix would be to make GetAccountBalance internal instead of private and use it together with DisplayAccountStatus to display account.

Sounds good

knocte avatar Jul 22 '24 13:07 knocte

After sending the transaction, please add an invokation to the function that prints "Press any key to continue..." (like we do when we send normal transactions).

knocte avatar Jul 22 '24 14:07 knocte

One last thing to do here: after sending the transaction to recover the funds, convert the ImportedAccount to an ArchivedAccount and save it to disk. This way, geewallet will warn the user if more funds arrive to it in the future.

knocte avatar Jul 23 '24 03:07 knocte

This PR has 5 commits. The first one has CI red, so I think the most logical thing to do is squash the 1st one with the 2nd, to avoid that red CI status, and because those two commits are basically working on the same thing. Later, I would also squash commits 3 and 4. So, in the end, this PR can have 3 commits only.

knocte avatar Jul 24 '24 06:07 knocte

@webwarrior-ws nit: before showing the possible accounts where to send the funds to, please add a Console.WriteLine invokation that informs the user about the address where the funds are.

knocte avatar Jul 26 '24 13:07 knocte

@webwarrior-ws nit: before showing the possible accounts where to send the funds to, please add a Console.WriteLine invokation that informs the user about the address where the funds are.

@knocte done

webwarrior-ws avatar Jul 29 '24 08:07 webwarrior-ws