forked from Qortal/qortal
Include output addresses, if present, in BitcoinyTransaction
This commit is contained in:
parent
b07ad094c1
commit
456bb3ca63
@ -1,6 +1,7 @@
|
|||||||
package org.qortal.crosschain;
|
package org.qortal.crosschain;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
@ -46,16 +47,25 @@ public class BitcoinyTransaction {
|
|||||||
public static class Output {
|
public static class Output {
|
||||||
public final String scriptPubKey;
|
public final String scriptPubKey;
|
||||||
public final long value;
|
public final long value;
|
||||||
|
public final Set<String> addresses;
|
||||||
|
|
||||||
// For JAXB
|
// For JAXB
|
||||||
protected Output() {
|
protected Output() {
|
||||||
this.scriptPubKey = null;
|
this.scriptPubKey = null;
|
||||||
this.value = 0;
|
this.value = 0;
|
||||||
|
this.addresses = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Output(String scriptPubKey, long value) {
|
public Output(String scriptPubKey, long value) {
|
||||||
this.scriptPubKey = scriptPubKey;
|
this.scriptPubKey = scriptPubKey;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
this.addresses = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Output(String scriptPubKey, long value, Set<String> addresses) {
|
||||||
|
this.scriptPubKey = scriptPubKey;
|
||||||
|
this.value = value;
|
||||||
|
this.addresses = addresses;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -329,7 +329,16 @@ public class ElectrumX extends BitcoinyBlockchainProvider {
|
|||||||
String scriptPubKey = (String) ((JSONObject) outputJson.get("scriptPubKey")).get("hex");
|
String scriptPubKey = (String) ((JSONObject) outputJson.get("scriptPubKey")).get("hex");
|
||||||
long value = (long) (((Double) outputJson.get("value")) * 1e8);
|
long value = (long) (((Double) outputJson.get("value")) * 1e8);
|
||||||
|
|
||||||
outputs.add(new BitcoinyTransaction.Output(scriptPubKey, value));
|
// address too, if present
|
||||||
|
Set<String> addresses = null;
|
||||||
|
Object addressesObj = ((JSONObject) outputJson.get("scriptPubKey")).get("addresses");
|
||||||
|
if (addressesObj instanceof JSONArray) {
|
||||||
|
addresses = new HashSet<>();
|
||||||
|
for (Object addressObj : (JSONArray) addressesObj)
|
||||||
|
addresses.add((String) addressObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
outputs.add(new BitcoinyTransaction.Output(scriptPubKey, value, addresses));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new BitcoinyTransaction(txHash, size, locktime, timestamp, inputs, outputs);
|
return new BitcoinyTransaction(txHash, size, locktime, timestamp, inputs, outputs);
|
||||||
|
Loading…
Reference in New Issue
Block a user