From 577879463544de4d19a60e88cb9188dab92091f7 Mon Sep 17 00:00:00 2001 From: johnygeorge Date: Mon, 6 Jun 2016 14:38:09 +0200 Subject: [PATCH] ScriptBuilder: Make OP_RETURN to allow 80 bytes. Make OP_RETURN to allow 80 bytes instead of the previous 40 bytes. This is to be consistent with the Bitcoin Core, which have made it back to 80 bytes. --- .../main/java/org/bitcoinj/script/ScriptBuilder.java | 2 +- .../src/test/java/org/bitcoinj/wallet/WalletTest.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/bitcoinj/script/ScriptBuilder.java b/core/src/main/java/org/bitcoinj/script/ScriptBuilder.java index 9642409d..c6bece72 100644 --- a/core/src/main/java/org/bitcoinj/script/ScriptBuilder.java +++ b/core/src/main/java/org/bitcoinj/script/ScriptBuilder.java @@ -433,7 +433,7 @@ public class ScriptBuilder { * the ledger. */ public static Script createOpReturnScript(byte[] data) { - checkArgument(data.length <= 40); + checkArgument(data.length <= 80); return new ScriptBuilder().op(OP_RETURN).data(data).build(); } diff --git a/core/src/test/java/org/bitcoinj/wallet/WalletTest.java b/core/src/test/java/org/bitcoinj/wallet/WalletTest.java index acd2d8d7..6273922b 100644 --- a/core/src/test/java/org/bitcoinj/wallet/WalletTest.java +++ b/core/src/test/java/org/bitcoinj/wallet/WalletTest.java @@ -2167,6 +2167,17 @@ public class WalletTest extends TestWithWallet { wallet.completeTx(request); } + @Test + public void opReturnMaxBytes() throws Exception { + receiveATransaction(wallet, myAddress); + Transaction tx = new Transaction(PARAMS); + Script script = ScriptBuilder.createOpReturnScript(new byte[80]); + tx.addOutput(Coin.ZERO, script); + SendRequest request = SendRequest.forTx(tx); + request.ensureMinRequiredFee = true; + wallet.completeTx(request); + } + @Test public void opReturnOneOutputWithValueTest() throws Exception { // Tests basic send of transaction with one output that destroys coins and has an OP_RETURN.