mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2024-11-19 09:50:32 +01:00
TransactionWitness: rename method messageSize()
from getMessageSize()
Keep the old method as deprecated.
This commit is contained in:
parent
c58232ef75
commit
e7b11c0713
@ -1428,7 +1428,7 @@ public class Transaction extends BaseMessage {
|
||||
size += out.messageSize();
|
||||
if (useSegwit)
|
||||
for (TransactionInput in : inputs)
|
||||
size += in.getWitness().getMessageSize();
|
||||
size += in.getWitness().messageSize();
|
||||
size += 4; // locktime
|
||||
return size;
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ public class TransactionWitness {
|
||||
* @return byte array containing the transaction witness
|
||||
*/
|
||||
public byte[] serialize() {
|
||||
return write(ByteBuffer.allocate(getMessageSize())).array();
|
||||
return write(ByteBuffer.allocate(messageSize())).array();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -147,13 +147,21 @@ public class TransactionWitness {
|
||||
*
|
||||
* @return size of the serialized message in bytes
|
||||
*/
|
||||
public int getMessageSize() {
|
||||
public int messageSize() {
|
||||
int size = VarInt.sizeOf(pushes.size());
|
||||
for (byte[] push : pushes)
|
||||
size += VarInt.sizeOf(push.length) + push.length;
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #messageSize()}
|
||||
*/
|
||||
@Deprecated
|
||||
public int getMessageSize() {
|
||||
return messageSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
List<String> stringPushes = new ArrayList<>(pushes.size());
|
||||
|
@ -73,7 +73,7 @@ public class TransactionWitnessTest {
|
||||
@Test
|
||||
@Parameters(method = "randomWitness")
|
||||
public void readAndWrite(TransactionWitness witness) {
|
||||
ByteBuffer buf = ByteBuffer.allocate(witness.getMessageSize());
|
||||
ByteBuffer buf = ByteBuffer.allocate(witness.messageSize());
|
||||
witness.write(buf);
|
||||
assertFalse(buf.hasRemaining());
|
||||
((Buffer) buf).rewind();
|
||||
|
Loading…
Reference in New Issue
Block a user