• R/O
  • HTTP
  • SSH
  • HTTPS

bytom-java-sdk: Commit

Official Java SDK for Bytom


Commit MetaInfo

Révision487fc03b5eccce34afc4ba24ab0d68d5e7573d3a (tree)
l'heure2019-04-09 15:31:38
Auteurmuscle_boy <shenao.78@163....>
CommiterGitHub

Message de Log

Merge pull request #12 from Bytom/fix_retire

fix retire

Change Summary

Modification

--- a/tx-signer/src/main/java/io/bytom/offline/api/Output.java
+++ b/tx-signer/src/main/java/io/bytom/offline/api/Output.java
@@ -1,6 +1,7 @@
11 package io.bytom.offline.api;
22
33 import io.bytom.offline.common.Utils;
4+import io.bytom.offline.common.VMUtil;
45 import org.bouncycastle.util.encoders.Hex;
56 import java.io.ByteArrayOutputStream;
67 import java.io.IOException;
@@ -39,7 +40,7 @@ public class Output {
3940 }
4041
4142 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)));
4344 return new Output(assetID, amount, retireProgram);
4445 }
4546
--- a/tx-signer/src/main/java/io/bytom/offline/common/VMUtil.java
+++ b/tx-signer/src/main/java/io/bytom/offline/common/VMUtil.java
@@ -5,13 +5,14 @@ import java.io.IOException;
55
66 public class VMUtil {
77
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;
1516
1617 public static byte[] p2spMultiSigProgram(byte[][] pubKeys, int nRequired) {
1718 checkMultiSigParams(nRequired, pubKeys.length);
@@ -37,7 +38,7 @@ public class VMUtil {
3738 }
3839 }
3940
40- private static byte[] pushDataBytes(byte[] data) {
41+ public static byte[] pushDataBytes(byte[] data) {
4142 int len = data.length;
4243 if (len == 0) {
4344 return new byte[] {OP_0};
Afficher sur ancien navigateur de dépôt.