Added defensiveness in convertToSimpleTransaction()

This commit is contained in:
CalDescent 2022-02-08 18:24:42 +00:00
parent 9630625449
commit d1f24d45da

View File

@ -447,6 +447,7 @@ public abstract class Bitcoiny implements ForeignBlockchain {
List<String> senders = t2.outputs.get(input.outputVout).addresses; List<String> senders = t2.outputs.get(input.outputVout).addresses;
long inputAmount = t2.outputs.get(input.outputVout).value; long inputAmount = t2.outputs.get(input.outputVout).value;
totalInputAmount += inputAmount; totalInputAmount += inputAmount;
if (senders != null) {
for (String sender : senders) { for (String sender : senders) {
boolean addressInWallet = false; boolean addressInWallet = false;
if (keySet.contains(sender)) { if (keySet.contains(sender)) {
@ -455,12 +456,14 @@ public abstract class Bitcoiny implements ForeignBlockchain {
} }
inputs.add(new SimpleTransaction.Input(sender, inputAmount, addressInWallet)); inputs.add(new SimpleTransaction.Input(sender, inputAmount, addressInWallet));
} }
}
} catch (ForeignBlockchainException e) { } catch (ForeignBlockchainException e) {
LOGGER.trace("Failed to retrieve transaction information {}", input.outputTxHash); LOGGER.trace("Failed to retrieve transaction information {}", input.outputTxHash);
} }
} }
if (t.outputs != null && !t.outputs.isEmpty()) { if (t.outputs != null && !t.outputs.isEmpty()) {
for (BitcoinyTransaction.Output output : t.outputs) { for (BitcoinyTransaction.Output output : t.outputs) {
if (output.addresses != null) {
for (String address : output.addresses) { for (String address : output.addresses) {
boolean addressInWallet = false; boolean addressInWallet = false;
if (keySet.contains(address)) { if (keySet.contains(address)) {
@ -473,6 +476,7 @@ public abstract class Bitcoiny implements ForeignBlockchain {
} }
outputs.add(new SimpleTransaction.Output(address, output.value, addressInWallet)); outputs.add(new SimpleTransaction.Output(address, output.value, addressInWallet));
} }
}
totalOutputAmount += output.value; totalOutputAmount += output.value;
} }
} }