mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-02-22 22:25:41 +01:00
TransactionOutput: rename method messageSize()
from getMessageSize()
Keep the old method as deprecated.
This commit is contained in:
parent
591ff3a027
commit
210eaf91b3
4 changed files with 13 additions and 5 deletions
|
@ -1425,7 +1425,7 @@ public class Transaction extends BaseMessage {
|
|||
size += in.getMessageSize();
|
||||
size += VarInt.sizeOf(outputs.size());
|
||||
for (TransactionOutput out : outputs)
|
||||
size += out.getMessageSize();
|
||||
size += out.messageSize();
|
||||
if (useSegwit)
|
||||
for (TransactionInput in : inputs)
|
||||
size += in.getWitness().getMessageSize();
|
||||
|
|
|
@ -145,7 +145,7 @@ public class TransactionOutput {
|
|||
* @return byte array containing the transaction output
|
||||
*/
|
||||
public byte[] serialize() {
|
||||
return write(ByteBuffer.allocate(getMessageSize())).array();
|
||||
return write(ByteBuffer.allocate(messageSize())).array();
|
||||
}
|
||||
|
||||
/** @deprecated use {@link #serialize()} */
|
||||
|
@ -160,12 +160,20 @@ public class TransactionOutput {
|
|||
*
|
||||
* @return size of the serialized message in bytes
|
||||
*/
|
||||
public int getMessageSize() {
|
||||
public int messageSize() {
|
||||
int size = Coin.BYTES; // value
|
||||
size += VarInt.sizeOf(scriptBytes.length) + scriptBytes.length;
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #messageSize()}
|
||||
*/
|
||||
@Deprecated
|
||||
public int getMessageSize() {
|
||||
return messageSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of this output. This is the amount of currency that the destination address
|
||||
* receives.
|
||||
|
|
|
@ -129,7 +129,7 @@ public class TransactionOutputTest extends TestWithWallet {
|
|||
@Test
|
||||
@Parameters(method = "randomOutputs")
|
||||
public void write(TransactionOutput output) {
|
||||
ByteBuffer buf = ByteBuffer.allocate(output.getMessageSize());
|
||||
ByteBuffer buf = ByteBuffer.allocate(output.messageSize());
|
||||
output.write(buf);
|
||||
assertFalse(buf.hasRemaining());
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ public class TransactionTest {
|
|||
// add fake transaction output
|
||||
TransactionOutput output = new TransactionOutput(null, Coin.COIN, ADDRESS);
|
||||
tx.addOutput(output);
|
||||
length += output.getMessageSize();
|
||||
length += output.messageSize();
|
||||
|
||||
// message size has now grown
|
||||
assertEquals(length, tx.messageSize());
|
||||
|
|
Loading…
Add table
Reference in a new issue