@@ -41,14 +41,14 @@ public void computeId() {
41
41
}
42
42
43
43
public String getId () {
44
- return Hex .encode (Sha256Hash .hash (Serializer .serialize (this )));
44
+ return Hex .encode (Sha256Hash .hash (this .serialize ()));
45
45
}
46
46
47
47
public Transaction sign (String passphrase ) {
48
48
ECKey privateKey = PrivateKey .fromPassphrase (passphrase );
49
49
50
50
this .senderPublicKey = privateKey .getPublicKeyAsHex ();
51
- Sha256Hash hash = Sha256Hash .of (Serializer .serialize (this , true , true , false ));
51
+ Sha256Hash hash = Sha256Hash .of (this .serialize (true , true , false ));
52
52
53
53
this .signature = Hex .encode (signer ().sign (hash .getBytes (), privateKey ));
54
54
@@ -58,7 +58,7 @@ public Transaction sign(String passphrase) {
58
58
public Transaction secondSign (String passphrase ) {
59
59
ECKey privateKey = PrivateKey .fromPassphrase (passphrase );
60
60
61
- Sha256Hash hash = Sha256Hash .of (Serializer .serialize (this , false , true , false ));
61
+ Sha256Hash hash = Sha256Hash .of (this .serialize (false , true ));
62
62
63
63
this .secondSignature = Hex .encode (signer ().sign (hash .getBytes (), privateKey ));
64
64
@@ -89,7 +89,7 @@ public boolean verify() {
89
89
ECKey keys = ECKey .fromPublicOnly (Hex .decode (this .senderPublicKey ));
90
90
91
91
byte [] signature = Hex .decode (this .signature );
92
- byte [] hash = Sha256Hash .hash (Serializer .serialize (this , true , true , false ));
92
+ byte [] hash = Sha256Hash .hash (this .serialize (true , true , false ));
93
93
94
94
return verifier ().verify (hash , keys , signature );
95
95
}
@@ -98,7 +98,7 @@ public boolean secondVerify(String secondPublicKey) {
98
98
ECKey keys = ECKey .fromPublicOnly (Hex .decode (secondPublicKey ));
99
99
100
100
byte [] signature = Hex .decode (this .secondSignature );
101
- byte [] hash = Sha256Hash .hash (Serializer .serialize (this , false , true , false ));
101
+ byte [] hash = Sha256Hash .hash (this .serialize (false , true , false ));
102
102
103
103
return verifier ().verify (hash , keys , signature );
104
104
}
@@ -145,6 +145,24 @@ public HashMap toHashMap() {
145
145
return map ;
146
146
}
147
147
148
+ public byte [] serialize (
149
+ boolean skipSignature , boolean skipSecondSignature , boolean skipMultiSignature ) {
150
+ return Serializer .serialize (this , skipSignature , skipSecondSignature , skipMultiSignature );
151
+ }
152
+
153
+ public byte [] serialize (boolean skipSignature , boolean skipSecondSignature ) {
154
+ return serialize (skipSignature , skipSecondSignature , false );
155
+ }
156
+
157
+ public byte [] serialize (boolean skipSignature ) {
158
+ return serialize (skipSignature , false , false );
159
+ }
160
+
161
+ // Overloaded method with no parameters, defaulting all to false
162
+ public byte [] serialize () {
163
+ return serialize (false , false , false );
164
+ }
165
+
148
166
public abstract byte [] serializeData ();
149
167
150
168
public abstract void deserializeData (ByteBuffer buffer );
0 commit comments