Commit cc4ae9ee authored by Sergei Zubov's avatar Sergei Zubov

Modify wallets

Remove bitcoin and stratis wallet, add destream wallet
parent 88763a9f
...@@ -77,8 +77,7 @@ app.on('ready', function () { ...@@ -77,8 +77,7 @@ app.on('ready', function () {
console.log("Breeze UI was started in development mode. This requires the user to be running the Breeze Daemon himself.") console.log("Breeze UI was started in development mode. This requires the user to be running the Breeze Daemon himself.")
} }
else { else {
startBitcoinApi(); startDeStreamApi();
startStratisApi();
} }
createTray(); createTray();
createWindow(); createWindow();
...@@ -88,8 +87,7 @@ app.on('ready', function () { ...@@ -88,8 +87,7 @@ app.on('ready', function () {
}); });
app.on('before-quit', function () { app.on('before-quit', function () {
closeBitcoinApi(), closeDeStreamApi();
closeStratisApi();
}); });
// Quit when all windows are closed. // Quit when all windows are closed.
...@@ -109,24 +107,7 @@ app.on('activate', function () { ...@@ -109,24 +107,7 @@ app.on('activate', function () {
} }
}); });
function closeBitcoinApi() { function closeDeStreamApi() {
// if (process.platform !== 'darwin' && !serve) {
if (!serve) {
var http1 = require('http');
const options1 = {
hostname: 'localhost',
port: 37220,
path: '/api/node/shutdown',
method: 'POST'
};
const req = http1.request(options1, (res) => {});
req.write('');
req.end();
}
};
function closeStratisApi() {
// if (process.platform !== 'darwin' && !serve) { // if (process.platform !== 'darwin' && !serve) {
if (process.platform !== 'darwin' && !serve) { if (process.platform !== 'darwin' && !serve) {
var http2 = require('http'); var http2 = require('http');
...@@ -143,42 +124,11 @@ function closeStratisApi() { ...@@ -143,42 +124,11 @@ function closeStratisApi() {
} }
}; };
function startBitcoinApi() { function startDeStreamApi() {
var bitcoinProcess; var destreamProcess;
const spawnBitcoin = require('child_process').spawn; const spawnDeStream = require('child_process').spawn;
//Start Breeze Bitcoin Daemon
let apiPath = path.resolve(__dirname, 'assets//daemon//Stratis.BreezeD');
if (os.platform() === 'win32') {
apiPath = path.resolve(__dirname, '..\\..\\resources\\daemon\\Stratis.BreezeD.exe');
} else if(os.platform() === 'linux') {
apiPath = path.resolve(__dirname, '..//..//resources//daemon//Stratis.BreezeD');
} else {
apiPath = path.resolve(__dirname, '..//..//resources//daemon//Stratis.BreezeD');
}
if(!testnet) {
bitcoinProcess = spawnBitcoin(apiPath, {
detached: true
});
} else if (testnet) {
bitcoinProcess = spawnBitcoin(apiPath, ['-testnet'], {
detached: true
});
}
bitcoinProcess.stdout.on('data', (data) => {
writeLog(`Bitcoin: ${data}`);
});
}
function startStratisApi() {
var stratisProcess;
const spawnStratis = require('child_process').spawn;
//Start Breeze Stratis Daemon //Start Breeze DeStream Daemon
let apiPath = path.resolve(__dirname, 'assets//daemon//Stratis.BreezeD'); let apiPath = path.resolve(__dirname, 'assets//daemon//Stratis.BreezeD');
if (os.platform() === 'win32') { if (os.platform() === 'win32') {
apiPath = path.resolve(__dirname, '..\\..\\resources\\daemon\\Stratis.BreezeD.exe'); apiPath = path.resolve(__dirname, '..\\..\\resources\\daemon\\Stratis.BreezeD.exe');
...@@ -189,17 +139,17 @@ function startStratisApi() { ...@@ -189,17 +139,17 @@ function startStratisApi() {
} }
if (!testnet) { if (!testnet) {
stratisProcess = spawnStratis(apiPath, ['stratis'], { destreamProcess = spawnDeStream(apiPath, ['destream'], {
detached: true detached: true
}); });
} else if (testnet) { } else if (testnet) {
stratisProcess = spawnStratis(apiPath, ['stratis', '-testnet'], { destreamProcess = spawnDeStream(apiPath, ['destream', '-testnet'], {
detached: true detached: true
}); });
} }
stratisProcess.stdout.on('data', (data) => { destreamProcess.stdout.on('data', (data) => {
writeLog(`Stratis: ${data}`); writeLog(`DeStream: ${data}`);
}); });
} }
......
...@@ -23,11 +23,11 @@ export class AppComponent implements OnInit { ...@@ -23,11 +23,11 @@ export class AppComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.setTitle(); this.setTitle();
this.apiService.getWalletFiles().retryWhen(errors => errors.delay(2000)).subscribe(() => this.checkStratisDaemon()); this.apiService.getWalletFiles().retryWhen(errors => errors.delay(2000)).subscribe(() => this.checkDeStreamDaemon());
} }
private checkStratisDaemon() { private checkDeStreamDaemon() {
this.apiService.getStratisWalletFiles().retryWhen(errors => errors.delay(2000)).subscribe(() => this.startApp()); this.apiService.getWalletFiles().retryWhen(errors => errors.delay(2000)).subscribe(() => this.startApp());
} }
private startApp() { private startApp() {
...@@ -36,7 +36,7 @@ export class AppComponent implements OnInit { ...@@ -36,7 +36,7 @@ export class AppComponent implements OnInit {
} }
private setTitle() { private setTitle() {
const applicationName = "Stratis Breeze Wallet"; const applicationName = "DeStream Breeze Wallet";
const newTitle = applicationName + " v" + remote.app.getVersion(); const newTitle = applicationName + " v" + remote.app.getVersion();
this.titleService.setTitle(newTitle); this.titleService.setTitle(newTitle);
} }
......
...@@ -127,33 +127,8 @@ export class LoginComponent implements OnInit { ...@@ -127,33 +127,8 @@ export class LoginComponent implements OnInit {
} }
private loadWallets(walletLoad: WalletLoad) { private loadWallets(walletLoad: WalletLoad) {
this.apiService.loadBitcoinWallet(walletLoad)
.subscribe(
response => {
if (response.status >= 200 && response.status < 400) {
this.globalService.setWalletName(walletLoad.name);
}
},
error => {
this.isDecrypting = false;
if (error.status === 0) {
this.genericModalService.openModal(null, null);
} else if (error.status >= 400) {
if (!error.json().errors[0]) {
console.log(error);
}
else {
this.genericModalService.openModal(null, error.json().errors[0].message);
}
}
},
() => this.loadStratisWallet(walletLoad)
)
;
}
private loadStratisWallet(walletLoad: WalletLoad) { this.apiService.loadDeStreamWallet(walletLoad)
this.apiService.loadStratisWallet(walletLoad)
.subscribe( .subscribe(
response => { response => {
if (response.status >= 200 && response.status < 400) { if (response.status >= 200 && response.status < 400) {
...@@ -180,19 +155,14 @@ export class LoginComponent implements OnInit { ...@@ -180,19 +155,14 @@ export class LoginComponent implements OnInit {
private getCurrentNetwork() { private getCurrentNetwork() {
let walletInfo = new WalletInfo(this.globalService.getWalletName()) let walletInfo = new WalletInfo(this.globalService.getWalletName())
this.apiService.getGeneralInfoOnce(walletInfo) this.apiService.getGeneralInfo(walletInfo)
.subscribe( .subscribe(
response => { response => {
if (response.status >= 200 && response.status < 400) { if (response.status >= 200 && response.status < 400) {
let responseMessage = response.json(); let responseMessage = response.json();
this.globalService.setNetwork(responseMessage.network); this.globalService.setNetwork(responseMessage.network);
if (responseMessage.network === "Main") { this.globalService.setCoinName("DeStreamCoin");
this.globalService.setCoinName("Bitcoin"); this.globalService.setCoinUnit("DST");
this.globalService.setCoinUnit("BTC");
} else if (responseMessage.network === "TestNet") {
this.globalService.setCoinName("TestBitcoin");
this.globalService.setCoinUnit("TBTC");
}
} }
}, },
error => { error => {
......
...@@ -141,36 +141,7 @@ export class ConfirmMnemonicComponent implements OnInit { ...@@ -141,36 +141,7 @@ export class ConfirmMnemonicComponent implements OnInit {
private createWallets(wallet: WalletCreation) { private createWallets(wallet: WalletCreation) {
this.apiService this.apiService
.createBitcoinWallet(wallet) .createDeStreamWallet(wallet)
.subscribe(
response => {
if (response.status >= 200 && response.status < 400){
// Bitcoin wallet created
}
},
error => {
console.log(error);
this.isCreating = false;
if (error.status === 0) {
this.genericModalService.openModal(null, null);
} else if (error.status >= 400) {
if (!error.json().errors[0]) {
console.log(error);
}
else {
this.genericModalService.openModal(null, error.json().errors[0].message);
this.router.navigate(['/setup/create']);
}
}
},
() => this.createStratisWallet(wallet)
)
;
}
private createStratisWallet(wallet: WalletCreation) {
this.apiService
.createStratisWallet(wallet)
.subscribe( .subscribe(
response => { response => {
if (response.status >= 200 && response.status < 400){ if (response.status >= 200 && response.status < 400){
......
...@@ -114,39 +114,9 @@ export class RecoverComponent implements OnInit { ...@@ -114,39 +114,9 @@ export class RecoverComponent implements OnInit {
} }
private recoverWallets(recoverWallet: WalletRecovery) { private recoverWallets(recoverWallet: WalletRecovery) {
let bitcoinErrorMessage = ""; let destreamErrorMessage = "";
this.apiService this.apiService
.recoverBitcoinWallet(recoverWallet) .recoverDeStreamWallet(recoverWallet)
.subscribe(
response => {
if (response.status >= 200 && response.status < 400) {
//Bitcoin Wallet Recovered
}
this.recoverStratisWallet(recoverWallet, bitcoinErrorMessage);
},
error => {
this.isRecovering = false;
console.log(error);
if (error.status === 0) {
this.genericModalService.openModal(null, null);
} else if (error.status >= 400) {
if (!error.json().errors[0]) {
console.log(error);
}
else {
bitcoinErrorMessage = error.json().errors[0].message;
}
}
this.recoverStratisWallet(recoverWallet, bitcoinErrorMessage);
}
)
;
}
private recoverStratisWallet(recoverWallet: WalletRecovery, bitcoinErrorMessage: string){
let stratisErrorMessage = "";
this.apiService
.recoverStratisWallet(recoverWallet)
.subscribe( .subscribe(
response => { response => {
if (response.status >= 200 && response.status < 400) { if (response.status >= 200 && response.status < 400) {
...@@ -154,7 +124,7 @@ export class RecoverComponent implements OnInit { ...@@ -154,7 +124,7 @@ export class RecoverComponent implements OnInit {
this.genericModalService.openModal("Wallet Recovered", body); this.genericModalService.openModal("Wallet Recovered", body);
this.router.navigate(['']) this.router.navigate([''])
} }
this.AlertIfNeeded(bitcoinErrorMessage, stratisErrorMessage); this.AlertIfNeeded(destreamErrorMessage);
}, },
error => { error => {
this.isRecovering = false; this.isRecovering = false;
...@@ -166,18 +136,18 @@ export class RecoverComponent implements OnInit { ...@@ -166,18 +136,18 @@ export class RecoverComponent implements OnInit {
console.log(error); console.log(error);
} }
else { else {
stratisErrorMessage = error.json().errors[0].message; destreamErrorMessage = error.json().errors[0].message;
} }
} }
this.AlertIfNeeded(bitcoinErrorMessage, stratisErrorMessage); this.AlertIfNeeded(destreamErrorMessage);
} }
) )
; ;
} }
private AlertIfNeeded(bitcoinErrorMessage: string, stratisErrorMessage: string) { private AlertIfNeeded(destreamErrorMessage: string) {
if(bitcoinErrorMessage !== "" || stratisErrorMessage !== "") { if(destreamErrorMessage !== "") {
let errorMessage = "<strong>Bitcoin wallet recovery:</strong><br>" + bitcoinErrorMessage + "<br><br><strong>Stratis wallet recovery:</strong><br>" + stratisErrorMessage; let errorMessage = "<strong>DeStream wallet recovery:</strong><br>" + destreamErrorMessage;
this.genericModalService.openModal(null, errorMessage); this.genericModalService.openModal(null, errorMessage);
} }
} }
......
...@@ -27,34 +27,15 @@ export class ApiService { ...@@ -27,34 +27,15 @@ export class ApiService {
private headers = new Headers({'Content-Type': 'application/json'}); private headers = new Headers({'Content-Type': 'application/json'});
private pollingInterval = 3000; private pollingInterval = 3000;
private bitcoinApiUrl = 'http://localhost:37220/api'; private destreamApiUrl = 'http://localhost:56864/api';
private stratisApiUrl = 'http://localhost:37221/api'; private currentApiUrl = 'http://localhost:56864/api';
private currentApiUrl = 'http://localhost:37220/api';
private getCurrentCoin() {
let currentCoin = this.globalService.getCoinName();
if (currentCoin === "Bitcoin" || currentCoin === "TestBitcoin") {
this.currentApiUrl = this.bitcoinApiUrl;
} else if (currentCoin === "Stratis" || currentCoin === "TestStratis") {
this.currentApiUrl = this.stratisApiUrl;
}
}
/** /**
* Gets available wallets at the default path * Gets available wallets at the default path
*/ */
getWalletFiles(): Observable<any> { getWalletFiles(): Observable<any> {
return this.http return this.http
.get(this.bitcoinApiUrl + '/wallet/files') .get(this.destreamApiUrl + '/wallet/files')
.map((response: Response) => response);
}
/**
* Gets available wallets at the default path
*/
getStratisWalletFiles(): Observable<any> {
return this.http
.get(this.stratisApiUrl + '/wallet/files')
.map((response: Response) => response); .map((response: Response) => response);
} }
...@@ -67,61 +48,33 @@ export class ApiService { ...@@ -67,61 +48,33 @@ export class ApiService {
params.set('wordCount', '12'); params.set('wordCount', '12');
return this.http return this.http
.get(this.bitcoinApiUrl + '/wallet/mnemonic', new RequestOptions({headers: this.headers, search: params})) .get(this.destreamApiUrl + '/wallet/mnemonic', new RequestOptions({headers: this.headers, search: params}))
.map((response: Response) => response);
}
/**
* Create a new Bitcoin wallet.
*/
createBitcoinWallet(data: WalletCreation): Observable<any> {
return this.http
.post(this.bitcoinApiUrl + '/wallet/create/', JSON.stringify(data), {headers: this.headers})
.map((response: Response) => response);
}
/**
* Create a new Stratis wallet.
*/
createStratisWallet(data: WalletCreation): Observable<any> {
return this.http
.post(this.stratisApiUrl + '/wallet/create/', JSON.stringify(data), {headers: this.headers})
.map((response: Response) => response); .map((response: Response) => response);
} }
/**
* Recover a Bitcoin wallet.
*/
recoverBitcoinWallet(data: WalletRecovery): Observable<any> {
return this.http
.post(this.bitcoinApiUrl + '/wallet/recover/', JSON.stringify(data), {headers: this.headers})
.map((response: Response) => response);
}
/** /**
* Recover a Stratis wallet. * Create a new DeStream wallet.
*/ */
recoverStratisWallet(data: WalletRecovery): Observable<any> { createDeStreamWallet(data: WalletCreation): Observable<any> {
return this.http return this.http
.post(this.stratisApiUrl + '/wallet/recover/', JSON.stringify(data), {headers: this.headers}) .post(this.destreamApiUrl + '/wallet/create/', JSON.stringify(data), {headers: this.headers})
.map((response: Response) => response); .map((response: Response) => response);
} }
/** /**
* Load a Bitcoin wallet * Recover a DeStream wallet.
*/ */
loadBitcoinWallet(data: WalletLoad): Observable<any> { recoverDeStreamWallet(data: WalletRecovery): Observable<any> {
return this.http return this.http
.post(this.bitcoinApiUrl + '/wallet/load/', JSON.stringify(data), {headers: this.headers}) .post(this.destreamApiUrl + '/wallet/recover/', JSON.stringify(data), {headers: this.headers})
.map((response: Response) => response); .map((response: Response) => response);
} }
/** /**
* Load a Stratis wallet * Load a DeStream wallet
*/ */
loadStratisWallet(data: WalletLoad): Observable<any> { loadDeStreamWallet(data: WalletLoad): Observable<any> {
return this.http return this.http
.post(this.stratisApiUrl + '/wallet/load/', JSON.stringify(data), {headers: this.headers}) .post(this.destreamApiUrl + '/wallet/load/', JSON.stringify(data), {headers: this.headers})
.map((response: Response) => response); .map((response: Response) => response);
} }
...@@ -129,30 +82,16 @@ export class ApiService { ...@@ -129,30 +82,16 @@ export class ApiService {
* Get wallet status info from the API. * Get wallet status info from the API.
*/ */
getWalletStatus(): Observable<any> { getWalletStatus(): Observable<any> {
this.getCurrentCoin();
return this.http return this.http
.get(this.currentApiUrl + '/wallet/status') .get(this.currentApiUrl + '/wallet/status')
.map((response: Response) => response); .map((response: Response) => response);
} }
/**
* Get general wallet info from the API once.
*/
getGeneralInfoOnce(data: WalletInfo): Observable<any> {
let params: URLSearchParams = new URLSearchParams();
params.set('Name', data.walletName);
return this.http
.get(this.bitcoinApiUrl + '/wallet/general-info', new RequestOptions({headers: this.headers, search: params}))
.map((response: Response) => response);
}
/** /**
* Get general wallet info from the API. * Get general wallet info from the API.
*/ */
getGeneralInfo(data: WalletInfo): Observable<any> { getGeneralInfo(data: WalletInfo): Observable<any> {
this.getCurrentCoin();
let params: URLSearchParams = new URLSearchParams(); let params: URLSearchParams = new URLSearchParams();
params.set('Name', data.walletName); params.set('Name', data.walletName);
...@@ -168,7 +107,6 @@ export class ApiService { ...@@ -168,7 +107,6 @@ export class ApiService {
* Get wallet balance info from the API. * Get wallet balance info from the API.
*/ */
getWalletBalance(data: WalletInfo): Observable<any> { getWalletBalance(data: WalletInfo): Observable<any> {
this.getCurrentCoin();
let params: URLSearchParams = new URLSearchParams(); let params: URLSearchParams = new URLSearchParams();
params.set('walletName', data.walletName); params.set('walletName', data.walletName);
...@@ -184,7 +122,6 @@ export class ApiService { ...@@ -184,7 +122,6 @@ export class ApiService {
* Get the maximum sendable amount for a given fee from the API * Get the maximum sendable amount for a given fee from the API
*/ */
getMaximumBalance(data): Observable<any> { getMaximumBalance(data): Observable<any> {
this.getCurrentCoin();
let params: URLSearchParams = new URLSearchParams(); let params: URLSearchParams = new URLSearchParams();
params.set('walletName', data.walletName); params.set('walletName', data.walletName);
...@@ -201,7 +138,6 @@ export class ApiService { ...@@ -201,7 +138,6 @@ export class ApiService {
* Get a wallets transaction history info from the API. * Get a wallets transaction history info from the API.
*/ */
getWalletHistory(data: WalletInfo): Observable<any> { getWalletHistory(data: WalletInfo): Observable<any> {
this.getCurrentCoin();
let params: URLSearchParams = new URLSearchParams(); let params: URLSearchParams = new URLSearchParams();
params.set('walletName', data.walletName); params.set('walletName', data.walletName);
...@@ -217,7 +153,6 @@ export class ApiService { ...@@ -217,7 +153,6 @@ export class ApiService {
* Get an unused receive address for a certain wallet from the API. * Get an unused receive address for a certain wallet from the API.
*/ */
getUnusedReceiveAddress(data: WalletInfo): Observable<any> { getUnusedReceiveAddress(data: WalletInfo): Observable<any> {
this.getCurrentCoin();
let params: URLSearchParams = new URLSearchParams(); let params: URLSearchParams = new URLSearchParams();
params.set('walletName', data.walletName); params.set('walletName', data.walletName);
...@@ -231,7 +166,6 @@ export class ApiService { ...@@ -231,7 +166,6 @@ export class ApiService {
* Get multiple unused receive addresses for a certain wallet from the API. * Get multiple unused receive addresses for a certain wallet from the API.
*/ */
getUnusedReceiveAddresses(data: WalletInfo, count: string): Observable<any> { getUnusedReceiveAddresses(data: WalletInfo, count: string): Observable<any> {
this.getCurrentCoin();
let params: URLSearchParams = new URLSearchParams(); let params: URLSearchParams = new URLSearchParams();
params.set('walletName', data.walletName); params.set('walletName', data.walletName);
...@@ -246,7 +180,6 @@ export class ApiService { ...@@ -246,7 +180,6 @@ export class ApiService {
* Get get all receive addresses for an account of a wallet from the API. * Get get all receive addresses for an account of a wallet from the API.
*/ */
getAllReceiveAddresses(data: WalletInfo): Observable<any> { getAllReceiveAddresses(data: WalletInfo): Observable<any> {
this.getCurrentCoin();
let params: URLSearchParams = new URLSearchParams(); let params: URLSearchParams = new URLSearchParams();
params.set('walletName', data.walletName); params.set('walletName', data.walletName);
...@@ -260,7 +193,6 @@ export class ApiService { ...@@ -260,7 +193,6 @@ export class ApiService {
* Estimate the fee of a transaction * Estimate the fee of a transaction
*/ */
estimateFee(data: FeeEstimation): Observable<any> { estimateFee(data: FeeEstimation): Observable<any> {
this.getCurrentCoin();
let params: URLSearchParams = new URLSearchParams(); let params: URLSearchParams = new URLSearchParams();
params.set('walletName', data.walletName); params.set('walletName', data.walletName);
...@@ -279,7 +211,6 @@ export class ApiService { ...@@ -279,7 +211,6 @@ export class ApiService {
* Build a transaction * Build a transaction
*/ */
buildTransaction(data: TransactionBuilding): Observable<any> { buildTransaction(data: TransactionBuilding): Observable<any> {
this.getCurrentCoin();
return this.http return this.http
.post(this.currentApiUrl + '/wallet/build-transaction', JSON.stringify(data), {headers: this.headers}) .post(this.currentApiUrl + '/wallet/build-transaction', JSON.stringify(data), {headers: this.headers})
...@@ -290,7 +221,6 @@ export class ApiService { ...@@ -290,7 +221,6 @@ export class ApiService {
* Send transaction * Send transaction
*/ */
sendTransaction(data: TransactionSending): Observable<any> { sendTransaction(data: TransactionSending): Observable<any> {
this.getCurrentCoin();
return this.http return this.http
.post(this.currentApiUrl + '/wallet/send-transaction', JSON.stringify(data), {headers: this.headers}) .post(this.currentApiUrl + '/wallet/send-transaction', JSON.stringify(data), {headers: this.headers})
...@@ -301,7 +231,6 @@ export class ApiService { ...@@ -301,7 +231,6 @@ export class ApiService {
* Send shutdown signal to the daemon * Send shutdown signal to the daemon
*/ */
shutdownNode(): Observable<any> { shutdownNode(): Observable<any> {
this.getCurrentCoin();
return this.http return this.http
.post(this.currentApiUrl + '/node/shutdown', '') .post(this.currentApiUrl + '/node/shutdown', '')
......
...@@ -3,7 +3,7 @@ import { Router, NavigationEnd } from '@angular/router'; ...@@ -3,7 +3,7 @@ import { Router, NavigationEnd } from '@angular/router';
import { ReplaySubject } from 'rxjs/ReplaySubject'; import { ReplaySubject } from 'rxjs/ReplaySubject';
export enum Page { export enum Page {
Bitcoin, Stratis DeStream
} }
@Injectable() @Injectable()
...@@ -16,8 +16,7 @@ export class NavigationService { ...@@ -16,8 +16,7 @@ export class NavigationService {
.map(x => <NavigationEnd>x) .map(x => <NavigationEnd>x)
.map(x => x.url); .map(x => x.url);
navigation$.filter(x => x === this.navBase).subscribe(_ => this.pageSubject.next(Page.Bitcoin)); navigation$.filter(x => x === `${this.navBase}/destream-wallet`).subscribe(_ => this.pageSubject.next(Page.DeStream));
navigation$.filter(x => x === `${this.navBase}/stratis-wallet`).subscribe(_ => this.pageSubject.next(Page.Stratis));
} }
public pageSubject = new ReplaySubject(1); public pageSubject = new ReplaySubject(1);
......
...@@ -58,10 +58,15 @@ export class DashboardComponent implements OnInit { ...@@ -58,10 +58,15 @@ export class DashboardComponent implements OnInit {
this.walletBalanceSubscription = this.apiService.getWalletBalance(walletInfo) this.walletBalanceSubscription = this.apiService.getWalletBalance(walletInfo)
.subscribe( .subscribe(
response => { response => {
console.log("HJERE");
if (response.status >= 200 && response.status < 400) { if (response.status >= 200 && response.status < 400) {
console.log("HJERE2");
let balanceResponse = response.json(); let balanceResponse = response.json();
console.log(balanceResponse);
this.confirmedBalance = balanceResponse.balances[0].amountConfirmed; this.confirmedBalance = balanceResponse.balances[0].amountConfirmed;
console.log(balanceResponse.balances[0].amountConfirmed);
this.unconfirmedBalance = balanceResponse.balances[0].amountUnconfirmed; this.unconfirmedBalance = balanceResponse.balances[0].amountUnconfirmed;
console.log(balanceResponse.balances[0].amountUnconfirmed);
} }
}, },
error => { error => {
......
...@@ -81,6 +81,7 @@ export class HistoryComponent { ...@@ -81,6 +81,7 @@ export class HistoryComponent {
private getTransactionInfo(transactions: any) { private getTransactionInfo(transactions: any) {
this.transactions = []; this.transactions = [];
console.log("hit it");
for (let transaction of transactions) { for (let transaction of transactions) {
let transactionType; let transactionType;
if (transaction.type === "send") { if (transaction.type === "send") {
...@@ -100,6 +101,12 @@ export class HistoryComponent { ...@@ -100,6 +101,12 @@ export class HistoryComponent {
let transactionTimestamp = transaction.timestamp; let transactionTimestamp = transaction.timestamp;
let transactionConfirmed; let transactionConfirmed;
console.log("transactionType: " + transactionType);
console.log("transactionId: " + transactionId);
console.log("transactionAmount: " + transactionAmount);
console.log("transactionFee: " + transactionFee);
console.log("transactionConfirmedInBlock: " + transactionConfirmedInBlock);
console.log("transactionTimestamp: " + transactionTimestamp);
this.transactions.push(new TransactionInfo(transactionType, transactionId, transactionAmount, transactionFee, transactionConfirmedInBlock, transactionTimestamp)); this.transactions.push(new TransactionInfo(transactionType, transactionId, transactionAmount, transactionFee, transactionConfirmedInBlock, transactionTimestamp));
} }
} }
......
...@@ -2,11 +2,7 @@ ...@@ -2,11 +2,7 @@
<aside id="sidebar"> <aside id="sidebar">
<!-- menu--> <!-- menu-->
<ul class="list-unstyled menu"> <ul class="list-unstyled menu">
<li (click)="loadBitcoinWallet()" [class.active]="bitcoinActive"> <li (click)="loadDeStreamWallet()" [class.active]="stratisActive">
<img src="../../../assets/images/ico_bitcoin.svg" alt="Bitcoin">
<span class="bar"></span>
</li>
<li (click)="loadStratisWallet()" [class.active]="stratisActive">
<img src="../../../assets/images/ico_stratis.svg" alt="Stratis"> <img src="../../../assets/images/ico_stratis.svg" alt="Stratis">
<span class="bar"></span> <span class="bar"></span>
</li> </li>
......
...@@ -20,47 +20,15 @@ export class SidebarComponent implements OnInit { ...@@ -20,47 +20,15 @@ export class SidebarComponent implements OnInit {
constructor(private globalService: GlobalService, private apiService: ApiService, constructor(private globalService: GlobalService, private apiService: ApiService,
private router: Router, private modalService: NgbModal, private genericModalService: ModalService, private router: Router, private modalService: NgbModal, private genericModalService: ModalService,
private navigationService: NavigationService) { } private navigationService: NavigationService) { }
public bitcoinActive: boolean;
public stratisActive: boolean;
ngOnInit() { ngOnInit() {
if (this.globalService.getCoinName() === "Bitcoin" || this.globalService.getCoinName() === "TestBitcoin") {
this.bitcoinActive = true;
this.stratisActive = false;
} else if (this.globalService.getCoinName() === "Stratis" || this.globalService.getCoinName() === "TestStratis") {
this.bitcoinActive = false;
this.stratisActive = true;
}
} }
public loadBitcoinWallet() { public loadDestreamWallet() {
let currentNetwork = this.globalService.getNetwork(); this.globalService.setCoinName("DeStreamCoin");
if (currentNetwork === "Main") { this.globalService.setCoinUnit("DST");
this.globalService.setCoinName("Bitcoin");
this.globalService.setCoinUnit("BTC");
} else if (currentNetwork === "TestNet"){
this.globalService.setCoinName("TestBitcoin");
this.globalService.setCoinUnit("TBTC");
}
this.bitcoinActive = true; this.router.navigate(['/wallet/destream-wallet']);
this.stratisActive = false;
this.router.navigate(['/wallet']);
}
public loadStratisWallet() {
let currentNetwork = this.globalService.getNetwork();
if (currentNetwork === "Main") {
this.globalService.setCoinName("Stratis");
this.globalService.setCoinUnit("STRAT");
} else if (currentNetwork === "TestNet"){
this.globalService.setCoinName("TestStratis");
this.globalService.setCoinUnit("TSTRAT");
}
this.bitcoinActive = false;
this.stratisActive = true;
this.router.navigate(['/wallet/stratis-wallet']);
} }
public logOut() { public logOut() {
......
...@@ -15,7 +15,7 @@ const routes: Routes = [ ...@@ -15,7 +15,7 @@ const routes: Routes = [
{ path: 'advanced', component: AdvancedComponent } { path: 'advanced', component: AdvancedComponent }
] ]
}, },
{ path: 'stratis-wallet', component: WalletComponent, { path: 'destream-wallet', component: WalletComponent,
children: [ children: [
{ path: '', redirectTo:'dashboard', pathMatch:'full' }, { path: '', redirectTo:'dashboard', pathMatch:'full' },
{ path: 'dashboard', component: DashboardComponent }, { path: 'dashboard', component: DashboardComponent },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment