forked from QORT/qortal
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Address info support for Litecoin
- Loading branch information
Showing
7 changed files
with
335 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/main/java/org/qortal/api/model/crosschain/AddressRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.qortal.api.model.crosschain; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
import javax.xml.bind.annotation.XmlAccessType; | ||
import javax.xml.bind.annotation.XmlAccessorType; | ||
|
||
@XmlAccessorType(XmlAccessType.FIELD) | ||
public class AddressRequest { | ||
|
||
@Schema(description = "Litecoin BIP32 extended public key", example = "tpub___________________________________________________________________________________________________________") | ||
public String xpub58; | ||
|
||
public AddressRequest() { | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package org.qortal.crosschain; | ||
|
||
import javax.xml.bind.annotation.XmlAccessType; | ||
import javax.xml.bind.annotation.XmlAccessorType; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Class AddressInfo | ||
*/ | ||
@XmlAccessorType(XmlAccessType.FIELD) | ||
public class AddressInfo { | ||
|
||
private String address; | ||
|
||
private List<Integer> path; | ||
|
||
private long value; | ||
|
||
private String pathAsString; | ||
|
||
private int transactionCount; | ||
|
||
public AddressInfo() { | ||
} | ||
|
||
public AddressInfo(String address, List<Integer> path, long value, String pathAsString, int transactionCount) { | ||
this.address = address; | ||
this.path = path; | ||
this.value = value; | ||
this.pathAsString = pathAsString; | ||
this.transactionCount = transactionCount; | ||
} | ||
|
||
public String getAddress() { | ||
return address; | ||
} | ||
|
||
public List<Integer> getPath() { | ||
return path; | ||
} | ||
|
||
public long getValue() { | ||
return value; | ||
} | ||
|
||
public String getPathAsString() { | ||
return pathAsString; | ||
} | ||
|
||
public int getTransactionCount() { | ||
return transactionCount; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
AddressInfo that = (AddressInfo) o; | ||
return value == that.value && transactionCount == that.transactionCount && Objects.equals(address, that.address) && Objects.equals(path, that.path) && Objects.equals(pathAsString, that.pathAsString); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(address, path, value, pathAsString, transactionCount); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "AddressInfo{" + | ||
"address='" + address + '\'' + | ||
", path=" + path + | ||
", value=" + value + | ||
", pathAsString='" + pathAsString + '\'' + | ||
", transactionCount=" + transactionCount + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.qortal.crosschain; | ||
|
||
/** | ||
* Class PathComparator | ||
*/ | ||
public class PathComparator implements java.util.Comparator<AddressInfo> { | ||
|
||
private int max; | ||
|
||
public PathComparator(int max) { | ||
this.max = max; | ||
} | ||
|
||
@Override | ||
public int compare(AddressInfo info1, AddressInfo info2) { | ||
return compareAtLevel(info1, info2, 0); | ||
} | ||
|
||
private int compareAtLevel(AddressInfo info1, AddressInfo info2, int level) { | ||
|
||
if( level < 0 ) return 0; | ||
|
||
int compareTo = info1.getPath().get(level).compareTo(info2.getPath().get(level)); | ||
|
||
if(compareTo != 0 || level == max) return compareTo; | ||
|
||
return compareAtLevel(info1, info2,level + 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.