Skip to content
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

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open

Conversation

OBorce
Copy link
Contributor

@OBorce OBorce commented Jun 18, 2024

  • 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

@OBorce OBorce force-pushed the refactor/wallet-generic-signer branch from e1f4596 to 37b71b9 Compare June 20, 2024 04:25
@OBorce OBorce force-pushed the refactor/wallet-generic-signer branch 6 times, most recently from 626b7d1 to fb2af0d Compare August 1, 2024 07:47
@OBorce OBorce marked this pull request as ready for review August 1, 2024 12:04
do_checks.sh Outdated Show resolved Hide resolved
@OBorce OBorce force-pushed the refactor/wallet-generic-signer branch from 726bb45 to 855cfce Compare August 6, 2024 10:54
build-tools/codecheck/codecheck.py Outdated Show resolved Hide resolved
crypto/src/key/secp256k1/extended_keys.rs Outdated Show resolved Hide resolved
crypto/src/key/extended.rs Outdated Show resolved Hide resolved
node-gui/src/backend/backend_impl.rs Show resolved Hide resolved
@@ -287,3 +287,6 @@ opt-level = 2
[profile.dist]
inherits = "release"
lto = "off"

[features]
trezor = []
Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment is still valid. We can't run tests on CI but we can at least build the code

wallet/src/signer/trezor_signer/mod.rs Outdated Show resolved Hide resolved
wallet/Cargo.toml Outdated Show resolved Hide resolved
wallet/wallet-cli-commands/src/helper_types.rs Outdated Show resolved Hide resolved
wallet/wallet-cli-commands/src/command_handler/mod.rs Outdated Show resolved Hide resolved
wallet/wallet-controller/src/lib.rs Outdated Show resolved Hide resolved
wallet/wallet-controller/src/lib.rs Outdated Show resolved Hide resolved
@OBorce OBorce force-pushed the refactor/wallet-generic-signer branch 2 times, most recently from 1cd8110 to c23f38d Compare August 13, 2024 23:23
wallet/src/signer/trezor_signer/mod.rs Outdated Show resolved Hide resolved
wallet/src/signer/trezor_signer/mod.rs Show resolved Hide resolved
wallet/src/signer/trezor_signer/mod.rs Outdated Show resolved Hide resolved
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(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. why mnemonic?
  2. 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

Copy link
Contributor Author

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

wallet/src/signer/trezor_signer/mod.rs Outdated Show resolved Hide resolved

/// 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"]))]
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should thenwhether_to_store_seed_phrase be marked with required_unless_present("hardware_wallet") or something like that? So people won't have to type it every time for hardware.

wallet/wallet-cli-commands/src/lib.rs Show resolved Hide resolved
wallet/wallet-controller/src/types/mod.rs Outdated Show resolved Hide resolved
wallet/wallet-cli-commands/src/lib.rs Show resolved Hide resolved
wallet/src/signer/trezor_signer/mod.rs Outdated Show resolved Hide resolved
@OBorce OBorce force-pushed the refactor/wallet-generic-signer branch from c23f38d to 4824da8 Compare August 30, 2024 16:09
@OBorce OBorce force-pushed the refactor/wallet-generic-signer branch 4 times, most recently from 6c3d058 to 037f258 Compare September 17, 2024 19:42
wallet/wallet-rpc-lib/src/rpc/types.rs Outdated Show resolved Hide resolved
wallet/wallet-rpc-lib/src/service/worker.rs Outdated Show resolved Hide resolved
wallet/types/src/wallet_type.rs Outdated Show resolved Hide resolved
wallet/wallet-cli-commands/src/command_handler/mod.rs Outdated Show resolved Hide resolved
wallet/src/signer/trezor_signer/tests.rs Outdated Show resolved Hide resolved
Destination::AnyoneCanSpend,
),
TxOutput::DataDeposit(vec![1, 2, 3]),
TxOutput::Htlc(OutputValue::Coin(burn_amount), Box::new(hash_lock)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there also should be a case for spending Htlc utxo with a secret

wallet/src/signer/trezor_signer/tests.rs Outdated Show resolved Hide resolved
wallet/src/signer/trezor_signer/tests.rs Show resolved Hide resolved
assert!(!devices.is_empty());
let client = devices.pop().unwrap().connect().unwrap();

let mut signer = TrezorSigner::new(chain_config.clone(), Arc::new(Mutex::new(client)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. There should be some negative cases: where trezor failed to sign inputs with unknown keys or something like that.
  2. How does device become aware of private keys? I see that at the beginning of the test a key chain is created from mnemonic, but how trezor is related to that I don't understand (like initialising it with test mnemonic of something)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I keep forgetting that this is manual test. So basically you have to recover a wallet from test mnemonic right?

@OBorce OBorce force-pushed the refactor/wallet-generic-signer branch from b459b54 to dc97e1b Compare October 31, 2024 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants