From cb18f7c4c3b2e1061565e3c78597d90aa019224c Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 2 Jun 2020 11:05:02 +0200 Subject: [PATCH] blockchain to block rename for transaction in block --- ...Transaction.java => BlockTransaction.java} | 6 +++--- ...ionHash.java => BlockTransactionHash.java} | 12 +++++------ ...ex.java => BlockTransactionHashIndex.java} | 20 +++++++++---------- .../sparrowwallet/drongo/wallet/Wallet.java | 4 ++-- .../drongo/wallet/WalletNode.java | 14 ++++++------- 5 files changed, 28 insertions(+), 28 deletions(-) rename src/main/java/com/sparrowwallet/drongo/wallet/{BlockchainTransaction.java => BlockTransaction.java} (59%) rename src/main/java/com/sparrowwallet/drongo/wallet/{BlockchainTransactionHash.java => BlockTransactionHash.java} (77%) rename src/main/java/com/sparrowwallet/drongo/wallet/{BlockchainTransactionHashIndex.java => BlockTransactionHashIndex.java} (58%) diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/BlockchainTransaction.java b/src/main/java/com/sparrowwallet/drongo/wallet/BlockTransaction.java similarity index 59% rename from src/main/java/com/sparrowwallet/drongo/wallet/BlockchainTransaction.java rename to src/main/java/com/sparrowwallet/drongo/wallet/BlockTransaction.java index 65f644a..f11a220 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/BlockchainTransaction.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/BlockTransaction.java @@ -3,10 +3,10 @@ package com.sparrowwallet.drongo.wallet; import com.sparrowwallet.drongo.protocol.Sha256Hash; import com.sparrowwallet.drongo.protocol.Transaction; -public class BlockchainTransaction extends BlockchainTransactionHash implements Comparable { +public class BlockTransaction extends BlockTransactionHash implements Comparable { private final Transaction transaction; - public BlockchainTransaction(Sha256Hash hash, int height, Long fee, Transaction transaction) { + public BlockTransaction(Sha256Hash hash, int height, Long fee, Transaction transaction) { super(hash, height, fee); this.transaction = transaction; } @@ -16,7 +16,7 @@ public class BlockchainTransaction extends BlockchainTransactionHash implements } @Override - public int compareTo(BlockchainTransaction blockchainTransaction) { + public int compareTo(BlockTransaction blockchainTransaction) { return super.compareTo(blockchainTransaction); } } diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/BlockchainTransactionHash.java b/src/main/java/com/sparrowwallet/drongo/wallet/BlockTransactionHash.java similarity index 77% rename from src/main/java/com/sparrowwallet/drongo/wallet/BlockchainTransactionHash.java rename to src/main/java/com/sparrowwallet/drongo/wallet/BlockTransactionHash.java index 5d49575..2d189e0 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/BlockchainTransactionHash.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/BlockTransactionHash.java @@ -4,22 +4,22 @@ import com.sparrowwallet.drongo.protocol.Sha256Hash; import java.util.Objects; -public abstract class BlockchainTransactionHash { +public abstract class BlockTransactionHash { private final Sha256Hash hash; private final int height; private final Long fee; private String label; - public BlockchainTransactionHash(Sha256Hash hash) { + public BlockTransactionHash(Sha256Hash hash) { this(hash, 0, 0L); } - public BlockchainTransactionHash(Sha256Hash hash, int height) { + public BlockTransactionHash(Sha256Hash hash, int height) { this(hash, height, 0L); } - public BlockchainTransactionHash(Sha256Hash hash, int height, Long fee) { + public BlockTransactionHash(Sha256Hash hash, int height, Long fee) { this.hash = hash; this.height = height; this.fee = fee; @@ -58,7 +58,7 @@ public abstract class BlockchainTransactionHash { public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - BlockchainTransactionHash that = (BlockchainTransactionHash) o; + BlockTransactionHash that = (BlockTransactionHash) o; return hash.equals(that.hash) && height == that.height; } @@ -67,7 +67,7 @@ public abstract class BlockchainTransactionHash { return Objects.hash(hash, height); } - public int compareTo(BlockchainTransactionHash reference) { + public int compareTo(BlockTransactionHash reference) { int heightDiff = height - reference.height; if(heightDiff != 0) { return heightDiff; diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/BlockchainTransactionHashIndex.java b/src/main/java/com/sparrowwallet/drongo/wallet/BlockTransactionHashIndex.java similarity index 58% rename from src/main/java/com/sparrowwallet/drongo/wallet/BlockchainTransactionHashIndex.java rename to src/main/java/com/sparrowwallet/drongo/wallet/BlockTransactionHashIndex.java index 70126f4..225b87f 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/BlockchainTransactionHashIndex.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/BlockTransactionHashIndex.java @@ -4,16 +4,16 @@ import com.sparrowwallet.drongo.protocol.Sha256Hash; import java.util.Objects; -public class BlockchainTransactionHashIndex extends BlockchainTransactionHash implements Comparable { +public class BlockTransactionHashIndex extends BlockTransactionHash implements Comparable { private final long index; private final long value; - private BlockchainTransactionHashIndex spentBy; + private BlockTransactionHashIndex spentBy; - public BlockchainTransactionHashIndex(Sha256Hash hash, int height, Long fee, long index, long value) { + public BlockTransactionHashIndex(Sha256Hash hash, int height, Long fee, long index, long value) { this(hash, height, fee, index, value, null); } - public BlockchainTransactionHashIndex(Sha256Hash hash, int height, Long fee, long index, long value, BlockchainTransactionHashIndex spentBy) { + public BlockTransactionHashIndex(Sha256Hash hash, int height, Long fee, long index, long value, BlockTransactionHashIndex spentBy) { super(hash, height, fee); this.index = index; this.value = value; @@ -32,11 +32,11 @@ public class BlockchainTransactionHashIndex extends BlockchainTransactionHash im return spentBy != null; } - public BlockchainTransactionHashIndex getSpentBy() { + public BlockTransactionHashIndex getSpentBy() { return spentBy; } - public void setSpentBy(BlockchainTransactionHashIndex spentBy) { + public void setSpentBy(BlockTransactionHashIndex spentBy) { this.spentBy = spentBy; } @@ -50,7 +50,7 @@ public class BlockchainTransactionHashIndex extends BlockchainTransactionHash im if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; if (!super.equals(o)) return false; - BlockchainTransactionHashIndex that = (BlockchainTransactionHashIndex) o; + BlockTransactionHashIndex that = (BlockTransactionHashIndex) o; return index == that.index; } @@ -60,7 +60,7 @@ public class BlockchainTransactionHashIndex extends BlockchainTransactionHash im } @Override - public int compareTo(BlockchainTransactionHashIndex reference) { + public int compareTo(BlockTransactionHashIndex reference) { int diff = super.compareTo(reference); if(diff != 0) { return diff; @@ -69,7 +69,7 @@ public class BlockchainTransactionHashIndex extends BlockchainTransactionHash im return (int)(index - reference.index); } - public BlockchainTransactionHashIndex copy() { - return new BlockchainTransactionHashIndex(super.getHash(), super.getHeight(), super.getFee(), index, value, spentBy.copy()); + public BlockTransactionHashIndex copy() { + return new BlockTransactionHashIndex(super.getHash(), super.getHeight(), super.getFee(), index, value, spentBy.copy()); } } diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java b/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java index 1d89f5c..564b354 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java @@ -21,7 +21,7 @@ public class Wallet { private Policy defaultPolicy; private List keystores = new ArrayList<>(); private final Set purposeNodes = new TreeSet<>(); - private final Map transactions = new HashMap<>(); + private final Map transactions = new HashMap<>(); public Wallet() { } @@ -82,7 +82,7 @@ public class Wallet { return purposeNodes; } - public Map getTransactions() { + public Map getTransactions() { return transactions; } diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/WalletNode.java b/src/main/java/com/sparrowwallet/drongo/wallet/WalletNode.java index 067a4f4..042ff2b 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/WalletNode.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/WalletNode.java @@ -11,7 +11,7 @@ public class WalletNode implements Comparable { private final String derivationPath; private String label; private Set children = new TreeSet<>(); - private Set transactionOutputs = new TreeSet<>(); + private Set transactionOutputs = new TreeSet<>(); private transient KeyPurpose keyPurpose; private transient int index = -1; @@ -83,7 +83,7 @@ public class WalletNode implements Comparable { return null; } - return getUnspentTransactionOutputs().stream().mapToLong(BlockchainTransactionHashIndex::getValue).sum(); + return getUnspentTransactionOutputs().stream().mapToLong(BlockTransactionHashIndex::getValue).sum(); } public Set getChildren() { @@ -94,16 +94,16 @@ public class WalletNode implements Comparable { this.children = children; } - public Set getTransactionOutputs() { + public Set getTransactionOutputs() { return transactionOutputs; } - public void setTransactionOutputs(Set transactionOutputs) { + public void setTransactionOutputs(Set transactionOutputs) { this.transactionOutputs = transactionOutputs; } - public Set getUnspentTransactionOutputs() { - Set unspentTXOs = new TreeSet<>(transactionOutputs); + public Set getUnspentTransactionOutputs() { + Set unspentTXOs = new TreeSet<>(transactionOutputs); return unspentTXOs.stream().filter(txo -> !txo.isSpent()).collect(Collectors.toCollection(HashSet::new)); } @@ -163,7 +163,7 @@ public class WalletNode implements Comparable { copy.getChildren().add(child.copy()); } - for(BlockchainTransactionHashIndex txo : getTransactionOutputs()) { + for(BlockTransactionHashIndex txo : getTransactionOutputs()) { copy.getTransactionOutputs().add(txo.copy()); }