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

1.3.4 - Daedalus Master Key restore #350

Merged
merged 77 commits into from
Mar 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
dcec33a
spec of trezor(moved from wiki) and ledger integration
Jan 28, 2019
55afaee
typo fix and spec finalization
Feb 24, 2019
3f68c6f
text fix
Feb 24, 2019
6279fe8
deleted trezor docs
Mar 7, 2019
b0f2c28
changed confirm button to remove last button
ASUKA1006 Mar 7, 2019
ee3e80c
add translations
ASUKA1006 Mar 7, 2019
5867ec3
fix a bug
ASUKA1006 Mar 10, 2019
3d2dbb0
creation of HW Interface for HW integrations
nicarq Feb 16, 2019
72ab9ad
compiles
nicarq Feb 17, 2019
e7ebc03
fix build
SebastienGllmt Feb 18, 2019
05d1028
fix running issues
nicarq Feb 18, 2019
0448489
ledger create wallet API
Feb 18, 2019
76fa47b
ledger api
Feb 19, 2019
2261292
flow fix
Feb 19, 2019
2b171d3
view setup
Feb 19, 2019
fbc76eb
updated CSP for yoroi-ledger-bridge
Feb 20, 2019
93ed3b3
review changes
Feb 20, 2019
580cf1c
try 1 yoroi-ledger bridge connect
Feb 20, 2019
9d91153
review fix
Feb 20, 2019
a09b9fa
fix bridge URL
SebastienGllmt Feb 20, 2019
d5ae4ed
await to give it time to load stuff
nicarq Feb 20, 2019
0a68df4
ledger connect initial impl
Feb 22, 2019
c5b1d9f
changes to sync with new yoroi ledger bridge
Feb 25, 2019
9f4212c
update package-lock for yoroi ledger bridge update
Feb 26, 2019
2256ee6
TrezorConnectStore implements HWConnectStoreTypes
Feb 26, 2019
37d6e05
fix HWConnectStoreTypes
Feb 27, 2019
7a34823
ledger connet UI text fix
Feb 27, 2019
404726d
topbar yoroi with ledger impl without actual ledger icon
Feb 27, 2019
ee741f5
ledger UI text fix, signTx partial impl
Feb 27, 2019
992881a
ledger SignTx fix try 1
Feb 28, 2019
95fc34b
ledger SignTx fix try 2 plus assets update
Mar 1, 2019
9d33058
fix address generation bug
nicarq Mar 2, 2019
b0a9630
some more code for signing tx
nicarq Mar 2, 2019
d30b8b9
adds code to reuse ledger iframe
nicarq Mar 3, 2019
3b9a4ae
hw assets fix
Mar 4, 2019
6f971e8
ledger bridge iframe init wait fix
Mar 4, 2019
fa9c79a
fix ledger broadcasting
SebastienGllmt Mar 4, 2019
9d41a98
fix missing variable
nicarq Mar 4, 2019
475debb
npm install fix
Mar 5, 2019
cb4f4bf
ledger bridge review fix
Mar 5, 2019
12eaa26
flow fix
Mar 5, 2019
b4cbae3
eslint fix
Mar 5, 2019
7d9d53e
fix ledger bridge init problem
Mar 5, 2019
b237180
fix broadcast again
SebastienGllmt Mar 5, 2019
e96cbb3
fix ledger tx
nicarq Mar 5, 2019
67d9266
dispose ledger bridge when not needed
Mar 6, 2019
3dc9378
fix ledger topbar icon
Mar 6, 2019
5dd669e
fixed some UI text
Mar 6, 2019
f308c2f
hw connect converted to shareable components
Mar 6, 2019
75b0d05
added @cardano-foundation/ledgerjs-hw-app-cardano module
Mar 6, 2019
c243ed9
potential fix circleci
nicarq Mar 8, 2019
b32163f
ledger UI text reuse from trezor text
Mar 8, 2019
6532e72
ledger connect and send error text fix
Mar 11, 2019
3ae627f
manage-translations applied
Mar 11, 2019
171f869
defaultMessage/description fix
Mar 11, 2019
61facd0
some TODOs fix
Mar 11, 2019
9aebd0e
Fixed handling of tx-bodies received from backend
vsubhuman Mar 11, 2019
b77cd8b
Fixed return type!
vsubhuman Mar 11, 2019
2bb0fa4
some fixes and resolved TODOs
nicarq Mar 11, 2019
4a89005
fix a couple of comments
nicarq Mar 11, 2019
fdf780f
temp hide ledger help link plus remove Cardano App link
Mar 12, 2019
6c17fe0
rebase fix
Mar 12, 2019
7da20cb
bump cardano version
nicarq Mar 13, 2019
139e5ff
update with buy ledger icon
nicarq Mar 13, 2019
4bf61fc
us translation
nicarq Mar 13, 2019
0919ac7
ledger spec Iteration-1 final
Mar 13, 2019
8b2579d
review fix 1
Mar 13, 2019
ca63ba6
Merge pull request #281 from Emurgo/docs/hardware-wallet
SebastienGllmt Mar 13, 2019
c45c32c
Merge pull request #298 from Emurgo/feature/ledger-integration
SebastienGllmt Mar 13, 2019
9729958
Merge branch 'develop' into feature/remove-word-button
SebastienGllmt Mar 13, 2019
3fc56bf
add daedalus import from master key
SebastienGllmt Mar 9, 2019
11588b2
Merge pull request #342 from Emurgo/feature/fromDaedalusKey
vsubhuman Mar 13, 2019
59f10a3
Merge pull request #336 from ASUKA1006/feature/remove-word-button
vsubhuman Mar 13, 2019
9fc2e14
Edit to wallet.send.ledger.confirmationDialog.info.line.2
Leo-Emurgo Mar 14, 2019
72d0dd9
Merge pull request #347 from Leo-Emurgo/patch-2
Mar 14, 2019
5439a88
hide ledger button
nicarq Mar 16, 2019
eedc58f
Merge pull request #349 from Emurgo/fix/hide-ledger-until-available
nicarq Mar 16, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/actions/ada/daedalus-transfer-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import Action from '../lib/Action';
export default class DaedalusTranferActions {
startTransferFunds: Action<any> = new Action();
startTransferPaperFunds: Action<any> = new Action();
setupTransferFunds: Action<any> = new Action();
startTransferMasterKey: Action<any> = new Action();
setupTransferFundsWithMnemonic: Action<any> = new Action();
setupTransferFundsWithMasterKey: Action<any> = new Action();
backToUninitialized: Action<any> = new Action();
transferFunds: Action<any> = new Action();
cancelTransferFunds: Action<any> = new Action();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// @flow
import Action from '../lib/Action';

// ======= TREZOR CONNECT ACTIONS =======
// ======= HARDWARE WALLET CONNECT ACTIONS =======

export default class TrezorConnectActions {
export default class HWConnectActions {
init: Action<void> = new Action();
cancel: Action<void> = new Action();
submitAbout: Action<void> = new Action();
goBacktToAbout: Action<void> = new Action();
goBackToAbout: Action<void> = new Action();
submitConnect: Action<void> = new Action();
submitSave: Action<string> = new Action();
}
11 changes: 8 additions & 3 deletions app/actions/ada/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import TransactionsActions from './transactions-actions';
import WalletSettingsActions from './wallet-settings-actions';
import AddressesActions from './addresses-actions';
import DaedalusTransferActions from './daedalus-transfer-actions';
import TrezorConnectActions from './trezor-connect-actions';
import HWConnectActions from './hw-connect-actions';
import TrezorSendActions from './trezor-send-actions';
import AdaRedemptionActions from './ada-redemption-actions';
import LedgerSendActions from './ledger-send-actions';

export type AdaActionsMap = {
adaRedemption: AdaRedemptionActions,
Expand All @@ -15,8 +16,10 @@ export type AdaActionsMap = {
walletSettings: WalletSettingsActions,
addresses: AddressesActions,
daedalusTransfer: DaedalusTransferActions,
trezorConnect: TrezorConnectActions,
trezorConnect: HWConnectActions,
trezorSend: TrezorSendActions,
ledgerConnect: HWConnectActions,
ledgerSend: LedgerSendActions,
};

const adaActionsMap: AdaActionsMap = {
Expand All @@ -26,8 +29,10 @@ const adaActionsMap: AdaActionsMap = {
walletSettings: new WalletSettingsActions(),
addresses: new AddressesActions(),
daedalusTransfer: new DaedalusTransferActions(),
trezorConnect: new TrezorConnectActions(),
trezorConnect: new HWConnectActions(),
trezorSend: new TrezorSendActions(),
ledgerConnect: new HWConnectActions(),
ledgerSend: new LedgerSendActions(),
};

export default adaActionsMap;
15 changes: 15 additions & 0 deletions app/actions/ada/ledger-send-actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// @flow
import Action from '../lib/Action';

export type SendUsingLedgerParams = {
receiver: string,
amount: string
};

// ======= Sending ADA using Ledger ACTIONS =======

export default class LedgerSendActions {
init: Action<void> = new Action();
cancel: Action<void> = new Action();
sendUsingLedger: Action<SendUsingLedgerParams> = new Action();
}
1 change: 1 addition & 0 deletions app/actions/wallet-backup-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export default class WalletBackupActions {
restartWalletBackup: Action<any> = new Action();
cancelWalletBackup: Action<any> = new Action();
finishWalletBackup: Action<any> = new Action();
removeOneMnemonicWord: Action<any> = new Action();
}
17 changes: 5 additions & 12 deletions app/api/ada/daedalusTransfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ import {
NoInputsError,
GenerateTransferTxError
} from './errors';
import {
getCryptoDaedalusWalletFromMnemonics
} from './lib/cardanoCrypto/cryptoWallet';
import {
getAllUTXOsForAddresses
} from './adaTransactions/adaNewTransactions';
Expand All @@ -38,14 +35,11 @@ import { getReceiverAddress } from './adaAddress';
* @param fullUtxo the full utxo of the Cardano blockchain
*/
export function getAddressesWithFunds(payload: {
secretWords: string,
checker: CryptoAddressChecker,
fullUtxo: Array<string>
}): Array<CryptoDaedalusAddressRestored> {
try {
const { secretWords, fullUtxo } = payload;
const checker: CryptoAddressChecker = getResultOrFail(
RandomAddressChecker.newCheckerFromMnemonics(secretWords)
);
const { checker, fullUtxo } = payload;
const addressesWithFunds: Array<CryptoDaedalusAddressRestored> = getResultOrFail(
RandomAddressChecker.checkAddresses(checker, fullUtxo)
);
Expand All @@ -58,12 +52,12 @@ export function getAddressesWithFunds(payload: {

/** Generate transaction including all addresses with no change */
export async function generateTransferTx(payload: {
secretWords: string,
wallet: CryptoDaedalusWallet,
addressesWithFunds: Array<CryptoDaedalusAddressRestored>
}): Promise<TransferTx> {
try {

const { secretWords, addressesWithFunds } = payload;
const { wallet, addressesWithFunds } = payload;

// fetch data to make transaction
const senders = addressesWithFunds.map(a => a.address);
Expand All @@ -78,8 +72,7 @@ export async function generateTransferTx(payload: {
// pick which address to send transfer to
const output = await getReceiverAddress();

// get wallet and make transaction
const wallet = getCryptoDaedalusWalletFromMnemonics(secretWords);
// make transaction
const tx: MoveResponse = getResultOrFail(Wallet.move(wallet, inputs, output));

// return summary of transaction
Expand Down
130 changes: 130 additions & 0 deletions app/api/ada/hardwareWallet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# newTransaction.js
This module is responsible for managing hardware wallet device sign transaction, and it's two step process.
- Prepare the payload data format to be consume by respective hawrdware wallets(Trezor/Ledger).
- Propagate the hardware wallet signed transaction to the blockchain.

## Prepare the payload data format to be consume by respective hawrdware wallets(Trezor/Ledger).
For that let's first understand Cardano's format(UnsignedTransactionExt).
```
const txExt = {
"inputs": [
{
"ptr": {
"index": 0,
"id": "2610d9fe9af9ac321d631b231edc8433105a2facf2b1b7048d3365458ba0c060"
},
"value": {
"address": "Ae2tdPwUPEZHEU3j2jSAhuvwrCPvjSBHPjk4xTHEaiVGkrhneAGB6qzZMoD",
"value": "80000"
},
"addressing": {
"account": 0,
"change": 0,
"index": 1
}
},
{
"ptr": {
"index": 1,
"id": "e70f354a69f0e67ac2114ac57e27bd4f15bfa8c66e00603bd8e975d90400bf63"
},
"value": {
"address": "Ae2tdPwUPEZKVNJCH2CjBFNukyQBSEuq9xiU8hxdA4FxeT9ajY8L3dpevuR",
"value": "1484495"
},
"addressing": {
"account": 0,
"change": 1,
"index": 23
}
}
],
"outputs": [
{
"address": "Ae2tdPwUPEZHAQPk7EHHmKXBWWS33QbEWb576v52yHMpPEt7HgjR42coDay",
"value": 20004
},
{
"address": "Ae2tdPwUPEZAa8d3kFZEJeSZvHk2EnWsnJ4mCowMD8NX8aStpuryFxunt9m",
"value": 1368631,
"isChange": true,
"fullAddress": {
"cadAmount": {
"getCCoin": 0
},
"cadId": "Ae2tdPwUPEZAa8d3kFZEJeSZvHk2EnWsnJ4mCowMD8NX8aStpuryFxunt9m",
"cadIsUsed": false,
"account": 0,
"change": 1,
"index": 24
}
}
]
}
```

- [Trezor.cardanoSignTransaction(trezorParams)](https://github.com/trezor/connect/blob/develop/docs/methods/cardanoSignTransaction.md)
```
const trezorParams = {
"network": 2,
"transactions": [
"839f8200d81858248258206f9cf4bbad8fd0ac7487419ff7f1ed7ecfe90892f753325aaa74fbee73c227a601ff9f8282d818582183581cccb5b2e6aa52faa4a18e55c7712ee69ddc1bfafebf4c9e9fcb154a1ba0001a59f92a181a000138808282d818582183581c5f616829cd5536ba6b5931bc2aeca6016e6d8dd0a054a2e57650d617a0001a43d762111a001a4022ffa0",
"839f8200d81858248258206f9cf4bbad8fd0ac7487419ff7f1ed7ecfe90892f753325aaa74fbee73c227a6008200d81858248258202610d9fe9af9ac321d631b231edc8433105a2facf2b1b7048d3365458ba0c06001ff9f8282d818582183581caae0559f67add7d768b91ef3e55f1ce0e400037a11da3cacd1c101b7a0001a6aefab2c19ea608282d818582183581ce35422b874147b84ab476cf799198f29f1f3dacfac6ec3738f92caffa0001aa6d6ed8c1a0016a6cfffa0"
],
"inputs": [
{
"path": "m/44'/1815'/0'/0/1",
"prev_hash": "2610d9fe9af9ac321d631b231edc8433105a2facf2b1b7048d3365458ba0c060",
"prev_index": 0,
"type": 0
},
{
"path": "m/44'/1815'/0'/1/23",
"prev_hash": "e70f354a69f0e67ac2114ac57e27bd4f15bfa8c66e00603bd8e975d90400bf63",
"prev_index": 1,
"type": 0
}
],
"outputs": [
{
"amount": "20004",
"address": "Ae2tdPwUPEZHAQPk7EHHmKXBWWS33QbEWb576v52yHMpPEt7HgjR42coDay"
},
{
"amount": "1368631",
"path": "m/44'/1815'/0'/1/24"
}
]
}
```

- [Ledger.signTransaction(ledgerParams)](https://github.com/vacuumlabs/ledgerjs/blob/1a85a888f7c2a0494b2dda0451e85916b43e7101/packages/hw-app-ada/src/Ada.js#L291)
```
const ledgerParams = {
"inputs" : [
{
txDataHex: trezorParams.transactions[0],
outputIndex: trezorParams.inputs[0].prev_index,
path: utils.str_to_path(trezorParams.inputs[0].path)
},
{
txDataHex: trezorParams.transactions[1],
outputIndex: trezorParams.inputs[1].prev_index,
path: utils.str_to_path(trezorParams.inputs[1].path)
}
],
"outputs": [
{
amountStr: trezorParams.outputs[0].amount,
address58: trezorParams.outputs[0].address
},
{
amountStr: trezorParams.outputs[1].amount,
path: utils.str_to_path(trezorParams.outputs[1].path)
}
]
}
```

## Propagate the hardware wallet signed transaction to the blockchain
TODO
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,26 @@ import { createHardwareWalletAccount } from '../adaAccount';
* Caches the fetched address results locally (into lovefieldDatabase)
* @returns a new AdaWallet
*/
export async function createTrezorWallet({
export async function createWallet({
walletInitData
}: AdaHardwareWalletParams): Promise<AdaWallet> {
try {
Logger.debug('createTrezorWallet::createTrezorWallet called');
Logger.debug('hardwareWallet::createWallet called');

// create ada wallet object for hardware wallet
const [adaWallet] = createAdaHardwareWallet({ walletInitData });
const [hardwareWallet] = createAdaHardwareWallet({ walletInitData });

// create crypto account object for hardware wallet
// eslint-disable-next-line max-len
const cryptoAccount = createHardwareWalletAccount(walletInitData.cwHardwareInfo.publicMasterKey);
const { publicMasterKey } = walletInitData.cwHardwareInfo;
const cryptoAccount = createHardwareWalletAccount(publicMasterKey);

// Restore transactions and Save wallet + cryptoAccount to localstorage
await restoreTransactionsAndSave(cryptoAccount, adaWallet);
await restoreTransactionsAndSave(cryptoAccount, hardwareWallet);

Logger.debug('createTrezorWallet::createTrezorWallet success');
return adaWallet;
Logger.debug('hardwareWallet::createWallet success');
return hardwareWallet;
} catch (error) {
Logger.error(`createTrezorWallet::createTrezorWallet error: ${stringifyError(error)}`);
Logger.error(`hardwareWallet::createWallet error: ${stringifyError(error)}`);
throw error;
}
}
Loading