Show new mined transactions on the address page
This commit is contained in:
		
							parent
							
								
									395f47516a
								
							
						
					
					
						commit
						9b65fbd98c
					
				| @ -166,31 +166,8 @@ export class AddressComponent implements OnInit, OnDestroy { | |||||||
|       }); |       }); | ||||||
| 
 | 
 | ||||||
|     this.stateService.mempoolTransactions$ |     this.stateService.mempoolTransactions$ | ||||||
|       .subscribe((transaction) => { |       .subscribe(tx => { | ||||||
|         if (this.transactions.some((t) => t.txid === transaction.txid)) { |         this.addTransaction(tx); | ||||||
|           return; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         this.transactions.unshift(transaction); |  | ||||||
|         this.transactions = this.transactions.slice(); |  | ||||||
|         this.txCount++; |  | ||||||
| 
 |  | ||||||
|         if (transaction.vout.some((vout) => vout.scriptpubkey_address === this.address.address)) { |  | ||||||
|           this.audioService.playSound('cha-ching'); |  | ||||||
|         } else { |  | ||||||
|           this.audioService.playSound('chime'); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         transaction.vin.forEach((vin) => { |  | ||||||
|           if (vin.prevout.scriptpubkey_address === this.address.address) { |  | ||||||
|             this.sent += vin.prevout.value; |  | ||||||
|           } |  | ||||||
|         }); |  | ||||||
|         transaction.vout.forEach((vout) => { |  | ||||||
|           if (vout.scriptpubkey_address === this.address.address) { |  | ||||||
|             this.received += vout.value; |  | ||||||
|           } |  | ||||||
|         }); |  | ||||||
|       }); |       }); | ||||||
| 
 | 
 | ||||||
|     this.stateService.blockTransactions$ |     this.stateService.blockTransactions$ | ||||||
| @ -200,12 +177,47 @@ export class AddressComponent implements OnInit, OnDestroy { | |||||||
|           tx.status = transaction.status; |           tx.status = transaction.status; | ||||||
|           this.transactions = this.transactions.slice(); |           this.transactions = this.transactions.slice(); | ||||||
|           this.audioService.playSound('magic'); |           this.audioService.playSound('magic'); | ||||||
|  |         } else { | ||||||
|  |           if (this.addTransaction(transaction, false)) { | ||||||
|  |             this.audioService.playSound('magic'); | ||||||
|  |           } | ||||||
|         } |         } | ||||||
|         this.totalConfirmedTxCount++; |         this.totalConfirmedTxCount++; | ||||||
|         this.loadedConfirmedTxCount++; |         this.loadedConfirmedTxCount++; | ||||||
|       }); |       }); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   addTransaction(transaction: Transaction, playSound: boolean = true): boolean { | ||||||
|  |     if (this.transactions.some((t) => t.txid === transaction.txid)) { | ||||||
|  |       return false; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     this.transactions.unshift(transaction); | ||||||
|  |     this.transactions = this.transactions.slice(); | ||||||
|  |     this.txCount++; | ||||||
|  | 
 | ||||||
|  |     if (playSound) { | ||||||
|  |       if (transaction.vout.some((vout) => vout?.scriptpubkey_address === this.address.address)) { | ||||||
|  |         this.audioService.playSound('cha-ching'); | ||||||
|  |       } else { | ||||||
|  |         this.audioService.playSound('chime'); | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     transaction.vin.forEach((vin) => { | ||||||
|  |       if (vin?.prevout?.scriptpubkey_address === this.address.address) { | ||||||
|  |         this.sent += vin.prevout.value; | ||||||
|  |       } | ||||||
|  |     }); | ||||||
|  |     transaction.vout.forEach((vout) => { | ||||||
|  |       if (vout?.scriptpubkey_address === this.address.address) { | ||||||
|  |         this.received += vout.value; | ||||||
|  |       } | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  |     return true; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   loadMore() { |   loadMore() { | ||||||
|     if (this.isLoadingTransactions || !this.totalConfirmedTxCount || this.loadedConfirmedTxCount >= this.totalConfirmedTxCount) { |     if (this.isLoadingTransactions || !this.totalConfirmedTxCount || this.loadedConfirmedTxCount >= this.totalConfirmedTxCount) { | ||||||
|       return; |       return; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user