mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-07 14:54:15 +00:00
Add Transaction.clearIn/Outputs and make getIn/Outputs unmodifiable
This commit is contained in:
parent
5993f2dc6c
commit
5369ca925a
@ -636,6 +636,20 @@ public class Transaction extends ChildMessage implements Serializable {
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all the inputs from this transaction.
|
||||
* Note that this also invalidates the length attribute
|
||||
*/
|
||||
public void clearInputs() {
|
||||
unCache();
|
||||
for (TransactionInput input : inputs) {
|
||||
input.setParent(null);
|
||||
}
|
||||
inputs.clear();
|
||||
// You wanted to reserialize, right?
|
||||
this.length = this.bitcoinSerialize().length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an input to this transaction that imports value from the given output. Note that this input is NOT
|
||||
* complete and after every input is added with addInput() and every output is added with addOutput(),
|
||||
@ -656,6 +670,20 @@ public class Transaction extends ChildMessage implements Serializable {
|
||||
adjustLength(inputs.size(), input.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all the inputs from this transaction.
|
||||
* Note that this also invalidates the length attribute
|
||||
*/
|
||||
public void clearOutputs() {
|
||||
unCache();
|
||||
for (TransactionOutput output : outputs) {
|
||||
output.setParent(null);
|
||||
}
|
||||
outputs.clear();
|
||||
// You wanted to reserialize, right?
|
||||
this.length = this.bitcoinSerialize().length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given output to this transaction. The output must be completely initialized.
|
||||
*/
|
||||
@ -964,16 +992,16 @@ public class Transaction extends ChildMessage implements Serializable {
|
||||
return version;
|
||||
}
|
||||
|
||||
/** Returns a modifiable list of all inputs. */
|
||||
/** Returns an unmodifiable view of all inputs. */
|
||||
public List<TransactionInput> getInputs() {
|
||||
maybeParse();
|
||||
return inputs;
|
||||
return Collections.unmodifiableList(inputs);
|
||||
}
|
||||
|
||||
/** Returns a modifiable list of all outputs. */
|
||||
/** Returns an unmodifiable view of all outputs. */
|
||||
public List<TransactionOutput> getOutputs() {
|
||||
maybeParse();
|
||||
return outputs;
|
||||
return Collections.unmodifiableList(outputs);
|
||||
}
|
||||
|
||||
/** @return the given transaction: same as getInputs().get(index). */
|
||||
|
Loading…
x
Reference in New Issue
Block a user