Revert "Ignoring test cases intended for Bitcoiny coins"

This reverts commit e287fa0ebe1996e1d22d094d3a9a7b185aa59008.
This commit is contained in:
kennycud 2023-11-29 17:51:07 -08:00
parent 3c307f15b3
commit 87a7b9df08
9 changed files with 6 additions and 89 deletions

View File

@ -21,18 +21,15 @@ public class AddressInfo {
private int transactionCount;
private boolean isSpendable;
public AddressInfo() {
}
public AddressInfo(String address, List<Integer> path, long value, String pathAsString, int transactionCount, boolean isSpendable) {
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;
this.isSpendable = isSpendable;
}
public String getAddress() {
@ -55,21 +52,17 @@ public class AddressInfo {
return transactionCount;
}
public boolean isSpendable() {
return isSpendable;
}
@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 && isSpendable == that.isSpendable && address.equals(that.address) && path.equals(that.path) && pathAsString.equals(that.pathAsString);
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, isSpendable);
return Objects.hash(address, path, value, pathAsString, transactionCount);
}
@Override
@ -80,7 +73,6 @@ public class AddressInfo {
", value=" + value +
", pathAsString='" + pathAsString + '\'' +
", transactionCount=" + transactionCount +
", isSpendable=" + isSpendable +
'}';
}
}

View File

@ -335,30 +335,6 @@ public abstract class Bitcoiny implements ForeignBlockchain {
}
}
/**
* Get Spending Candidate Addresses
*
* @param key58 public master key
* @return the addresses this instance will look at when building a spend
* @throws ForeignBlockchainException
*/
public List<String> getSpendingCandidateAddresses(String key58) throws ForeignBlockchainException {
Wallet wallet = Wallet.fromWatchingKeyB58(this.params, key58, DeterministicHierarchy.BIP32_STANDARDISATION_TIME_SECS);
wallet.setUTXOProvider(new WalletAwareUTXOProvider(this, wallet));
// from Wallet.getStoredOutputsFromUTXOProvider()
List<ECKey> spendingKeys = wallet.getImportedKeys();
spendingKeys.addAll(wallet.getActiveKeyChain().getLeafKeys());
List<String> spendingCandidateAddresses
= spendingKeys.stream()
.map(spendingKey -> Address.fromKey(this.params, spendingKey, ScriptType.P2PKH ).toString())
.collect(Collectors.toList());
return spendingCandidateAddresses;
}
/**
* Returns bitcoinj transaction sending <tt>amount</tt> to <tt>recipient</tt> using default fees.
*
@ -502,10 +478,8 @@ public abstract class Bitcoiny implements ForeignBlockchain {
public List<AddressInfo> getWalletAddressInfos(String key58) throws ForeignBlockchainException {
List<AddressInfo> infos = new ArrayList<>();
List<String> candidates = this.getSpendingCandidateAddresses(key58);
for(DeterministicKey key : getWalletKeys(key58)) {
infos.add(buildAddressInfo(key, candidates));
infos.add(buildAddressInfo(key));
}
return infos.stream()
@ -513,7 +487,7 @@ public abstract class Bitcoiny implements ForeignBlockchain {
.collect(Collectors.toList());
}
public AddressInfo buildAddressInfo(DeterministicKey key, List<String> candidates) throws ForeignBlockchainException {
public AddressInfo buildAddressInfo(DeterministicKey key) throws ForeignBlockchainException {
Address address = Address.fromKey(this.params, key, ScriptType.P2PKH);
@ -524,8 +498,7 @@ public abstract class Bitcoiny implements ForeignBlockchain {
toIntegerList( key.getPath()),
summingUnspentOutputs(address.toString()),
key.getPathAsString(),
transactionCount,
candidates.contains(address.toString()));
transactionCount);
}
private static List<Integer> toIntegerList(ImmutableList<ChildNumber> path) {

View File

@ -32,11 +32,6 @@ public class BitcoinTests extends BitcoinyTests {
return "tprv8ZgxMBicQKsPdahhFSrCdvC1bsWyzHHZfTneTVqUXN6s1wEtZLwAkZXzFP6TYLg2aQMecZLXLre5bTVGajEB55L1HYJcawpdFG66STVAWPJ";
}
@Override
protected String getDeterministicPublicKey58() {
return "tpubDCxs3oB9X7XJYkQGU6gfPwd4h3NEiBGA8mfD1aEbZiG5x3BTH4cJqszDP6dtoHPPjZNEj5jPxuSWHCvjg9AHz4dNg6w5vQhv1B8KwWKpxoz";
}
@Override
protected String getRecipient() {
return "2N8WCg52ULCtDSMjkgVTm5mtPdCsUptkHWE";

View File

@ -31,8 +31,6 @@ public abstract class BitcoinyTests extends Common {
protected abstract String getDeterministicKey58();
protected abstract String getDeterministicPublicKey58();
protected abstract String getRecipient();
@Before
@ -164,16 +162,4 @@ public abstract class BitcoinyTests extends Common {
System.out.println( "address infos ..." );
addressInfos.forEach( System.out::println );
}
@Test
public void testWalletSpendingCandidateAddresses() throws ForeignBlockchainException {
String xpub58 = getDeterministicPublicKey58();
List<String> candidateAddresses = this.bitcoiny.getSpendingCandidateAddresses(xpub58);
System.out.println("candidate address count = " + candidateAddresses.size() );
System.out.println( "candidate addresses ..." );
candidateAddresses.forEach( System.out::println );
}
}

View File

@ -32,11 +32,6 @@ public class DigibyteTests extends BitcoinyTests {
return "xpub661MyMwAqRbcEnabTLX5uebYcsE3uG5y7ve9jn1VK8iY1MaU3YLoLJEe8sTu2YVav5Zka5qf2dmMssfxmXJTqZnazZL2kL7M2tNKwEoC34R";
}
@Override
protected String getDeterministicPublicKey58() {
return "xpub661MyMwAqRbcEnabTLX5uebYcsE3uG5y7ve9jn1VK8iY1MaU3YLoLJEe8sTu2YVav5Zka5qf2dmMssfxmXJTqZnazZL2kL7M2tNKwEoC34R";
}
@Override
protected String getRecipient() {
return "2N8WCg52ULCtDSMjkgVTm5mtPdCsUptkHWE";

View File

@ -32,11 +32,6 @@ public class DogecoinTests extends BitcoinyTests {
return "dgpv51eADS3spNJh9drNeW1Tc1P9z2LyaQRXPBortsq6yice1k47C2u2Prvgxycr2ihNBWzKZ2LthcBBGiYkWZ69KUTVkcLVbnjq7pD8mnApEru";
}
@Override
protected String getDeterministicPublicKey58() {
return "dgub8rqf3khHiPeYE3cNn3Y4DQQ411nAnFpuSUPt5k5GJZQsydsTLkaf4onaWn4N8pHvrV3oNMEATKoPGTFZwm2Uhh7Dy9gYwA7rkSv6oLofbag";
}
@Override
protected String getRecipient() {
return null;

View File

@ -32,11 +32,6 @@ public class LitecoinTests extends BitcoinyTests {
return "tprv8ZgxMBicQKsPdahhFSrCdvC1bsWyzHHZfTneTVqUXN6s1wEtZLwAkZXzFP6TYLg2aQMecZLXLre5bTVGajEB55L1HYJcawpdFG66STVAWPJ";
}
@Override
protected String getDeterministicPublicKey58() {
return "tpubDCxs3oB9X7XJYkQGU6gfPwd4h3NEiBGA8mfD1aEbZiG5x3BTH4cJqszDP6dtoHPPjZNEj5jPxuSWHCvjg9AHz4dNg6w5vQhv1B8KwWKpxoz";
}
@Override
protected String getRecipient() {
return "2N8WCg52ULCtDSMjkgVTm5mtPdCsUptkHWE";

View File

@ -43,11 +43,6 @@ public class PirateChainTests extends BitcoinyTests {
return null;
}
@Override
protected String getDeterministicPublicKey58() {
return null;
}
@Override
protected String getRecipient() {
return null;
@ -255,8 +250,4 @@ public class PirateChainTests extends BitcoinyTests {
@Test
@Ignore(value = "Needs adapting for Pirate Chain")
public void testWalletAddressInfos() throws ForeignBlockchainException {}
@Test
@Ignore(value = "Needs adapting for Pirate Chain")
public void testWalletSpendingCandidateAddresses() throws ForeignBlockchainException {}
}

View File

@ -32,11 +32,6 @@ public class RavencoinTests extends BitcoinyTests {
return "xpub661MyMwAqRbcEt3Ge1wNmkagyb1J7yTQu4Kquvy77Ycg2iPoh7Urg8s9Jdwp7YmrqGkDKJpUVjsZXSSsQgmAVUC17ZVQQeoWMzm7vDTt1y7";
}
@Override
protected String getDeterministicPublicKey58() {
return "xpub661MyMwAqRbcEt3Ge1wNmkagyb1J7yTQu4Kquvy77Ycg2iPoh7Urg8s9Jdwp7YmrqGkDKJpUVjsZXSSsQgmAVUC17ZVQQeoWMzm7vDTt1y7";
}
@Override
protected String getRecipient() {
return null;