mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-01-31 23:32:16 +00:00
Transactions: Make some methods public and add a couple of accessor methods.
This commit is contained in:
parent
30eb1f8043
commit
8fa8a195c1
@ -337,7 +337,7 @@ public class TransactionInput extends ChildMessage implements Serializable {
|
||||
*
|
||||
* @return true if the disconnection took place, false if it was not connected.
|
||||
*/
|
||||
boolean disconnect() {
|
||||
public boolean disconnect() {
|
||||
if (outpoint.fromTx == null) return false;
|
||||
TransactionOutput output = outpoint.fromTx.getOutput((int) outpoint.getIndex());
|
||||
if (output.getSpentBy() == this) {
|
||||
@ -375,4 +375,13 @@ public class TransactionInput extends ChildMessage implements Serializable {
|
||||
int myIndex = parentTransaction.getInputs().indexOf(this);
|
||||
sig.correctlySpends(parentTransaction, myIndex, pubKey, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the connected output, assuming the input was connected with
|
||||
* {@link TransactionInput#connect(TransactionOutput)} or variants at some point. If it wasn't connected, then
|
||||
* this method returns null.
|
||||
*/
|
||||
public TransactionOutput getConnectedOutput() {
|
||||
return getOutpoint().getConnectedOutput();
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ public class TransactionOutPoint extends ChildMessage implements Serializable {
|
||||
* sides in memory, and they have been linked together, this returns a pointer to the connected output, or null
|
||||
* if there is no such connection.
|
||||
*/
|
||||
TransactionOutput getConnectedOutput() {
|
||||
public TransactionOutput getConnectedOutput() {
|
||||
if (fromTx == null) return null;
|
||||
return fromTx.getOutputs().get((int) index);
|
||||
}
|
||||
@ -139,7 +139,9 @@ public class TransactionOutPoint extends ChildMessage implements Serializable {
|
||||
* @return an ECKey or null if the connected key cannot be found in the wallet.
|
||||
*/
|
||||
public ECKey getConnectedKey(Wallet wallet) throws ScriptException {
|
||||
Script connectedScript = getConnectedOutput().getScriptPubKey();
|
||||
TransactionOutput connectedOutput = getConnectedOutput();
|
||||
checkState(connectedOutput != null, "Input is not connected in wallet so cannot retrieve connected key");
|
||||
Script connectedScript = connectedOutput.getScriptPubKey();
|
||||
if (connectedScript.isSentToAddress()) {
|
||||
byte[] addressBytes = connectedScript.getPubKeyHash();
|
||||
return wallet.findKeyFromPubHash(addressBytes);
|
||||
|
Loading…
Reference in New Issue
Block a user