Skip to content

Commit 9bc36f8

Browse files
committed
Fixed issue are per #8 - Parity account unlock request with no duration.
1 parent 72bcddf commit 9bc36f8

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/integration-test/java/org/web3j/protocol/scenarios/Scenario.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ public void setUp() {
7171

7272
boolean unlockAccount() throws Exception {
7373
PersonalUnlockAccount personalUnlockAccount =
74-
parity.personalUnlockAccount(ALICE.getAddress(), WALLET_PASSWORD, ACCOUNT_UNLOCK_DURATION)
74+
parity.personalUnlockAccount(
75+
ALICE.getAddress(), WALLET_PASSWORD, ACCOUNT_UNLOCK_DURATION)
7576
.sendAsync().get();
7677
return personalUnlockAccount.accountUnlocked();
7778
}

src/main/java/org/web3j/protocol/parity/JsonRpc2_0Parity.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ public Request<?, NewAccountIdentifier> personalNewAccountFromWallet(WalletFile
7171
}
7272

7373
@Override
74-
public Request<?, PersonalUnlockAccount> personalUnlockAccount(String accountId, String password, BigInteger duration) {
74+
public Request<?, PersonalUnlockAccount> personalUnlockAccount(
75+
String accountId, String password, BigInteger duration) {
7576
List<Object> attributes = new ArrayList<>(3);
7677
attributes.add(accountId);
7778
attributes.add(password);
@@ -80,6 +81,8 @@ public Request<?, PersonalUnlockAccount> personalUnlockAccount(String accountId,
8081
// Parity has a bug where it won't support a duration
8182
// See https://github.com/ethcore/parity/issues/1215
8283
attributes.add(duration.longValue());
84+
} else {
85+
attributes.add(null); // we still need to include the null value, otherwise Parity rejects
8386
}
8487

8588
return new Request<>(

src/test/java/org/web3j/protocol/parity/RequestTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void testPersonalUnlockAccount() throws Exception {
9494
public void testPersonalUnlockAccountNoDuration() throws Exception {
9595
web3j.personalUnlockAccount("0xfc390d8a8ddb591b010fda52f4db4945742c3809", "hunter2").send();
9696

97-
verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"personal_unlockAccount\",\"params\":[\"0xfc390d8a8ddb591b010fda52f4db4945742c3809\",\"hunter2\"],\"id\":1}");
97+
verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"personal_unlockAccount\",\"params\":[\"0xfc390d8a8ddb591b010fda52f4db4945742c3809\",\"hunter2\",null],\"id\":1}");
9898
}
9999

100100
@Test

0 commit comments

Comments
 (0)