-
Notifications
You must be signed in to change notification settings - Fork 7
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
Feature persistent store #22
Conversation
* upstream/master: Fix address screen layout constraint, close Sjors#13
NthKey/SupportingFiles/NthKey.xcdatamodeld/NthKey.xcdatamodel/contents
Outdated
Show resolved
Hide resolved
NthKey/SupportingFiles/NthKey.xcdatamodeld/NthKey.xcdatamodel/contents
Outdated
Show resolved
Hide resolved
NthKey/SupportingFiles/NthKey.xcdatamodeld/NthKey.xcdatamodel/contents
Outdated
Show resolved
Hide resolved
NthKey/SupportingFiles/NthKey.xcdatamodeld/NthKey.xcdatamodel/contents
Outdated
Show resolved
Hide resolved
NthKey/SupportingFiles/NthKey.xcdatamodeld/NthKey.xcdatamodel/contents
Outdated
Show resolved
Hide resolved
9e7264a
to
cc80b3f
Compare
Several tests are failing at the moment on Travis: https://travis-ci.com/github/Sjors/nthkey-ios/builds/220832007#L997 Please let me know when you think it's ready to test. |
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.
Would it make sense to move NthKey.xcdatamodeld
from SupportingFiles
to Model
?
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 order here is a bit confusing:
The Mainnet / Testnet toggle only applies to the creation of a new wallet. Let's handle wallet creation in a model window (both Announce and adding by QR / JSON). However, this can be done in a followup PR.
I created a fresh seed and a multisig wallet with Specter, on testnet. For some reason the addresses don't match between Specter and the simulator.
Yes, the addresses creation process didn't take into account all the cosigners keys, just fixed it in f303327. Note: Please remove the old wallet before your test. It can be performed by the long tap (UX isn't perfect for the moment). Because on addresses tab you can see addresses for the selected wallet, and if you just add new one (application didn't block you to add several copies of the same wallet for the moment) it will be hard to select right wallet. |
When scanning a QR code (or reading JSON) from Specter to import a wallet, you want to sanity check the network. Here's an example: {
"label": "NanoS with iPhone 12 simulator",
"blockheight": 0,
"descriptor": "wsh(sortedmulti(1,[048117aa\/48h\/1h\/0h\/2h]tpubDF5EvuWLmn6qak12tkKAi6wFHBBYFg22RxNycBHfMk43FeKgz5chhv1UANVuAmbF3PQopymtH54B1pKJomeMrH8cY9RUf6e51Dtt9vFxfsj\/0\/*,[ee081656\/48h\/1h\/0h\/2h]tpubDFFahYHoXpUZfqXEAP1KcuMCvJZ1s815LHFTtayUsg13GiZeJt9zvhx11bYRioSaxJ2FmjNaKN3Wjezbr5t3FxbD3yqJ5F22Gfds551iASQ\/0\/*))#99ajkvkr"
} Ideally Specter should add a field with the network type, but the alternative way is to look at the xpub / tpub in descriptor. If the user tries to import a wallet for the wrong network, just give an error. That should reduce complexity a bit in that last commit. |
Yes, it is a good idea to guide user throw the "Add wallet" flow (Show QR to specter and scan QR from it to complete). I'll create issue for it.
I'll follow you #22 (comment) |
I deleted and reimported the wallet, but the addresses are still not correct. In the above descriptor, the first address should be The device fingerprint is the same for all networks; that's just the BIP32 standard. |
Yes, the network recognition not working correctly at the moment, I'll fix it soon and let you know.
Okay, got it. |
NthKey/Model/SeedManager.swift
Outdated
@@ -53,13 +53,9 @@ struct SeedManager { | |||
precondition(false) | |||
} | |||
let seedHex = BIP39Mnemonic(entropy)!.seedHex() | |||
let masterKey = HDKey(seedHex, .testnet)! // FIXME: HDKey in this case shouldn't depend on network, because fingerprint is unique for the device |
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 HDKey object does depend on the network, but its fingerprint doesn't (please check). For the purpose of this function, using .mainnet
looks better.
https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#master-key-generation
The differentiation between mainnet and testnet happens at depth 2: e.g. m/84'/0'
(mainnet) vs m/84'/1'
(testnet), but this doesn't really matter in practice.
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.
NthKey/Model/DataManager.swift
Outdated
var receivedNetwork: Network? | ||
for key in desc.extendedKeys { | ||
var keyNetwork: Network? | ||
switch key.xpub.prefix(4) { |
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.
Instead of parsing the string like this, I think you can use the HDKey constructor in LibWally with the full string and see which network it returns?
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.
This initiliazer:
https://github.com/blockchain/libwally-swift/blob/master/LibWally/BIP32.swift#L157
And then HDKey class has a method which uses libwally-core internals to figure out the network: https://github.com/blockchain/libwally-swift/blob/master/LibWally/BIP32.swift#L213
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.
Alright, this seems to work! Can you tidy up the commits a bit, and maybe test it yourself with Specter? I'll then give it a final review and merge. I made some issues for (minor) improvements here: https://github.com/Sjors/nthkey-ios/milestone/1 |
Sure, I test all cases for the scope before each commit. I mean small scope as a small piece of the whole task.
It isn't ready yet.
|
This can wait. |
|
5cd9c8a
to
23fc709
Compare
signer.hdKey | ||
} | ||
let us = Signer.getOurselfSigner() | ||
|
||
self.isChange = output.isChange(signer: us.hdKey, inputs: inputs, cosigners: cosignerKeys, threshold: threshold) |
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.
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.
23fc709
to
c839a4d
Compare
add addresses mockups, fix address views to operate with CD entities
fix preview settings
prepare for handle scans
fix default wallet selection
add sign view model, add code signers view model, add data manager empty mock, remove cosigners / hasWallet / fingerprint / mainnet saved values from user defaults, add fingerprints foa all networks to user default saved values, limit psbt manager / Signer / Document picker filename to testnet fo a while, switch off "should have cosigners" precondition on sign view controller, rename WalletManager to SeedManager, remove unused code
fix wallet selection
…llet in user defaults
move threshold to co-signers section
refactoring SignView and it model to FSM, refactor SignViewController from UIHostingController to regular view controller, remove threshold from UserDefaults, remove Cosigners from Signer
c839a4d
to
907c8d5
Compare
This PR will resolve next issues: