Skip to content

Commit e7b6561

Browse files
author
[a561842] hubert marteau
committed
Version including runtime parameters to use two nodes on a single
machine as described in : https://www.multichain.com/qa/2817/how-to-run-datadir-in-multichain?show=2822#a2822 Now, when you create Command object you can specify these parameters. More documentation has to come.
1 parent 5ba6326 commit e7b6561

22 files changed

+284
-76
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.multichainjavaapi</groupId>
55
<artifactId>MultiChainJavaAPI</artifactId>
6-
<version>0.4.14-SNAPSHOT</version>
6+
<version>0.4.15-SNAPSHOT</version>
77

88
<properties>
99
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

src/main/java/multichain/command/AddressCommand.java

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020

2121
/**
2222
* @author Ub - H. MARTEAU
23-
* @version 4.13
23+
* @version 4.15
2424
*/
2525
public class AddressCommand extends QueryBuilderAddress {
2626

27-
public AddressCommand(String ip, String port, String login, String password) {
28-
initialize(ip, port, login, password);
27+
public AddressCommand(String ip, String port, String login, String password, RuntimeParameters runtimeparameters) {
28+
initialize(ip, port, login, password, runtimeparameters);
2929
}
3030

3131
/**
@@ -204,6 +204,16 @@ public final List<Address> getAddressesList() throws MultichainException {
204204

205205
return addresses;
206206
}
207+
public final List<Address> getAddressesList(boolean verbose) throws MultichainException {
208+
List<Address> addresses = new ArrayList<Address>();
209+
210+
Object objectAddresses = executeGetAddresses(verbose);
211+
if (verifyInstance(objectAddresses, ArrayList.class) && verifyInstanceofList((ArrayList<Object>) objectAddresses, Address.class)) {
212+
addresses = AddressFormatter.formatAddressesList((ArrayList<Object>) objectAddresses);
213+
}
214+
215+
return addresses;
216+
}
207217

208218
/**
209219
* Returns a list of balances of all addresses in this node’s wallet
@@ -360,15 +370,23 @@ public List<BalanceAssetGeneral> getAddressBalances(String address) throws Multi
360370
* @throws MultichainException
361371
*/
362372
public final String getNewAddress() throws MultichainException {
373+
return getNewAddress(null);
374+
}
375+
public final String getNewAddress(String label) throws MultichainException {
363376
String stringAddress = "";
364-
365-
Object objectAddress = executeGetNewAddress();
377+
378+
Object objectAddress = null;
379+
if (label == null || label.isEmpty()) {
380+
objectAddress = executeGetNewAddress();
381+
} else {
382+
objectAddress = executeGetNewAddress(label);
383+
}
366384
if (verifyInstance(objectAddress, String.class)) {
367385
stringAddress = (String) objectAddress;
368386
}
369387

370388
return stringAddress;
371-
}
389+
}
372390

373391
/**
374392
*
@@ -390,17 +408,25 @@ public final String getNewAddress() throws MultichainException {
390408
* @throws MultichainException
391409
*/
392410
public final Address getNewAddressFilled() throws MultichainException {
411+
return getNewAddressFilled(null);
412+
}
413+
public final Address getNewAddressFilled(String label) throws MultichainException {
393414
Address address = new Address();
394415

395-
Object objectAddress = executeGetNewAddress();
416+
Object objectAddress = null;
417+
if (label == null || label.isEmpty()) {
418+
objectAddress = executeGetNewAddress();
419+
} else {
420+
objectAddress = executeGetNewAddress(label);
421+
}
396422
if (verifyInstance(objectAddress, String.class)) {
397423
String stringAddress = (String) objectAddress;
398424

399425
address = validateAddress(stringAddress);
400426
}
401427

402428
return address;
403-
}
429+
}
404430

405431
/**
406432
* Adds address to the wallet, without an associated private key, to create
@@ -429,6 +455,26 @@ public final Address getNewAddressFilled() throws MultichainException {
429455
public void importAddress(String address, String label, boolean rescan) throws MultichainException {
430456
/* String systemMessage = */executeImportAddress(address, label, rescan);
431457
}
458+
459+
/**
460+
* setaccount "address" "account"
461+
*
462+
* Sets the account associated with the given address.
463+
*
464+
* Arguments:
465+
* 1. "address" (string, required) The address to be associated with an account.
466+
* 2. "account" (string, required) The account to assign the address to.
467+
*
468+
* @param address
469+
* @param label
470+
* @return
471+
* @throws MultichainException
472+
*
473+
* !!!!! Accounts are not supported with scalable wallet - if you need accounts, run multichaind -walletdbversion=1 -rescan, but the wallet will perform worse
474+
*/
475+
public void setAccount(String address, String label) throws MultichainException {
476+
executeSetAccount(address, label);
477+
}
432478

433479
/**
434480
* Get information about an address

src/main/java/multichain/command/BalanceCommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
/**
1818
* @author Ub - H. MARTEAU
19-
* @version 4.13
19+
* @version 4.15
2020
*/
2121
public class BalanceCommand extends QueryBuilderBalance {
22-
public BalanceCommand(String ip, String port, String login, String password) {
23-
initialize(ip, port, login, password);
22+
public BalanceCommand(String ip, String port, String login, String password, RuntimeParameters runtimeparameters) {
23+
initialize(ip, port, login, password, runtimeparameters);
2424
}
2525

2626
/**

src/main/java/multichain/command/BlockCommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717

1818
/**
1919
* @author Ub - H. MARTEAU
20-
* @version 4.8
20+
* @version 4.15
2121
*/
2222
public class BlockCommand extends QueryBuilderBlock {
2323

24-
public BlockCommand(String ip, String port, String login, String password) {
25-
initialize(ip, port, login, password);
24+
public BlockCommand(String ip, String port, String login, String password, RuntimeParameters runtimeparameters) {
25+
initialize(ip, port, login, password, runtimeparameters);
2626
}
2727

2828
/**

src/main/java/multichain/command/ChainCommand.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
/**
1313
* @author Ub - H. MARTEAU
14-
* @version 4.13
14+
* @version 4.15
1515
*/
1616
public class ChainCommand extends QueryBuilderChain {
1717

18-
public ChainCommand(String ip, String port, String login, String password) {
19-
initialize(ip, port, login, password);
18+
public ChainCommand(String ip, String port, String login, String password, RuntimeParameters runtimeparameters) {
19+
initialize(ip, port, login, password, runtimeparameters);
2020
}
2121

2222
/**
@@ -58,6 +58,9 @@ public ChainCommand(String ip, String port, String login, String password) {
5858
public String getInfo() throws MultichainException {
5959
return executeGetInfo();
6060
}
61+
public String getInfo(String arg) throws MultichainException {
62+
return executeGetInfo(arg);
63+
}
6164

6265
/**
6366
* help ( command )

src/main/java/multichain/command/GrantCommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
/**
1919
* @author Ub - H. MARTEAU & Jagrut KOSTI
20-
* @version 3.1
20+
* @version 4.15
2121
*/
2222
public class GrantCommand extends QueryBuilderGrant {
2323

@@ -33,8 +33,8 @@ public class GrantCommand extends QueryBuilderGrant {
3333
public static int WALLET = QueryBuilderGrant.WALLET;
3434
public static int WALLET_ISSUE = QueryBuilderGrant.WALLET_ISSUE;
3535

36-
public GrantCommand(String ip, String port, String login, String password) {
37-
initialize(ip, port, login, password);
36+
public GrantCommand(String ip, String port, String login, String password, RuntimeParameters runtimeparameters) {
37+
initialize(ip, port, login, password, runtimeparameters);
3838
}
3939

4040
/**

src/main/java/multichain/command/IssueCommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818

1919
/**
2020
* @author Ub - H. MARTEAU
21-
* @version 4.4
21+
* @version 4.15
2222
*/
2323
public class IssueCommand extends QueryBuilderIssue {
2424

25-
public IssueCommand(String ip, String port, String login, String password) {
26-
initialize(ip, port, login, password);
25+
public IssueCommand(String ip, String port, String login, String password, RuntimeParameters runtimeparameters) {
26+
initialize(ip, port, login, password, runtimeparameters);
2727
}
2828

2929
/**

src/main/java/multichain/command/KeyCommand.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,15 @@
77
*/
88
package multichain.command;
99

10-
import java.util.ArrayList;
11-
import java.util.List;
12-
13-
import multichain.command.builders.QueryBuilderBalance;
1410
import multichain.command.builders.QueryBuilderKey;
15-
import multichain.object.BalanceAsset;
16-
import multichain.object.formatters.BalanceFormatter;
1711

1812
/**
1913
* @author Ub - H. MARTEAU
20-
* @version 3.0
14+
* @version 4.15
2115
*/
2216
public class KeyCommand extends QueryBuilderKey {
23-
public KeyCommand(String ip, String port, String login, String password) {
24-
initialize(ip, port, login, password);
17+
public KeyCommand(String ip, String port, String login, String password, RuntimeParameters runtimeparameters) {
18+
initialize(ip, port, login, password, runtimeparameters);
2519
}
2620

2721
public Object getPrivkey(String privkey) throws MultichainException {

src/main/java/multichain/command/MessagingCommand.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1+
/*
2+
* Copyright (C) 2017 Worldline, Inc.
3+
*
4+
* MultiChainJavaAPI code distributed under the GPLv3 license, see COPYING file.
5+
* https://github.com/SimplyUb/MultiChainJavaAPI/blob/master/LICENSE
6+
*
7+
*/
18
package multichain.command;
29

310
import multichain.command.MultichainException;
411
import multichain.command.builders.QueryBuilderMessaging;
512
import multichain.object.Address;
613

14+
/**
15+
* @author Ub - H. MARTEAU
16+
* @version 4.15
17+
*/
718
public class MessagingCommand extends QueryBuilderMessaging {
819

9-
public MessagingCommand(String ip, String port, String login, String password) {
10-
initialize(ip, port, login, password);
20+
public MessagingCommand(String ip, String port, String login, String password, RuntimeParameters runtimeparameters) {
21+
initialize(ip, port, login, password, runtimeparameters);
1122
}
1223

1324
/**

src/main/java/multichain/command/MiningCommand.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
1+
/*
2+
* Copyright (C) 2017 Worldline, Inc.
3+
*
4+
* MultiChainJavaAPI code distributed under the GPLv3 license, see COPYING file.
5+
* https://github.com/SimplyUb/MultiChainJavaAPI/blob/master/LICENSE
6+
*
7+
*/
18
package multichain.command;
29

310
import multichain.command.builders.QueryBuilderMining;
411

12+
/**
13+
* @author Ub - H. MARTEAU
14+
* @version 4.15
15+
*/
516
public class MiningCommand extends QueryBuilderMining {
6-
public MiningCommand(String ip, String port, String login, String password) {
7-
initialize(ip, port, login, password);
17+
public MiningCommand(String ip, String port, String login, String password, RuntimeParameters runtimeparameters) {
18+
initialize(ip, port, login, password, runtimeparameters);
819
}
920

1021
public Object pauseMining() throws MultichainException {

0 commit comments

Comments
 (0)