WIP: trade-bot: detect and remove mempool entries from ElectrumX "listunspent" results

This commit is contained in:
catbref 2020-07-29 20:48:06 +01:00
parent 7fd7104f46
commit 16581766c6

View File

@ -226,9 +226,13 @@ public class ElectrumX {
for (Object rawUnspent : (JSONArray) unspentJson) {
JSONObject unspent = (JSONObject) rawUnspent;
int height = ((Long) unspent.get("height")).intValue();
// We only want unspent outputs from confirmed transactions (and definitely not mempool duplicates with height 0)
if (height <= 0)
continue;
byte[] txHash = HashCode.fromString((String) unspent.get("tx_hash")).asBytes();
int outputIndex = ((Long) unspent.get("tx_pos")).intValue();
int height = ((Long) unspent.get("height")).intValue();
long value = (Long) unspent.get("value");
unspentOutputs.add(new UnspentOutput(txHash, outputIndex, height, value));