Skip to content
This repository has been archived by the owner on Nov 23, 2023. It is now read-only.

Commit

Permalink
removed Bitcoincash support
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonlesisz committed Aug 9, 2017
1 parent ce179c9 commit 3d64e07
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 209 deletions.
11 changes: 0 additions & 11 deletions connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,6 @@ this.TrezorConnect = (function () {
}
}

this.claimBitcoinCashAccountsInfo = function(callback, requiredFirmware){
try {
manager.sendWithChannel(_fwStrFix({
type: 'claimBitcoinCashAccountsInfo',
description: 'all'
}, requiredFirmware), callback);
} catch(e) {
callback({success: false, error: e});
}
}

this.getBalance = function (callback, requiredFirmware) {
manager.sendWithChannel(_fwStrFix({
type: 'accountinfo'
Expand Down
40 changes: 0 additions & 40 deletions examples/claim-bch.html

This file was deleted.

41 changes: 0 additions & 41 deletions examples/claim-btc.html

This file was deleted.

4 changes: 2 additions & 2 deletions popup/popup-dist.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions popup/popup-dist.js.map

Large diffs are not rendered by default.

113 changes: 0 additions & 113 deletions popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ function onMessage(event) {
case 'allaccountsinfo':
handleAllAccountsInfo(event);
break;
case 'claimBitcoinCashAccountsInfo':
handleClaimBitcoinCashAccountsInfo(event);
break;

case 'signtx':
handleSignTx(event);
Expand Down Expand Up @@ -659,116 +656,6 @@ function cancelInfo() {
window.cancelInfo = cancelInfo;


function handleClaimBitcoinCashAccountsInfo(event) {
show('#operation_accountinfo');
let description = event.data.description;

initDevice({ emptyPassphrase: false })
.then(function getAccounts(device) {
return getAccountByDescription(description)
.then(accounts => {
let list = [];
// get new BitcoinCash address for every retreived account
return accounts.reduce(
(promise, a) => {
return promise.then(() => {

// modify BTC path to BCC path
let bccPath = a.getPath();
bccPath[1] = (145 | HD_HARDENED) >>> 0;
bccPath.push(0, 0);

// get BCC adress from BCC path
return device.session.getAddress(bccPath, 'Bitcoin', false, false)
.then(bccAddressResponse => {
list.push({
id: a.id,
addressId: a.nextAddressId,
balance: a.getBalance(),
path: a.getPath(),
unspents: a.getUnspents(),
bitcoinCashAddress: bccAddressResponse.message.address,
bitcoinCashPath: bccAddressResponse.message.path
});
return list;
});
});
},
Promise.resolve()
);
// handle invalid pin error, loop function
}).catch(errorHandler(() => getAccounts(device)));
})
.then(list => {
if (BIP44_COIN_TYPE === 0) {
// BTC account discovery, do nothing...
return list;
} else {
// BCH account discovery.
// We need to do a second discovery this time with BTC accounts to find BTC fresh address
// to do this we need to set BIP44_COIN_TYPE to 0 (BTC - default)
// and after discovery finish set it back to previous cached value...
let bip44_coin_type_cache = BIP44_COIN_TYPE;
BIP44_COIN_TYPE = 0;
return getAccountByDescription(description)
.then(accounts => {

BIP44_COIN_TYPE = bip44_coin_type_cache;
for(let item in list){
let btcAccount = accounts[item];
list[item].bitcoinAddress = btcAccount.nextAddress;
list[item].bitcoinAddressPath = btcAccount.getAddressPath(btcAccount.nextAddress);
}
return list;
})
}

})
.then(list => {
// get fees
// return findAllRecommendedFeeLevels().then(fees => {
// return {
// accounts: list,
// fees: fees
// }
// });
return {
accounts: list,
fees: [
{
name: 'High',
maxFee: 199
}, {
name: 'Normal',
maxFee: 112
}, {
name: 'Economy',
maxFee: 48
}, {
name: 'Low',
maxFee: 24
}
]
}

})
.then(response => { // success
return global.device.session.release().then(() => {
respondToEvent(event, {
success: true,
accounts: response.accounts,
fees: response.fees
});
});
})
.catch(error => { // failure
console.error(error);
respondToEvent(event, {success: false, error: error.message});
});

}


function handleAllAccountsInfo(event) {
show('#operation_accountinfo');
let description = event.data.description;
Expand Down

0 comments on commit 3d64e07

Please sign in to comment.