mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-14 19:25:51 +00:00
Implement ScriptChunk.toString() by extracting relevant parts from Script.toString().
This commit is contained in:
parent
9c8d2cc600
commit
7b24a72e45
@ -36,7 +36,6 @@ import java.security.NoSuchAlgorithmException;
|
||||
import java.util.*;
|
||||
|
||||
import static com.google.bitcoin.script.ScriptOpCodes.*;
|
||||
import static com.google.bitcoin.core.Utils.bytesToHexString;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
@ -107,22 +106,11 @@ public class Script {
|
||||
*/
|
||||
public String toString() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
for (ScriptChunk chunk : chunks) {
|
||||
if (chunk.isOpCode()) {
|
||||
buf.append(getOpCodeName(chunk.opcode));
|
||||
buf.append(" ");
|
||||
} else if (chunk.data != null) {
|
||||
// Data chunk
|
||||
buf.append(getPushDataName(chunk.opcode));
|
||||
buf.append("[");
|
||||
buf.append(bytesToHexString(chunk.data));
|
||||
buf.append("] ");
|
||||
} else {
|
||||
// Small num
|
||||
buf.append(decodeFromOpN(chunk.opcode));
|
||||
}
|
||||
}
|
||||
return buf.toString().trim();
|
||||
for (ScriptChunk chunk : chunks)
|
||||
buf.append(chunk).append(' ');
|
||||
if (buf.length() > 0)
|
||||
buf.setLength(buf.length() - 1);
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/** Returns the serialized program as a newly created byte array. */
|
||||
|
@ -25,9 +25,12 @@ import java.util.Arrays;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.bitcoin.core.Utils.bytesToHexString;
|
||||
import static com.google.bitcoin.script.ScriptOpCodes.OP_PUSHDATA1;
|
||||
import static com.google.bitcoin.script.ScriptOpCodes.OP_PUSHDATA2;
|
||||
import static com.google.bitcoin.script.ScriptOpCodes.OP_PUSHDATA4;
|
||||
import static com.google.bitcoin.script.ScriptOpCodes.getOpCodeName;
|
||||
import static com.google.bitcoin.script.ScriptOpCodes.getPushDataName;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
@ -97,6 +100,24 @@ public class ScriptChunk {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
if (isOpCode()) {
|
||||
buf.append(getOpCodeName(opcode));
|
||||
} else if (data != null) {
|
||||
// Data chunk
|
||||
buf.append(getPushDataName(opcode));
|
||||
buf.append("[");
|
||||
buf.append(bytesToHexString(data));
|
||||
buf.append("]");
|
||||
} else {
|
||||
// Small num
|
||||
buf.append(Script.decodeFromOpN(opcode));
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user