mirror of
https://github.com/mempool/mempool.git
synced 2025-03-26 17:51:45 +01:00
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) {
|
||||
foundTransactions.forEach((tx) => {
|
||||
tx.status = {
|
||||
confirmed: true,
|
||||
block_height: block.height,
|
||||
block_hash: block.id,
|
||||
block_time: block.timestamp,
|
||||
};
|
||||
});
|
||||
|
||||
response['address-block-transactions'] = foundTransactions;
|
||||
}
|
||||
}
|
||||
|
@ -35,29 +35,16 @@ export class AddressComponent implements OnInit, OnDestroy {
|
||||
ngOnInit() {
|
||||
this.websocketService.want(['blocks', 'stats', 'mempool-blocks']);
|
||||
|
||||
this.route.paramMap.pipe(
|
||||
switchMap((params: ParamMap) => {
|
||||
this.route.paramMap
|
||||
.subscribe((params: ParamMap) => {
|
||||
this.error = undefined;
|
||||
this.isLoadingAddress = true;
|
||||
this.isLoadingTransactions = true;
|
||||
this.transactions = null;
|
||||
document.body.scrollTo(0, 0);
|
||||
this.addressString = params.get('id') || '';
|
||||
return this.electrsApiService.getAddress$(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.loadAddress(this.addressString);
|
||||
});
|
||||
|
||||
this.stateService.mempoolTransactions$
|
||||
.subscribe((transaction) => {
|
||||
@ -100,12 +87,27 @@ export class AddressComponent implements OnInit, OnDestroy {
|
||||
this.stateService.isOffline$
|
||||
.subscribe((state) => {
|
||||
if (!state && this.transactions && this.transactions.length) {
|
||||
this.isLoadingTransactions = true;
|
||||
this.reloadAddressTransactions(this.address.address);
|
||||
this.loadAddress(this.addressString);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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() {
|
||||
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;
|
||||
@ -118,7 +120,6 @@ export class AddressComponent implements OnInit, OnDestroy {
|
||||
this.electrsApiService.getAddressTransactions$(address)
|
||||
.subscribe((transactions: any) => {
|
||||
this.transactions = transactions;
|
||||
this.updateChainStats();
|
||||
this.isLoadingTransactions = false;
|
||||
});
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ export class QrcodeComponent implements AfterViewInit {
|
||||
address.toUpperCase();
|
||||
}
|
||||
|
||||
QRCode.toCanvas(this.canvas.nativeElement, address, opts, (error: any) => {
|
||||
QRCode.toCanvas(this.canvas.nativeElement, 'bitcoin:' + address, opts, (error: any) => {
|
||||
if (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
@ -27,18 +27,6 @@ export class WebsocketService {
|
||||
startSubscription() {
|
||||
this.websocketSubject.next({'action': 'init'});
|
||||
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) => {
|
||||
if (response.blocks && response.blocks.length) {
|
||||
const blocks = response.blocks;
|
||||
@ -110,6 +98,7 @@ export class WebsocketService {
|
||||
(err: Error) => {
|
||||
console.log(err);
|
||||
this.goneOffline = true;
|
||||
this.stateService.isOffline$.next(true);
|
||||
console.log('Error, retrying in 10 sec');
|
||||
window.setTimeout(() => this.startSubscription(), 10000);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user