Skip to content

Commit 18ad045

Browse files
author
Hubert Marteau
committed
2.0 - BlockChain used like a object to manage a few BlockChains in the
same code & Stream management added
1 parent a1de1c9 commit 18ad045

38 files changed

+4966
-2481
lines changed

src/multichain/command/AddressCommand.java

Lines changed: 149 additions & 123 deletions
Large diffs are not rendered by default.

src/multichain/command/BalanceCommand.java

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,34 @@
1616

1717
/**
1818
* @author Ub - H. MARTEAU
19-
* @version 1.0
19+
* @version 2.0
2020
*/
2121
public class BalanceCommand extends QueryBuilderBalance {
22+
public BalanceCommand(String chainName) {
23+
setCHAIN(chainName);
24+
}
25+
2226
/**
23-
*
27+
*
2428
* gettotalbalances ( minconf includeWatchonly includeLocked)
25-
*
26-
* If account is not specified, returns the server's total available asset balances.
27-
* If account is specified, returns the balances in the account.
29+
*
30+
* If account is not specified, returns the server's total available asset
31+
* balances. If account is specified, returns the balances in the account.
2832
* Note that the account "" is not the same as leaving the parameter out.
29-
* The server total may be different to the balance in the default "" account.
30-
*
31-
* Arguments:
32-
* 1. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.
33-
* 2. includeWatchonly (bool, optional, default=false) Also include balance in watchonly addresses (see 'importaddress')
34-
* 3. includeLocked (bool, optional, default=false) Also take locked outputs into account
35-
* Results are an array of Objects with totals and details for each asset.
36-
*
33+
* The server total may be different to the balance in the default ""
34+
* account.
35+
*
36+
* Arguments: 1. minconf (numeric, optional, default=1) Only include
37+
* transactions confirmed at least this many times. 2. includeWatchonly
38+
* (bool, optional, default=false) Also include balance in watchonly
39+
* addresses (see 'importaddress') 3. includeLocked (bool, optional,
40+
* default=false) Also take locked outputs into account Results are an array
41+
* of Objects with totals and details for each asset.
42+
*
3743
* @return a list of all the asset balances in this node’s wallet
3844
* @throws MultichainException
3945
*/
40-
protected static List<BalanceAsset> getTotalBalances() throws MultichainException {
46+
public List<BalanceAsset> getTotalBalances() throws MultichainException {
4147
List<BalanceAsset> listBalanceAsset = new ArrayList<BalanceAsset>();
4248

4349
String stringBalanceAsset = executeGetTotalBalances();
@@ -47,14 +53,13 @@ protected static List<BalanceAsset> getTotalBalances() throws MultichainExceptio
4753
}
4854

4955
/**
50-
*
51-
* getunconfirmedbalance
52-
* Returns the server's total unconfirmed balance
53-
*
56+
*
57+
* getunconfirmedbalance Returns the server's total unconfirmed balance
58+
*
5459
* @return not formated balance
5560
* @throws MultichainException
5661
*/
57-
protected static String getUnconfirmedBalance() throws MultichainException {
62+
public String getUnconfirmedBalance() throws MultichainException {
5863
return executeGetUnconfirmedBalance();
5964
}
6065

src/multichain/command/BlockCommand.java

Lines changed: 63 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -13,141 +13,151 @@
1313

1414
/**
1515
* @author Ub - H. MARTEAU
16-
* @version 1.0
16+
* @version 2.0
1717
*/
1818
public class BlockCommand extends QueryBuilderBlock {
1919

20+
public BlockCommand(String chainName) {
21+
setCHAIN(chainName);
22+
}
23+
2024
/**
2125
* getbestblockhash
22-
*
26+
*
2327
* Returns the hash of the best (tip) block in the longest block chain.
24-
*
28+
*
2529
* Result
26-
* "hex" (string) the block hash hex encoded
27-
*
30+
* "hex" (string) the block hash hex encoded
31+
*
2832
* @return the hash of the best block
2933
* @throws MultichainException
3034
*/
31-
public static String getBestBlockHash() throws MultichainException {
35+
public String getBestBlockHash() throws MultichainException {
3236
return executeGetBestBlockHash();
3337
}
3438

35-
3639
/**
3740
* getblock "hash/height" ( verbose )
38-
*
41+
*
3942
* If verbose is false, returns a string that is serialized, hex-encoded data for block 'hash'.
4043
* If verbose is true, returns an Object with information about block <hash>.
41-
*
44+
*
4245
* Arguments:
43-
* 1. "hash/height" (string, required) The block hash or block height in active chain
44-
* 2. verbose (boolean, optional, default=true) true for a json object, false for the hex encoded data
45-
*
46+
* 1. "hash/height" (string, required) The block hash or block height in active chain
47+
* 2. verbose (boolean, optional, default=true) true for a json object, false for the hex encoded data
48+
*
4649
* Result (for verbose = true):
4750
* {
48-
* "hash" : "hash", (string) the block hash (same as provided)
49-
* "miner" : "miner", (string) the address of the miner
50-
* "confirmations" : n, (numeric) The number of confirmations, or -1 if the block is not on the main chain
51-
* "size" : n, (numeric) The block size
52-
* "height" : n, (numeric) The block height or index
53-
* "version" : n, (numeric) The block version
54-
* "merkleroot" : "xxxx", (string) The merkle root
55-
* "tx" : [ (array of string) The transaction ids
56-
* "transactionid" (string) The transaction id
57-
* ,...
58-
* ],
59-
* "time" : ttt, (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)
60-
* "nonce" : n, (numeric) The nonce
61-
* "bits" : "1d00ffff", (string) The bits
62-
* "difficulty" : x.xxx, (numeric) The difficulty
63-
* "previousblockhash" : "hash", (string) The hash of the previous block
64-
* "nextblockhash" : "hash" (string) The hash of the next block
51+
* "hash" : "hash", (string) the block hash (same as provided)
52+
* "miner" : "miner", (string) the address of the miner
53+
* "confirmations" : n, (numeric) The number of confirmations, or -1 if the block is not on the main chain
54+
* "size" : n, (numeric) The block size
55+
* "height" : n, (numeric) The block height or index
56+
* "version" : n, (numeric) The block version
57+
* "merkleroot" : "xxxx", (string) The merkle root
58+
* "tx" : [ (array of string) The transaction ids
59+
* "transactionid" (string) The transaction id
60+
* ,...
61+
* ],
62+
* "time" : ttt, (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)
63+
* "nonce" : n, (numeric) The nonce
64+
* "bits" : "1d00ffff", (string) The bits
65+
* "difficulty" : x.xxx, (numeric) The difficulty
66+
* "previousblockhash" : "hash", (string) The hash of the previous block
67+
* "nextblockhash" : "hash" (string) The hash of the next block
6568
* }
66-
*
69+
*
6770
* Result (for verbose=false):
68-
* "data" (string) A string that is serialized, hex-encoded data for block 'hash'.
69-
*
70-
*
71+
* "data" (string) A string that is serialized, hex-encoded data for block 'hash'.
72+
*
73+
*
7174
* @param hashOrHeight
7275
* @param verbose
73-
* @return Block : information about the block with hash (retrievable from getblockhash) or at the given height in the active chain
76+
* @return Block : information about the block with hash (retrievable from getblockhash) or at the given height in
77+
* the active chain
7478
* @throws MultichainException
7579
*/
76-
public static Block getBlock(String blockHash, boolean verbose) throws MultichainException {
80+
public Block getBlock(String blockHash, boolean verbose) throws MultichainException {
7781
String stringBlock = executeGetBlock(blockHash, verbose);
7882

7983
return BlockFormatter.formatBlock(stringBlock);
8084
}
8185

8286
/**
8387
* {@link #getBlock(String, boolean)} without verbose
88+
*
8489
* @param blockHash
85-
* @return Block : information about the block with hash (retrievable from getblockhash) or at the given height in the active chain
90+
* @return Block : information about the block with hash (retrievable from getblockhash) or at the given height in
91+
* the active chain
8692
* @throws MultichainException
8793
*/
88-
public static Block getBlock(String blockHash) throws MultichainException {
94+
public Block getBlock(String blockHash) throws MultichainException {
8995
String stringBlock = executeGetBlock(blockHash, true);
9096

9197
return BlockFormatter.formatBlock(stringBlock);
9298
}
9399

94100
/**
95101
* {@link #getBlock(String, boolean)} with long value of Height
102+
*
96103
* @param blockHash
97104
* @param verbose
98-
* @return Block : information about the block with hash (retrievable from getblockhash) or at the given height in the active chain
105+
* @return Block : information about the block with hash (retrievable from getblockhash) or at the given height in
106+
* the active chain
99107
* @throws MultichainException
100108
*/
101-
public static Block getBlock(long blockHeight, boolean verbose) throws MultichainException {
109+
public Block getBlock(long blockHeight, boolean verbose) throws MultichainException {
102110
String blockHash = Long.toString(blockHeight);
103111

104112
return getBlock(blockHash, verbose);
105113
}
106114

107115
/**
108116
* {@link #getBlock(long, boolean)} without verbose
117+
*
109118
* @param blockHash
110-
* @return Block : information about the block with hash (retrievable from getblockhash) or at the given height in the active chain
119+
* @return Block : information about the block with hash (retrievable from getblockhash) or at the given height in
120+
* the active chain
111121
* @throws MultichainException
112122
*/
113-
public static Block getBlock(long blockHeight) throws MultichainException {
123+
public Block getBlock(long blockHeight) throws MultichainException {
114124
String blockHash = Long.toString(blockHeight);
115125

116126
return getBlock(blockHash, true);
117127
}
118128

119129
/**
120130
* getblockcount
121-
*
131+
*
122132
* Returns the number of blocks in the longest block chain.
123-
*
133+
*
124134
* Result:
125-
* n (numeric) The current block count
126-
*
135+
* n (numeric) The current block count
136+
*
127137
* @return The Actual count of blocks in the BlockChain.
128138
* @throws MultichainException
129139
*/
130-
public static long getBlockCount() throws MultichainException {
140+
public long getBlockCount() throws MultichainException {
131141
String stringBlockCount = executeGetBlockCount();
132142

133143
return BlockFormatter.formatBlockCount(stringBlockCount);
134144
}
135145

136146
/**
137147
* getblockhash index
138-
*
148+
*
139149
* Returns hash of block in best-block-chain at index provided.
140-
*
150+
*
141151
* Arguments:
142-
* 1. index (numeric, required) The block index
143-
*
152+
* 1. index (numeric, required) The block index
153+
*
144154
* Result:
145-
* "hash" (string) The block hash
146-
*
155+
* "hash" (string) The block hash
156+
*
147157
* @return the hash of the best block
148158
* @throws MultichainException
149159
*/
150-
public static String getBlockHash(long index) throws MultichainException {
160+
public String getBlockHash(long index) throws MultichainException {
151161
return executeGetBlockHash(index);
152162
}
153163

src/multichain/command/ChainCommand.java

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)