Skip to content

Commit e04f0b0

Browse files
author
ub
committed
Issues correction + class usage modification
1 parent 69441a0 commit e04f0b0

File tree

8 files changed

+54
-21
lines changed

8 files changed

+54
-21
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.11-SNAPSHOT</version>
6+
<version>0.4.12-SNAPSHOT</version>
77

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

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,12 @@ public Block getBlock(String blockHash) throws MultichainException {
168168
* the active chain
169169
* @throws MultichainException
170170
*/
171-
public Block getBlock(int blockHeight, boolean verbose) throws MultichainException {
172-
Object objectBlock = executeGetBlock(blockHeight, verbose);
171+
public Block getBlock(long blockHeight, boolean verbose) throws MultichainException {
172+
int verboseValue = 0;
173+
if (verbose) {
174+
verboseValue = 1;
175+
}
176+
Object objectBlock = executeGetBlock(blockHeight, verboseValue);
173177
Block block = BlockFormatter.formatBlock(objectBlock);
174178

175179
return block;
@@ -183,7 +187,7 @@ public Block getBlock(int blockHeight, boolean verbose) throws MultichainExcepti
183187
* the active chain
184188
* @throws MultichainException
185189
*/
186-
public Block getBlock(int blockHeight) throws MultichainException {
190+
public Block getBlock(long blockHeight) throws MultichainException {
187191
return getBlock(blockHeight, true);
188192
}
189193

src/main/java/multichain/command/RAWTransactionCommand.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -596,13 +596,15 @@ public String getRawChangeAddress() throws MultichainException {
596596
* @return
597597
* @throws MultichainException
598598
*/
599-
public TransactionRAW getRawTransaction(String txid, int verbose) throws MultichainException {
600-
TransactionRAW transactionRAW = new TransactionRAW();
601-
599+
public Object getRawTransaction(String txid, int verbose) throws MultichainException {
602600
Object objectTransactionRAW = executeGetRawTransaction(txid, verbose);
603-
transactionRAW = RAWTransactionFormatter.formatTransactionRAW(objectTransactionRAW);
604-
605-
return transactionRAW;
601+
if (verbose == 0) {
602+
return objectTransactionRAW;
603+
} else {
604+
TransactionRAW transactionRAW = RAWTransactionFormatter.formatTransactionRAW(objectTransactionRAW);
605+
return transactionRAW;
606+
}
607+
606608
}
607609

608610
/**
@@ -613,7 +615,7 @@ public TransactionRAW getRawTransaction(String txid, int verbose) throws Multich
613615
* @throws MultichainException
614616
*/
615617
public TransactionRAW getRAWTransactionWithDetail(String txid) throws MultichainException {
616-
return getRawTransaction(txid, 1);
618+
return (TransactionRAW) getRawTransaction(txid, 1);
617619
}
618620

619621
/**
@@ -623,8 +625,8 @@ public TransactionRAW getRAWTransactionWithDetail(String txid) throws Multichain
623625
* @return
624626
* @throws MultichainException
625627
*/
626-
public TransactionRAW getRAWTransactionWithoutDetail(String txid) throws MultichainException {
627-
return getRawTransaction(txid, 0);
628+
public String getRAWTransactionWithoutDetail(String txid) throws MultichainException {
629+
return (String) getRawTransaction(txid, 0);
628630
}
629631

630632
/**

src/main/java/multichain/command/builders/QueryBuilderBlock.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ protected Object executeListBlocks(String blockidentifiers,boolean verbose) thro
126126
* active chain
127127
* @throws MultichainException
128128
*/
129-
protected Object executeGetBlock(int height, boolean verbose) throws MultichainException {
130-
return execute(CommandEnum.GETBLOCK, height, verbose);
129+
protected Object executeGetBlock(long height, int verbose) throws MultichainException {
130+
return execute(CommandEnum.GETBLOCK, String.valueOf(height), verbose);
131131
}
132132

133133
/**

src/main/java/multichain/object/TransactionRAWVout.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class TransactionRAWVout {
2020
ScriptPubKey scriptPubKey;
2121
List<BalanceAsset> assets;
2222
List<Permission> permissions;
23+
List<Item> items;
2324

2425
/**
2526
*
@@ -29,6 +30,7 @@ public TransactionRAWVout() {
2930
scriptPubKey = new ScriptPubKey();
3031
assets = new ArrayList<BalanceAsset>();
3132
permissions = new ArrayList<Permission>();
33+
items = new ArrayList<Item>();
3234
}
3335

3436
/**
@@ -115,5 +117,19 @@ public void addPermission(Permission permission) {
115117
this.permissions.add(permission);
116118
}
117119

120+
/**
121+
* @return the items
122+
*/
123+
public List<Item> getItems() {
124+
return items;
125+
}
126+
127+
/**
128+
* @param items the items to set
129+
*/
130+
public void setItems(List<Item> items) {
131+
this.items = items;
132+
}
133+
118134

119135
}

src/test/java/multichain/command/BlockCommandTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ public static void main(String[] args) {
112112
System.out.println("--- Start of AddressCommandTest ---");
113113

114114
// BlockChain TestCommand has to be created and started before
115-
multiChainCommand = new MultiChainCommand("localhost", "6824", "multichainrpc",
116-
"73oYQWzx45hossFPPWUgicpLvHhsD8PempYxnSF6bnY9");
115+
multiChainCommand = new MultiChainCommand(TestConst.MULTICHAIN_SERVER_IP, TestConst.MULTICHAIN_SERVER_PORT, TestConst.MULTICHAIN_SERVER_LOGIN,
116+
TestConst.MULTICHAIN_SERVER_PWD);
117117

118-
//testgetBlock();
119-
testlistBlocks();
118+
testgetBlock();
119+
//testlistBlocks();
120120

121121
System.out.println("--- End of AddressCommandTest ---");
122122
}

src/test/java/multichain/command/RAWTransactionCommandTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,16 @@ public void testcreateRawTransaction() {
134134
assertTrue(true);
135135
}
136136

137+
@Test
138+
public void testgetRawTransaction() throws MultichainException {
139+
// MultiChainCommand multiChainCommand = new MultiChainCommand(TestConst.MULTICHAIN_SERVER_IP,
140+
// TestConst.MULTICHAIN_SERVER_PORT, TestConst.MULTICHAIN_SERVER_LOGIN, TestConst.MULTICHAIN_SERVER_PWD);
141+
//
142+
// Object temp = multiChainCommand.getRawTransactionCommand().getRawTransaction("a8d2952e73258f115a7561f799b26dbf14b446ddf62b0136a982fc76a2d80a85", 0);
143+
//
144+
// System.out.println(temp.getClass());
145+
assertTrue(true);
146+
}
147+
137148

138149
}

src/test/java/multichain/command/TestConst.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
public class TestConst {
44
public static String MULTICHAIN_SERVER_IP = "localhost";
5-
public static String MULTICHAIN_SERVER_PORT = "6824";
5+
public static String MULTICHAIN_SERVER_PORT = "9218";
66
public static String MULTICHAIN_SERVER_LOGIN = "multichainrpc";
7-
public static String MULTICHAIN_SERVER_PWD = "73oYQWzx45hossFPPWUgicpLvHhsD8PempYxnSF6bnY9";
7+
public static String MULTICHAIN_SERVER_PWD = "D1MQcRZZiQdP6jFCAjTuv8Sno86teBkEbk2eVpZXJqBd";
88
}

0 commit comments

Comments
 (0)