Official Java SDK for Bytom
Révision | 84860690c82adeb7742a63de8ed0e66343a044d4 (tree) |
---|---|
l'heure | 2019-04-09 15:28:09 |
Auteur | shenao78 <shenao.78@163....> |
Commiter | shenao78 |
fix retire
@@ -1,6 +1,7 @@ | ||
1 | 1 | package io.bytom.offline.api; |
2 | 2 | |
3 | 3 | import io.bytom.offline.common.Utils; |
4 | +import io.bytom.offline.common.VMUtil; | |
4 | 5 | import org.bouncycastle.util.encoders.Hex; |
5 | 6 | import java.io.ByteArrayOutputStream; |
6 | 7 | import java.io.IOException; |
@@ -39,7 +40,7 @@ public class Output { | ||
39 | 40 | } |
40 | 41 | |
41 | 42 | public static Output newRetireOutput(String assetID, long amount, String arbitrary) { |
42 | - String retireProgram = "6a" + Integer.toString(Hex.decode(arbitrary).length,16) + arbitrary; | |
43 | + String retireProgram = Hex.toHexString(new byte[]{VMUtil.OP_FAIL}) + Hex.toHexString(VMUtil.pushDataBytes(Hex.decode(arbitrary))); | |
43 | 44 | return new Output(assetID, amount, retireProgram); |
44 | 45 | } |
45 | 46 |
@@ -5,13 +5,14 @@ import java.io.IOException; | ||
5 | 5 | |
6 | 6 | public class VMUtil { |
7 | 7 | |
8 | - private static final byte OP_0 = (byte) 0x00; | |
9 | - private static final byte OP_1 = (byte) 0x51; | |
10 | - private static final byte OP_PUSHDATA1 = (byte) 0x4c; | |
11 | - private static final byte OP_PUSHDATA2 = (byte) 0x4d; | |
12 | - private static final byte OP_PUSHDATA4 = (byte) 0x43; | |
13 | - private static final byte OP_TXSIGHASH = (byte) 0xae; | |
14 | - private static final byte OP_CHECKMULTISIG = (byte) 0xad; | |
8 | + public static final byte OP_0 = (byte) 0x00; | |
9 | + public static final byte OP_1 = (byte) 0x51; | |
10 | + public static final byte OP_PUSHDATA1 = (byte) 0x4c; | |
11 | + public static final byte OP_PUSHDATA2 = (byte) 0x4d; | |
12 | + public static final byte OP_PUSHDATA4 = (byte) 0x43; | |
13 | + public static final byte OP_TXSIGHASH = (byte) 0xae; | |
14 | + public static final byte OP_CHECKMULTISIG = (byte) 0xad; | |
15 | + public static final byte OP_FAIL = (byte) 0x6a; | |
15 | 16 | |
16 | 17 | public static byte[] p2spMultiSigProgram(byte[][] pubKeys, int nRequired) { |
17 | 18 | checkMultiSigParams(nRequired, pubKeys.length); |
@@ -37,7 +38,7 @@ public class VMUtil { | ||
37 | 38 | } |
38 | 39 | } |
39 | 40 | |
40 | - private static byte[] pushDataBytes(byte[] data) { | |
41 | + public static byte[] pushDataBytes(byte[] data) { | |
41 | 42 | int len = data.length; |
42 | 43 | if (len == 0) { |
43 | 44 | return new byte[] {OP_0}; |