OSDN Git Service

fix signature fix_retire
authorshenao78 <shenao.78@163.com>
Tue, 16 Apr 2019 06:12:24 +0000 (14:12 +0800)
committershenao78 <shenao.78@163.com>
Tue, 16 Apr 2019 06:12:24 +0000 (14:12 +0800)
tx-signer/src/main/java/io/bytom/offline/api/BaseInput.java
tx-signer/src/main/java/io/bytom/offline/api/SpendInput.java
tx-signer/src/test/java/io/bytom/offline/api/AppTest.java

index 4963549..6b909a7 100644 (file)
@@ -70,6 +70,9 @@ public abstract class BaseInput {
         if (program == null) {
             throw new IllegalArgumentException("the program id of input must be specified.");
         }
+        if (keyIndex == null) {
+            throw new IllegalArgumentException("the key index of input must be specified.");
+        }
         if (witnessComponent.getRootPrivateKey() == null) {
             throw new IllegalArgumentException("the root private key of input must be specified.");
         }
index f24d055..0a11c32 100644 (file)
@@ -52,7 +52,7 @@ public class SpendInput extends BaseInput {
 
         byte[] privateChild;
         if (bipProtocol == BIPProtocol.BIP44) {
-            privateChild = DerivePrivateKey.bip44derivePrvKey(rootPrvKey, AccountKeySpace, change, controlProgramIndex);
+            privateChild = DerivePrivateKey.bip44derivePrvKey(rootPrvKey, getKeyIndex(), change, controlProgramIndex);
         } else {
             privateChild = DerivePrivateKey.bip32derivePrvKey(rootPrvKey, getKeyIndex(), AccountKeySpace, controlProgramIndex);
         }
index efd5a64..6897e92 100755 (executable)
@@ -98,6 +98,7 @@ public class AppTest {
         input1.setChange(true);\r
         input1.setControlProgramIndex(41);\r
         input1.setSourceID("0b2cff11d1d056d95237a5f2d06059e5395e86f60e69c1e8201ea624911c0c65");\r
+        input1.setKeyIndex(1);\r
         input1.setSourcePosition(0);\r
 \r
         SpendInput input2 = new SpendInput(assetId1, 70000000000L, "0014bb8a039726df1b649738e9973db14a4b4fd4becf");\r
@@ -105,6 +106,7 @@ public class AppTest {
         input2.setChange(true);\r
         input2.setControlProgramIndex(26);\r
         input2.setSourceID("be0ac837e832c34a02968e54dab4f95cbeceb9fb01cd378310f6ea32219ee29b");\r
+        input2.setKeyIndex(1);\r
         input2.setSourcePosition(1);\r
 \r
         Output output1 = new Output(btmAssetID, 279100000L, "001414d362694eacfa110dc20dec77d610d22340f95b");\r