Commit 50517ad6 authored by dev0tion's avatar dev0tion

Show unused address

parent eec7ee54
......@@ -85,6 +85,7 @@ export class LoginComponent implements OnInit {
console.log(response);
if (response.status >= 200 && response.status < 400) {
let responseMessage = response.json();
this.globalService.setCurrentWalletName(walletLoad.name)
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 {
this.name = name;
}
private password: string;
private folderPath: string;
private name: string;
public password: string;
public folderPath: string;
public name: string;
}
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 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
......@@ -7,6 +7,7 @@ import 'rxjs/add/operator/catch';
import { WalletCreation } from '../classes/wallet-creation';
import { WalletRecovery } from '../classes/wallet-recovery';
import { WalletLoad } from '../classes/wallet-load';
import { WalletInfo } from '../classes/wallet-info';
import { Mnemonic } from '../classes/mnemonic';
/**
......@@ -87,9 +88,13 @@ export class ApiService {
/**
* 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
.get(this.mockApiUrl + '/wallet/receive')
.get(this.webApiUrl + '/wallet/address', new RequestOptions({headers: this.headers, search: params}))
.map((response: Response) => response);
}
}
......@@ -2,20 +2,14 @@
<h1>Receive</h1>
<div>
<div>
<table *ngIf="addresses">
<table *ngIf="address">
<thead>
<th>Unused Receive Addresses: </th>
<th>Receive address: </th>
</thead>
<tr *ngFor="let address of addresses">
<tr>
<td>{{ address }}</td>
</tr>
</table>
</div>
</div>
<div>
<label>Used Receive Addresses</label>
</div>
<div>
<label>Change Addresses</label>
</div>
</div>
\ No newline at end of file
</div>
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({
selector: 'receive-component',
......@@ -11,19 +13,21 @@ import { ApiService } from '../../shared/services/api.service'
export class ReceiveComponent {
constructor(private apiService: ApiService) {}
private addresses: any;
private address: any;
private errorMessage: string;
private walletInfo: WalletInfo;
ngOnInit() {
this.getUnusedReceiveAddresses();
}
private getUnusedReceiveAddresses() {
this.apiService.getUnusedReceiveAddresses()
this.walletInfo = new WalletInfo("Test", 0, "Test")
this.apiService.getUnusedReceiveAddress(this.walletInfo)
.subscribe(
response => {
if (response.status >= 200 && response.status < 400) {
this.addresses = response.json().addresses;
this.address = response.json();
}
},
error => {
......@@ -34,4 +38,4 @@ export class ReceiveComponent {
}
);
}
}
\ No newline at end of file
}
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