Skip to content

Commit bbcd90e

Browse files
authored
Merge pull request #379 from tronprotocol/master
merge master to develop
2 parents 6477f1a + b06bfe3 commit bbcd90e

File tree

4 files changed

+40
-8
lines changed

4 files changed

+40
-8
lines changed

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ soliditynode = {
2929
"solidity ip : port"
3030
]
3131
} // NOTE: solidity node is optional
32+
33+
blockNumberStartToScan = 22690588 // NOTE: this field is optional
3234
```
3335

3436
### Run a web wallet
@@ -1535,7 +1537,14 @@ d :2fd028965d3b455579ab28
15351537

15361538
## How to transfer shielded TRC20 token
15371539

1538-
when you begin to transfer TRC20 token to shielded address, you must have a shielded address. The
1540+
If you want to try to transfer shielded TRC20 token, you'd better set the `blockNumberStartToScan` field in `config.conf` file.
1541+
This field is used to set the starting block that the wallet needs to scan. If you ignore this field, or set it to 0,
1542+
the notes you receive will probably take a long time to show up in the wallet. It is recommended that this field is
1543+
set to the block number in which the earliest relevant shielded contract was created. If the exact number is not known,
1544+
this field can be set as follows. If used in mainnet, please set 22690588. If used in Nile testnet, please set 6380000.
1545+
Otherwise, please set 0.
1546+
1547+
When you begin to transfer TRC20 token to shielded address, you must have a shielded address. The
15391548
following commands help to generate shielded account.
15401549

15411550
### GetSpendingKey
@@ -1869,6 +1878,8 @@ type
18691878
18701879
List the note scanned by the local cache address, and the `Scaling Factor`.
18711880

1881+
**NOTE** When you load shielded wallet, the wallet will scan blocks to find the notes others send to you in the backend. This will take a long time, so when you run `ListShieldedTRC20Note`, your notes will not be displayed immediately.
1882+
18721883
Example:
18731884

18741885
```console

src/main/java/org/tron/core/zen/ShieldedTRC20Wrapper.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.tron.core.zen;
22

33
import com.google.protobuf.ByteString;
4+
import com.typesafe.config.Config;
45
import io.netty.util.internal.StringUtil;
56
import lombok.Getter;
67
import lombok.Setter;
@@ -11,6 +12,7 @@
1112
import org.tron.common.utils.ByteArray;
1213
import org.tron.common.utils.ByteUtil;
1314
import org.tron.common.utils.Utils;
15+
import org.tron.core.config.Configuration;
1416
import org.tron.core.exception.CipherException;
1517
import org.tron.core.exception.ZksnarkException;
1618
import org.tron.core.zen.address.KeyIo;
@@ -62,9 +64,22 @@ public class ShieldedTRC20Wrapper {
6264
@Getter
6365
@Setter
6466
public List<ShieldedTRC20NoteInfo> spendUtxoList = new ArrayList<>();
67+
@Getter
68+
@Setter
69+
public static long defaultBlockNumberToScan = 0;
6570

6671
private boolean loadShieldedStatus = false;
6772

73+
static {
74+
Config config = Configuration.getByPath("config.conf");
75+
if (config.hasPath("blockNumberStartToScan")) {
76+
try {
77+
defaultBlockNumberToScan = config.getLong("blockNumberStartToScan");
78+
} catch (Exception e) {
79+
}
80+
}
81+
}
82+
6883
private ShieldedTRC20Wrapper() {
6984
thread = new Thread(new scanIvkRunable());
7085
}
@@ -206,7 +221,7 @@ private void resetShieldedTRC20Note() throws ZksnarkException {
206221
byte[] key = ByteUtil.merge(entry.getValue().getIvk(),
207222
entry.getValue().getFullViewingKey().getAk(),
208223
entry.getValue().getFullViewingKey().getNk());
209-
ivkMapScanBlockNum.put(ByteArray.toHexString(key), 0L);
224+
ivkMapScanBlockNum.put(ByteArray.toHexString(key), defaultBlockNumberToScan);
210225
}
211226

212227
utxoMapNote.clear();
@@ -234,8 +249,8 @@ private void scanBlockByIvk() throws CipherException {
234249
long start = entry.getValue();
235250
long end = start;
236251
while (end < blockNum) {
237-
if (blockNum - start > 1000) {
238-
end = start + 1000;
252+
if (blockNum - start > 200) { // scan 200 blocks at a time
253+
end = start + 200;
239254
} else {
240255
end = blockNum;
241256
}
@@ -293,10 +308,10 @@ private void scanBlockByIvk() throws CipherException {
293308
}
294309
}
295310
start = end;
311+
ivkMapScanBlockNum.put(entry.getKey(), start);
312+
updateIvkAndBlockNumFile();
296313
}
297-
ivkMapScanBlockNum.put(entry.getKey(), blockNum);
298314
}
299-
updateIvkAndBlockNumFile();
300315
}
301316
}
302317

@@ -369,7 +384,7 @@ public boolean addNewShieldedTRC20Address(final ShieldedAddressInfo addressInfo,
369384
boolean newAddress)
370385
throws CipherException, ZksnarkException {
371386
appendAddressInfoToFile(addressInfo);
372-
long blockNum = 0;
387+
long blockNum = defaultBlockNumberToScan;
373388
if (newAddress) {
374389
try {
375390
Block block = WalletApi.getBlock(-1);

src/main/java/org/tron/walletcli/Client.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2112,7 +2112,7 @@ private void deployContract(String[] parameter)
21122112
if (isHex) {
21132113
codeStr += argsStr;
21142114
} else {
2115-
codeStr += Hex.toHexString(AbiUtil.encodeInput(constructorStr, argsStr));
2115+
codeStr += AbiUtil.parseMethod(constructorStr, argsStr);
21162116
}
21172117
}
21182118
long value = 0;

src/main/resources/config.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,9 @@ fullnode = {
1515
#}
1616

1717
RPC_version = 2
18+
19+
# This field used in shielded transaction. It is recommended that this field is set to the block
20+
# number in which the earliest relevant shielded contract was created. If the exact number is not
21+
# known, this field can be set as follows. If used in mainnet, please set 22690588. If used in Nile
22+
# testnet, please set 6380000. Otherwise, please set 0.
23+
blockNumberStartToScan = 22690588

0 commit comments

Comments
 (0)