UTXO spent tracking refactor

refs #1301
This commit is contained in:
softsimon
2022-03-07 19:45:09 +01:00
parent 09e3791cee
commit 6f3443faba
6 changed files with 59 additions and 44 deletions

View File

@@ -332,11 +332,18 @@ class WebsocketHandler {
}
if (client['track-tx']) {
const utxoSpent = newTransactions.some((tx) => {
return tx.vin.some((vin) => vin.txid === client['track-tx']);
});
if (utxoSpent) {
response['utxoSpent'] = true;
const outspends: object = {};
newTransactions.forEach((tx) => tx.vin.forEach((vin, i) => {
if (vin.txid === client['track-tx']) {
outspends[vin.vout] = {
vin: i,
txid: tx.txid,
};
}
}));
if (Object.keys(outspends).length) {
response['utxoSpent'] = outspends;
}
if (rbfTransactions[client['track-tx']]) {
@@ -414,7 +421,6 @@ class WebsocketHandler {
}
if (client['track-tx'] && txIds.indexOf(client['track-tx']) > -1) {
client['track-tx'] = null;
response['txConfirmed'] = true;
}