-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor/wallet generic signer #1783
base: master
Are you sure you want to change the base?
Conversation
OBorce
commented
Jun 18, 2024
•
edited
Loading
edited
- add a generic signer provider for creating a software or a hardware signer
- make account key chain generic to allow using it with and without a VRF keychain
- add an implementation for the trezor signer
- copy auto generated trezor client to communicate with a connected trezor device
- add new hardware-wallet option when creating and opening a wallet in the CLI and RPC wallet commands
e1f4596
to
37b71b9
Compare
626b7d1
to
fb2af0d
Compare
726bb45
to
855cfce
Compare
@@ -287,3 +287,6 @@ opt-level = 2 | |||
[profile.dist] | |||
inherits = "release" | |||
lto = "off" | |||
|
|||
[features] | |||
trezor = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be enabled in CI
wallet/wallet-controller/src/lib.rs
Outdated
match &self.wallet { | ||
WalletType2::Software(w) => w.seed_phrase(), | ||
#[cfg(feature = "trezor")] | ||
WalletType2::Trezor(w) => w.seed_phrase(), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These match statements pollute the code; also, some of them are duplicated.
Perhaps it's better to encapsulate all of them inside impl WalletType2
?
P.S. Personally, I'd probably try to use https://github.com/kobzol/rust-delegate
for this. Not insisting on this, of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved inside the impl
1cd8110
to
c23f38d
Compare
SignatureStatus::FullySigned, | ||
SignatureStatus::FullySigned, | ||
)), | ||
InputWitness::Standard(sig) => match destination { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need a TODO and a github issue (so we won't forget) to support HTLC signing after my pr is merged
let db = Arc::new(Store::new(DefaultBackend::new_in_memory()).unwrap()); | ||
let mut db_tx = db.transaction_rw_unlocked(None).unwrap(); | ||
|
||
let master_key_chain = MasterKeyChain::new_from_mnemonic( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- why mnemonic?
- I don't fully understand how it's tested, this is run manually right? It looks like possible to run emulator with cli and automate this. Let's maybe discuss it because I'm afraid such functionality is not tested enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current test assumes the device will be initialized with the same mnemonic, but that can be fixed later as the tests can't run automatically now anyway.
To automate the tests I think we will need first to make the signing async, so that we can return from the wallet the status of the signing, i.e. when it is waiting for a button to be pressed on the trezor device
|
||
/// Create a wallet using a connected hardware wallet. Only the public keys will be kept in | ||
/// the software wallet | ||
#[arg(long, conflicts_with_all(["mnemonic", "passphrase"]))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it also conflicts with whether_to_store_seed_phrase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whether_to_store_seed_phrase was a required parameter I am not sure if we should break backwards compatibility or not, that is why I left it alone, and just check that it is set to false.
whether_to_store_seed_phrase: CliStoreSeedPhrase, | ||
|
||
/// Mnemonic phrase (12, 15, or 24 words as a single quoted argument). If not specified, a new mnemonic phrase is generated and printed. | ||
mnemonic: Option<String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should it be just String? btw we can remove mnemonic from CreateWallet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is optional because of the hardware wallet option.
c23f38d
to
4824da8
Compare
f787225
to
a35f2c3
Compare
- it will rescan the blokchain on wallet creation - wallet-create will only scan forward from the current block height
2157893
to
2014928
Compare
6c3d058
to
037f258
Compare