|
21 | 21 |
|
22 | 22 | import org.web3j.crypto.Credentials;
|
23 | 23 | import org.web3j.protocol.besu.Besu;
|
| 24 | +import org.web3j.protocol.besu.response.privacy.PrivateEnclaveKey; |
24 | 25 | import org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt;
|
25 | 26 | import org.web3j.protocol.core.DefaultBlockParameter;
|
26 | 27 | import org.web3j.protocol.core.methods.response.EthGetCode;
|
@@ -80,7 +81,7 @@ protected PrivateTransactionManager(
|
80 | 81 | credentials,
|
81 | 82 | chainId,
|
82 | 83 | privateFrom,
|
83 |
| - new PollingPrivateTransactionReceiptProcessor(besu, attempts, sleepDuration)); |
| 84 | + new PollingPrivateTransactionReceiptProcessor(besu, sleepDuration, attempts)); |
84 | 85 | }
|
85 | 86 |
|
86 | 87 | protected PrivateTransactionManager(
|
@@ -160,11 +161,7 @@ public EthSendTransaction sendTransaction(
|
160 | 161 | RESTRICTED);
|
161 | 162 | }
|
162 | 163 |
|
163 |
| - final String rawSignedTransaction = |
164 |
| - Numeric.toHexString( |
165 |
| - PrivateTransactionEncoder.signMessage(transaction, chainId, credentials)); |
166 |
| - |
167 |
| - return besu.eeaSendRawTransaction(rawSignedTransaction).send(); |
| 164 | + return signAndSend(transaction); |
168 | 165 | }
|
169 | 166 |
|
170 | 167 | public EthSendTransaction sendTransactionEIP1559(
|
@@ -210,11 +207,7 @@ public EthSendTransaction sendTransactionEIP1559(
|
210 | 207 | RESTRICTED);
|
211 | 208 | }
|
212 | 209 |
|
213 |
| - final String rawSignedTransaction = |
214 |
| - Numeric.toHexString( |
215 |
| - PrivateTransactionEncoder.signMessage(transaction, chainId, credentials)); |
216 |
| - |
217 |
| - return besu.eeaSendRawTransaction(rawSignedTransaction).send(); |
| 210 | + return signAndSend(transaction); |
218 | 211 | }
|
219 | 212 |
|
220 | 213 | @Override
|
@@ -264,4 +257,29 @@ public EthGetCode getCode(
|
264 | 257 | this.getPrivacyGroupId().toString(), contractAddress, defaultBlockParameter)
|
265 | 258 | .send();
|
266 | 259 | }
|
| 260 | + |
| 261 | + public String sign(RawPrivateTransaction rawTransaction) { |
| 262 | + |
| 263 | + byte[] signedMessage; |
| 264 | + |
| 265 | + if (chainId > ChainIdLong.NONE) { |
| 266 | + signedMessage = |
| 267 | + PrivateTransactionEncoder.signMessage(rawTransaction, chainId, credentials); |
| 268 | + } else { |
| 269 | + signedMessage = PrivateTransactionEncoder.signMessage(rawTransaction, credentials); |
| 270 | + } |
| 271 | + |
| 272 | + return Numeric.toHexString(signedMessage); |
| 273 | + } |
| 274 | + |
| 275 | + public EthSendTransaction signAndSend(RawPrivateTransaction rawTransaction) throws IOException { |
| 276 | + String hexValue = sign(rawTransaction); |
| 277 | + return this.besu.eeaSendRawTransaction(hexValue).send(); |
| 278 | + } |
| 279 | + |
| 280 | + public PrivateEnclaveKey signAndDistribute(RawPrivateTransaction rawTransaction) |
| 281 | + throws IOException { |
| 282 | + String hexValue = sign(rawTransaction); |
| 283 | + return this.besu.privDistributeRawTransaction(hexValue).send(); |
| 284 | + } |
267 | 285 | }
|
0 commit comments