mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-13 11:36:15 +01:00
TransactionInput: rename method messageSize()
from getMessageSize()
Keep the old method as deprecated.
This commit is contained in:
parent
210eaf91b3
commit
c58232ef75
4 changed files with 13 additions and 5 deletions
|
@ -1422,7 +1422,7 @@ public class Transaction extends BaseMessage {
|
|||
size += 2; // marker, flag
|
||||
size += VarInt.sizeOf(inputs.size());
|
||||
for (TransactionInput in : inputs)
|
||||
size += in.getMessageSize();
|
||||
size += in.messageSize();
|
||||
size += VarInt.sizeOf(outputs.size());
|
||||
for (TransactionOutput out : outputs)
|
||||
size += out.messageSize();
|
||||
|
|
|
@ -182,7 +182,7 @@ public class TransactionInput {
|
|||
* @return byte array containing the transaction input
|
||||
*/
|
||||
public byte[] serialize() {
|
||||
return write(ByteBuffer.allocate(getMessageSize())).array();
|
||||
return write(ByteBuffer.allocate(messageSize())).array();
|
||||
}
|
||||
|
||||
/** @deprecated use {@link #serialize()} */
|
||||
|
@ -197,13 +197,21 @@ public class TransactionInput {
|
|||
*
|
||||
* @return size of the serialized message in bytes
|
||||
*/
|
||||
public int getMessageSize() {
|
||||
public int messageSize() {
|
||||
int size = TransactionOutPoint.BYTES;
|
||||
size += VarInt.sizeOf(scriptBytes.length) + scriptBytes.length;
|
||||
size += 4; // sequence
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #messageSize()}
|
||||
*/
|
||||
@Deprecated
|
||||
public int getMessageSize() {
|
||||
return messageSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Coinbase transactions have special inputs with hashes of zero. If this is such an input, returns true.
|
||||
*/
|
||||
|
|
|
@ -126,7 +126,7 @@ public class TransactionInputTest {
|
|||
@Test
|
||||
@Parameters(method = "randomInputs")
|
||||
public void readAndWrite(TransactionInput input) {
|
||||
ByteBuffer buf = ByteBuffer.allocate(input.getMessageSize());
|
||||
ByteBuffer buf = ByteBuffer.allocate(input.messageSize());
|
||||
input.write(buf);
|
||||
assertFalse(buf.hasRemaining());
|
||||
((Buffer) buf).rewind();
|
||||
|
|
|
@ -179,7 +179,7 @@ public class TransactionTest {
|
|||
TransactionInput input = new TransactionInput(null, ScriptBuilder.createEmpty().program(),
|
||||
new TransactionOutPoint(0, Sha256Hash.ZERO_HASH));
|
||||
tx.addInput(input);
|
||||
length += input.getMessageSize();
|
||||
length += input.messageSize();
|
||||
|
||||
// add fake transaction output
|
||||
TransactionOutput output = new TransactionOutput(null, Coin.COIN, ADDRESS);
|
||||
|
|
Loading…
Add table
Reference in a new issue