OSDN Git Service

refactor
[bytom/bytom-java-sdk.git] / tx-signer / src / main / java / io / bytom / api / WitnessComponent.java
1 package io.bytom.api;
2
3 import org.bouncycastle.util.encoders.Hex;
4
5 import java.util.ArrayList;
6 import java.util.List;
7
8 /**
9  * A single witness component, holding information that will become the input
10  * witness.
11  */
12 public class WitnessComponent {
13
14     /**
15      * The list of witnesses made with the specified keys (null unless type is
16      * "signature").
17      */
18     private List<String> witnesses;
19
20     private String rootPrivateKey;
21
22     public WitnessComponent() {
23         witnesses = new ArrayList<>();
24     }
25
26     public byte[][] toByteArray() {
27         byte[][] byteArray = new byte[witnesses.size()][];
28         for (int i = 0; i < witnesses.size(); i++) {
29             byteArray[i] = Hex.decode(witnesses.get(i));
30         }
31         return byteArray;
32     }
33
34     public String getWitness(int index) {
35         return witnesses.get(index);
36     }
37
38     public void appendWitness(String witness) {
39         witnesses.add(witness);
40     }
41
42     public String getRootPrivateKey() {
43         return rootPrivateKey;
44     }
45
46     public void setRootPrivateKey(String rootPrivateKey) {
47         this.rootPrivateKey = rootPrivateKey;
48     }
49 }