Confirmed address transactions fix. QR Code fix. (take 2)
This commit is contained in:
parent
37166e230d
commit
23a61a37fd
@ -178,6 +178,15 @@ class WebsocketHandler {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (foundTransactions.length) {
|
if (foundTransactions.length) {
|
||||||
|
foundTransactions.forEach((tx) => {
|
||||||
|
tx.status = {
|
||||||
|
confirmed: true,
|
||||||
|
block_height: block.height,
|
||||||
|
block_hash: block.id,
|
||||||
|
block_time: block.timestamp,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
response['address-block-transactions'] = foundTransactions;
|
response['address-block-transactions'] = foundTransactions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,29 +35,16 @@ export class AddressComponent implements OnInit, OnDestroy {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.websocketService.want(['blocks', 'stats', 'mempool-blocks']);
|
this.websocketService.want(['blocks', 'stats', 'mempool-blocks']);
|
||||||
|
|
||||||
this.route.paramMap.pipe(
|
this.route.paramMap
|
||||||
switchMap((params: ParamMap) => {
|
.subscribe((params: ParamMap) => {
|
||||||
this.error = undefined;
|
this.error = undefined;
|
||||||
this.isLoadingAddress = true;
|
this.isLoadingAddress = true;
|
||||||
this.isLoadingTransactions = true;
|
this.isLoadingTransactions = true;
|
||||||
this.transactions = null;
|
this.transactions = null;
|
||||||
document.body.scrollTo(0, 0);
|
document.body.scrollTo(0, 0);
|
||||||
this.addressString = params.get('id') || '';
|
this.addressString = params.get('id') || '';
|
||||||
return this.electrsApiService.getAddress$(this.addressString);
|
this.loadAddress(this.addressString);
|
||||||
})
|
});
|
||||||
)
|
|
||||||
.subscribe((address) => {
|
|
||||||
this.address = address;
|
|
||||||
this.updateChainStats();
|
|
||||||
this.websocketService.startTrackAddress(address.address);
|
|
||||||
this.isLoadingAddress = false;
|
|
||||||
this.reloadAddressTransactions(address.address);
|
|
||||||
},
|
|
||||||
(error) => {
|
|
||||||
console.log(error);
|
|
||||||
this.error = error;
|
|
||||||
this.isLoadingAddress = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.stateService.mempoolTransactions$
|
this.stateService.mempoolTransactions$
|
||||||
.subscribe((transaction) => {
|
.subscribe((transaction) => {
|
||||||
@ -100,12 +87,27 @@ export class AddressComponent implements OnInit, OnDestroy {
|
|||||||
this.stateService.isOffline$
|
this.stateService.isOffline$
|
||||||
.subscribe((state) => {
|
.subscribe((state) => {
|
||||||
if (!state && this.transactions && this.transactions.length) {
|
if (!state && this.transactions && this.transactions.length) {
|
||||||
this.isLoadingTransactions = true;
|
this.loadAddress(this.addressString);
|
||||||
this.reloadAddressTransactions(this.address.address);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadAddress(addressStr?: string) {
|
||||||
|
this.electrsApiService.getAddress$(addressStr)
|
||||||
|
.subscribe((address) => {
|
||||||
|
this.address = address;
|
||||||
|
this.updateChainStats();
|
||||||
|
this.websocketService.startTrackAddress(address.address);
|
||||||
|
this.isLoadingAddress = false;
|
||||||
|
this.reloadAddressTransactions(address.address);
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
console.log(error);
|
||||||
|
this.error = error;
|
||||||
|
this.isLoadingAddress = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
updateChainStats() {
|
updateChainStats() {
|
||||||
this.receieved = this.address.chain_stats.funded_txo_sum + this.address.mempool_stats.funded_txo_sum;
|
this.receieved = this.address.chain_stats.funded_txo_sum + this.address.mempool_stats.funded_txo_sum;
|
||||||
this.sent = this.address.chain_stats.spent_txo_sum + this.address.mempool_stats.spent_txo_sum;
|
this.sent = this.address.chain_stats.spent_txo_sum + this.address.mempool_stats.spent_txo_sum;
|
||||||
@ -118,7 +120,6 @@ export class AddressComponent implements OnInit, OnDestroy {
|
|||||||
this.electrsApiService.getAddressTransactions$(address)
|
this.electrsApiService.getAddressTransactions$(address)
|
||||||
.subscribe((transactions: any) => {
|
.subscribe((transactions: any) => {
|
||||||
this.transactions = transactions;
|
this.transactions = transactions;
|
||||||
this.updateChainStats();
|
|
||||||
this.isLoadingTransactions = false;
|
this.isLoadingTransactions = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ export class QrcodeComponent implements AfterViewInit {
|
|||||||
address.toUpperCase();
|
address.toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
QRCode.toCanvas(this.canvas.nativeElement, address, opts, (error: any) => {
|
QRCode.toCanvas(this.canvas.nativeElement, 'bitcoin:' + address, opts, (error: any) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
@ -27,18 +27,6 @@ export class WebsocketService {
|
|||||||
startSubscription() {
|
startSubscription() {
|
||||||
this.websocketSubject.next({'action': 'init'});
|
this.websocketSubject.next({'action': 'init'});
|
||||||
this.websocketSubject
|
this.websocketSubject
|
||||||
.pipe(
|
|
||||||
retryWhen((errors: any) => errors
|
|
||||||
.pipe(
|
|
||||||
tap(() => {
|
|
||||||
this.goneOffline = true;
|
|
||||||
this.websocketSubject.next({'action': 'init'});
|
|
||||||
this.stateService.isOffline$.next(true);
|
|
||||||
}),
|
|
||||||
delay(5000),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.subscribe((response: WebsocketResponse) => {
|
.subscribe((response: WebsocketResponse) => {
|
||||||
if (response.blocks && response.blocks.length) {
|
if (response.blocks && response.blocks.length) {
|
||||||
const blocks = response.blocks;
|
const blocks = response.blocks;
|
||||||
@ -110,6 +98,7 @@ export class WebsocketService {
|
|||||||
(err: Error) => {
|
(err: Error) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
this.goneOffline = true;
|
this.goneOffline = true;
|
||||||
|
this.stateService.isOffline$.next(true);
|
||||||
console.log('Error, retrying in 10 sec');
|
console.log('Error, retrying in 10 sec');
|
||||||
window.setTimeout(() => this.startSubscription(), 10000);
|
window.setTimeout(() => this.startSubscription(), 10000);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user