Fix address tracking issues.
This commit is contained in:
parent
30d2c5de27
commit
7e07e2cd8a
@ -164,7 +164,26 @@ class WebsocketHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send all new incoming transactions related to tracked asset
|
if (client['track-address']) {
|
||||||
|
const foundTransactions: TransactionExtended[] = [];
|
||||||
|
|
||||||
|
newTransactions.forEach((tx) => {
|
||||||
|
const someVin = tx.vin.some((vin) => !!vin.prevout && vin.prevout.scriptpubkey_address === client['track-address']);
|
||||||
|
if (someVin) {
|
||||||
|
foundTransactions.push(tx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const someVout = tx.vout.some((vout) => vout.scriptpubkey_address === client['track-address']);
|
||||||
|
if (someVout) {
|
||||||
|
foundTransactions.push(tx);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (foundTransactions.length) {
|
||||||
|
response['address-transactions'] = foundTransactions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (client['track-asset']) {
|
if (client['track-asset']) {
|
||||||
const foundTransactions: TransactionExtended[] = [];
|
const foundTransactions: TransactionExtended[] = [];
|
||||||
|
|
||||||
@ -190,7 +209,7 @@ class WebsocketHandler {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (foundTransactions.length) {
|
if (foundTransactions.length) {
|
||||||
response['asset-transactions'] = foundTransactions;
|
response['address-transactions'] = foundTransactions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,7 +250,7 @@ class WebsocketHandler {
|
|||||||
foundTransactions.push(tx);
|
foundTransactions.push(tx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (tx.vout && tx.vout.some((vout) => !!vout.asset && vout.asset === client['track-asset'])) {
|
if (tx.vout && tx.vout.some((vout) => vout.scriptpubkey_address === client['track-address'])) {
|
||||||
foundTransactions.push(tx);
|
foundTransactions.push(tx);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -246,7 +265,7 @@ class WebsocketHandler {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
response['asset-block-transactions'] = foundTransactions;
|
response['block-transactions'] = foundTransactions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,7 +302,7 @@ class WebsocketHandler {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
response['address-block-transactions'] = foundTransactions;
|
response['block-transactions'] = foundTransactions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@
|
|||||||
<br><br>
|
<br><br>
|
||||||
<span class="text-small">
|
<span class="text-small">
|
||||||
Push transactions related to address: <span class="code">{{ '{' }} 'track-address': '3PbJ...bF9B' {{ '}' }}</span>
|
Push transactions related to address: <span class="code">{{ '{' }} 'track-address': '3PbJ...bF9B' {{ '}' }}</span>
|
||||||
to receive all new transactions containing that address as input or output. Returns an array of transactions. 'address-transactions' for new mempool transactions and 'address-block-transactions' for new block confirmed transactions.
|
to receive all new transactions containing that address as input or output. Returns an array of transactions. 'address-transactions' for new mempool transactions and 'block-transactions' for new block confirmed transactions.
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -142,7 +142,7 @@ export class AssetComponent implements OnInit, OnDestroy {
|
|||||||
this.isLoadingAsset = false;
|
this.isLoadingAsset = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.stateService.assetTransactions$
|
this.stateService.mempoolTransactions$
|
||||||
.subscribe((transaction) => {
|
.subscribe((transaction) => {
|
||||||
if (this.transactions.some((t) => t.txid === transaction.txid)) {
|
if (this.transactions.some((t) => t.txid === transaction.txid)) {
|
||||||
return;
|
return;
|
||||||
|
@ -7,8 +7,6 @@ import { WebsocketService } from 'src/app/services/websocket.service';
|
|||||||
styleUrls: ['./start.component.scss']
|
styleUrls: ['./start.component.scss']
|
||||||
})
|
})
|
||||||
export class StartComponent implements OnInit {
|
export class StartComponent implements OnInit {
|
||||||
view: 'blocks' | 'transactions' = 'blocks';
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private websocketService: WebsocketService,
|
private websocketService: WebsocketService,
|
||||||
) { }
|
) { }
|
||||||
|
@ -30,8 +30,6 @@ export class TransactionComponent implements OnInit, OnDestroy {
|
|||||||
transactionTime = -1;
|
transactionTime = -1;
|
||||||
subscription: Subscription;
|
subscription: Subscription;
|
||||||
|
|
||||||
rightPosition = 0;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private electrsApiService: ElectrsApiService,
|
private electrsApiService: ElectrsApiService,
|
||||||
|
@ -25,7 +25,6 @@ export class StateService {
|
|||||||
mempoolBlocks$ = new ReplaySubject<MempoolBlock[]>(1);
|
mempoolBlocks$ = new ReplaySubject<MempoolBlock[]>(1);
|
||||||
txConfirmed$ = new Subject<Block>();
|
txConfirmed$ = new Subject<Block>();
|
||||||
mempoolTransactions$ = new Subject<Transaction>();
|
mempoolTransactions$ = new Subject<Transaction>();
|
||||||
assetTransactions$ = new Subject<Transaction>();
|
|
||||||
blockTransactions$ = new Subject<Transaction>();
|
blockTransactions$ = new Subject<Transaction>();
|
||||||
|
|
||||||
live2Chart$ = new Subject<OptimizedMempoolStats>();
|
live2Chart$ = new Subject<OptimizedMempoolStats>();
|
||||||
@ -33,7 +32,7 @@ export class StateService {
|
|||||||
viewFiat$ = new BehaviorSubject<boolean>(false);
|
viewFiat$ = new BehaviorSubject<boolean>(false);
|
||||||
connectionState$ = new BehaviorSubject<0 | 1 | 2>(2);
|
connectionState$ = new BehaviorSubject<0 | 1 | 2>(2);
|
||||||
|
|
||||||
markBlock$ = new Subject<MarkBlockState>();
|
markBlock$ = new ReplaySubject<MarkBlockState>();
|
||||||
keyNavigation$ = new Subject<KeyboardEvent>();
|
keyNavigation$ = new Subject<KeyboardEvent>();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -111,20 +111,8 @@ export class WebsocketService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response['address-block-transactions']) {
|
if (response['block-transactions']) {
|
||||||
response['address-block-transactions'].forEach((addressTransaction: Transaction) => {
|
response['block-transactions'].forEach((addressTransaction: Transaction) => {
|
||||||
this.stateService.blockTransactions$.next(addressTransaction);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response['asset-transactions']) {
|
|
||||||
response['asset-transactions'].forEach((assetTransaction: Transaction) => {
|
|
||||||
this.stateService.assetTransactions$.next(assetTransaction);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response['asset-block-transactions']) {
|
|
||||||
response['asset-block-transactions'].forEach((addressTransaction: Transaction) => {
|
|
||||||
this.stateService.blockTransactions$.next(addressTransaction);
|
this.stateService.blockTransactions$.next(addressTransaction);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user