Commit 50517ad6 authored by dev0tion's avatar dev0tion

Show unused address

parent eec7ee54
...@@ -85,6 +85,7 @@ export class LoginComponent implements OnInit { ...@@ -85,6 +85,7 @@ export class LoginComponent implements OnInit {
console.log(response); console.log(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.setCurrentWalletName(walletLoad.name)
this.router.navigate(['/wallet']); this.router.navigate(['/wallet']);
} }
}, },
......
export class WalletInfo {
constructor(walletName: string, coinType: number, accountName: string) {
this.walletName = walletName;
this.coinType = coinType;
this.accountName = accountName;
}
public walletName: string;
public coinType: number;
public accountName: string;
}
...@@ -6,7 +6,7 @@ export class WalletLoad { ...@@ -6,7 +6,7 @@ export class WalletLoad {
this.name = name; this.name = name;
} }
private password: string; public password: string;
private folderPath: string; public folderPath: string;
private name: string; public name: string;
} }
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Http, Headers, Response } from '@angular/http'; import { Http, Headers, Response, RequestOptions, URLSearchParams} from '@angular/http';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch'; import 'rxjs/add/operator/catch';
...@@ -7,6 +7,7 @@ import 'rxjs/add/operator/catch'; ...@@ -7,6 +7,7 @@ import 'rxjs/add/operator/catch';
import { WalletCreation } from '../classes/wallet-creation'; import { WalletCreation } from '../classes/wallet-creation';
import { WalletRecovery } from '../classes/wallet-recovery'; import { WalletRecovery } from '../classes/wallet-recovery';
import { WalletLoad } from '../classes/wallet-load'; import { WalletLoad } from '../classes/wallet-load';
import { WalletInfo } from '../classes/wallet-info';
import { Mnemonic } from '../classes/mnemonic'; import { Mnemonic } from '../classes/mnemonic';
/** /**
...@@ -87,9 +88,13 @@ export class ApiService { ...@@ -87,9 +88,13 @@ export class ApiService {
/** /**
* Get unused receive addresses for a certain wallet from the API. * Get unused receive addresses for a certain wallet from the API.
*/ */
getUnusedReceiveAddresses(): Observable<any> { getUnusedReceiveAddress(data: WalletInfo): Observable<any> {
let params: URLSearchParams = new URLSearchParams();
params.set('walletName', data.walletName);
params.set('coinType', data.coinType.toString());
params.set('accountName', data.accountName);
return this.http return this.http
.get(this.mockApiUrl + '/wallet/receive') .get(this.webApiUrl + '/wallet/address', new RequestOptions({headers: this.headers, search: params}))
.map((response: Response) => response); .map((response: Response) => response);
} }
} }
...@@ -2,20 +2,14 @@ ...@@ -2,20 +2,14 @@
<h1>Receive</h1> <h1>Receive</h1>
<div> <div>
<div> <div>
<table *ngIf="addresses"> <table *ngIf="address">
<thead> <thead>
<th>Unused Receive Addresses: </th> <th>Receive address: </th>
</thead> </thead>
<tr *ngFor="let address of addresses"> <tr>
<td>{{ address }}</td> <td>{{ address }}</td>
</tr> </tr>
</table> </table>
</div> </div>
</div> </div>
<div>
<label>Used Receive Addresses</label>
</div>
<div>
<label>Change Addresses</label>
</div>
</div> </div>
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ApiService } from '../../shared/services/api.service' import { ApiService } from '../../shared/services/api.service';
import { WalletInfo } from '../../shared/classes/wallet-info';
@Component({ @Component({
selector: 'receive-component', selector: 'receive-component',
...@@ -11,19 +13,21 @@ import { ApiService } from '../../shared/services/api.service' ...@@ -11,19 +13,21 @@ import { ApiService } from '../../shared/services/api.service'
export class ReceiveComponent { export class ReceiveComponent {
constructor(private apiService: ApiService) {} constructor(private apiService: ApiService) {}
private addresses: any; private address: any;
private errorMessage: string; private errorMessage: string;
private walletInfo: WalletInfo;
ngOnInit() { ngOnInit() {
this.getUnusedReceiveAddresses(); this.getUnusedReceiveAddresses();
} }
private getUnusedReceiveAddresses() { private getUnusedReceiveAddresses() {
this.apiService.getUnusedReceiveAddresses() this.walletInfo = new WalletInfo("Test", 0, "Test")
this.apiService.getUnusedReceiveAddress(this.walletInfo)
.subscribe( .subscribe(
response => { response => {
if (response.status >= 200 && response.status < 400) { if (response.status >= 200 && response.status < 400) {
this.addresses = response.json().addresses; this.address = response.json();
} }
}, },
error => { error => {
......
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