Skip to content

Commit

Permalink
2.0.8 (#67)
Browse files Browse the repository at this point in the history
* Add Private Viewing Key (pvk) capability

* add vk tag in the txs table

* Add VK import

* Versioning 2.0.8-rc1

* Update version as stable

Co-authored-by: MarcelusCH <[email protected]>
  • Loading branch information
cryptorex and MarcelusCH authored Sep 9, 2022
1 parent 1bbc193 commit 94cd5b2
Show file tree
Hide file tree
Showing 16 changed files with 143 additions and 63 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# BitcoinZ Wallet 2.0.7-u3
# BitcoinZ Wallet 2.0.8

[Download here](https://github.com/btcz/bitcoinz-wallet/releases)

Expand Down Expand Up @@ -83,7 +83,7 @@ The details of how to build it are described below (easy to follow).

3.1. If you have built BitcoinZ from source code:

Assuming you have already built from source code [BitcoinZ](https://github.com/btcz/bitcoinz) in directory `/home/user/bitcoinz/src` (for example - this is the typical build dir. for bitcoinz v2.0.7) which contains the command line tools `bitcoinz-cli` and `bitcoinzd` you need to take the created file `./build/jars/BitcoinZWallet.jar` and copy it to directory `/home/user/bitcoinz/src` (the same dir. that contains `bitcoinz-cli` and `bitcoinzd`). Example copy command:
Assuming you have already built from source code [BitcoinZ](https://github.com/btcz/bitcoinz) in directory `/home/user/bitcoinz/src` (for example - this is the typical build dir. for bitcoinz v2.0.8) which contains the command line tools `bitcoinz-cli` and `bitcoinzd` you need to take the created file `./build/jars/BitcoinZWallet.jar` and copy it to directory `/home/user/bitcoinz/src` (the same dir. that contains `bitcoinz-cli` and `bitcoinzd`). Example copy command:
```
cp ./build/jars/BitcoinZWallet.jar /home/user/zen/src
```
Expand Down
2 changes: 1 addition & 1 deletion src/build/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@

<target name="ubuntuPackage" depends="jar,copyothers">
<mkdir dir="${ubuntu.package.dir}"/>
<deb destfile="${ubuntu.package.dir}/bitcoinz-wallet_2.0.7-u3.deb"
<deb destfile="${ubuntu.package.dir}/bitcoinz-wallet_2.0.8.deb"
control="${src.dir}/resources/ubuntu-package"
verbose="true">

Expand Down
7 changes: 5 additions & 2 deletions src/java/com/bitcoinz/btczui/AboutDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public AboutDialog(JFrame parent) throws UnsupportedEncodingException{
" |____/ | | | |/ / / / \\ \\| | | |\\ | | / / \\ \\ /\\ / / _` | | |/ _ \\ __| | | || | \n" +
" | ___ \\| |_ | |\\ \\__ \\ \\_/ /| |_ | | \\ | / /_ \\ V V / (_| | | | __/ |_| |_| || | \n" +
" |_____/____| |_| \\____|\\___/_____||_| \\_|/____| \\_/\\_/ \\__,_|_|_|\\___|\\__|\\___/|___| \n" +
" Version 2.0.7-u3 \n \n" +
" Version 2.0.8 \n \n" +

" Copyright (c) 2017-2022 BitcoinZ team \n" +
" Copyright (c) 2016-2018 Ivan Vaklinov &lt;[email protected]&gt; \n" +
Expand Down Expand Up @@ -128,7 +128,7 @@ public AboutDialog(JFrame parent) throws UnsupportedEncodingException{
aboutNORTH_CENTER.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
aboutNORTH_CENTER.setText(
"<html><b><span style='font-weight:bold;font-size:2.3em'>" +
"BitcoinZ Wallet UI</span></b><br>&nbsp;Version 2.0.7-u3</html>");
"BitcoinZ Wallet UI</span></b><br>&nbsp;Version 2.0.8</html>");

// About description
JLabel aboutCENTER = new JLabel();
Expand Down Expand Up @@ -181,6 +181,9 @@ public AboutDialog(JFrame parent) throws UnsupportedEncodingException{
"<html>" +
"<div style='display: table; padding: 10px; height: 400px; max-width: 600px; overflow: hidden;'> " +

"<b><u>v2.0.8 (SEP-2022)</u></b><br>"+
"- Added Viewing key import and usage. <br><br>"+

"<b><u>v2.0.7-u3 (MAY-2022)</u></b><br>"+
"- Added option to disable the (z) messaging. <br>"+
"- Added Raw TX tab with data send capability. <br>"+
Expand Down
8 changes: 4 additions & 4 deletions src/java/com/bitcoinz/btczui/AddressTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void actionPerformed(ActionEvent e){
if ((lastRow >= 0) && (lastColumn >= 0)){
try{

String address = AddressTable.this.getModel().getValueAt(lastRow, 2).toString();
String address = AddressTable.this.getModel().getValueAt(lastRow, 3).toString();
boolean isZAddress = Util.isZAddress(address);

// Check for encrypted wallet
Expand Down Expand Up @@ -121,7 +121,7 @@ public void actionPerformed(ActionEvent e){
if ((lastRow >= 0) && (lastColumn >= 0)){
try{

String address = AddressTable.this.getModel().getValueAt(lastRow, 2).toString();
String address = AddressTable.this.getModel().getValueAt(lastRow, 3).toString();
boolean isZAddress = Util.isZAddress(address);

// Check for encrypted wallet
Expand Down Expand Up @@ -176,7 +176,7 @@ public void actionPerformed(ActionEvent e){
if ((lastRow >= 0) && (lastColumn >= 0)){
try{

String address = AddressTable.this.getModel().getValueAt(lastRow, 2).toString();
String address = AddressTable.this.getModel().getValueAt(lastRow, 3).toString();
boolean isZAddress = Util.isZAddress(address);

// Check for encrypted wallet
Expand Down Expand Up @@ -253,7 +253,7 @@ public void actionPerformed(ActionEvent e)
{
try
{
String address = AddressTable.this.getModel().getValueAt(lastRow, 2).toString();
String address = AddressTable.this.getModel().getValueAt(lastRow, 3).toString();
boolean isZAddress = Util.isZAddress(address);

// Check for encrypted wallet
Expand Down
26 changes: 20 additions & 6 deletions src/java/com/bitcoinz/btczui/AddressesPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

Expand Down Expand Up @@ -334,12 +335,13 @@ private synchronized void updateWalletAddressBalanceTableAutomated()
private JTable createAddressBalanceTable(String rowData[][])
throws WalletCallException, IOException, InterruptedException
{
String columnNames[] = { "Balance", "Confirmed?", "Address" };
String columnNames[] = { "Balance", "Confirmed?", "", "Address" };
JTable table = new AddressTable(rowData, columnNames, this.clientCaller);
table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
table.getColumnModel().getColumn(0).setPreferredWidth(160);
table.getColumnModel().getColumn(1).setPreferredWidth(140);
table.getColumnModel().getColumn(2).setPreferredWidth(1000);
table.getColumnModel().getColumn(2).setPreferredWidth(80);
table.getColumnModel().getColumn(3).setPreferredWidth(1000);

return table;
}
Expand All @@ -348,8 +350,11 @@ private JTable createAddressBalanceTable(String rowData[][])
private String[][] getAddressBalanceDataFromWallet()
throws WalletCallException, IOException, InterruptedException
{
// Z Addresses - they are OK
String[] zAddresses = clientCaller.getWalletZAddresses();
// Z Addresses
// Modified to get also the Viewing Key
List<List> zAdrrData = clientCaller.getWalletZAddresses();
List<String> zAddresses = zAdrrData.get(0);
List<Boolean> isVKsOnly = zAdrrData.get(1);

// T Addresses listed with the list received by addr comamnd
String[] tAddresses = this.clientCaller.getWalletAllPublicAddresses();
Expand All @@ -372,7 +377,7 @@ private String[][] getAddressBalanceDataFromWallet()
tAddressesCombined.addAll(tStoredAddressSet);
tAddressesCombined.addAll(tAddressSetWithUnspentOuts);

String[][] addressBalances = new String[zAddresses.length + tAddressesCombined.size()][];
String[][] addressBalances = new String[zAddresses.size() + tAddressesCombined.size()][];

// Format double numbers - else sometimes we get exponential notation 1E-4 BTCZ
DecimalFormat df = new DecimalFormat("########0.00######");
Expand Down Expand Up @@ -432,12 +437,19 @@ private String[][] getAddressBalanceDataFromWallet()
{
balanceToShow,
isConfirmed ? ("Yes " + confirmed) : ("No " + notConfirmed),
"",
addressToDisplay
};
}

for (String address : zAddresses)



for (int ii = 0; ii < zAddresses.size(); ii++)
{
boolean isVKonly = isVKsOnly.get(ii);
String address = zAddresses.get(ii);

String confirmedBalance = this.clientCaller.getBalanceForAddress(address);
String unconfirmedBalance = this.clientCaller.getUnconfirmedBalanceForAddress(address);
boolean isConfirmed = (confirmedBalance.equals(unconfirmedBalance));
Expand All @@ -448,8 +460,10 @@ private String[][] getAddressBalanceDataFromWallet()
{
balanceToShow,
isConfirmed ? ("Yes " + confirmed) : ("No " + notConfirmed),
isVKonly ? ("vk") : (""),
address
};

}

return addressBalances;
Expand Down
80 changes: 64 additions & 16 deletions src/java/com/bitcoinz/btczui/BTCZClientCaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,53 +240,86 @@ public synchronized String[][] getWalletPublicTransactions()
String strTransactions[][] = new String[jsonTransactions.size()][];
for (int i = 0; i < jsonTransactions.size(); i++)
{
strTransactions[i] = new String[7];
strTransactions[i] = new String[8];
JsonObject trans = jsonTransactions.get(i).asObject();

// Needs to be the same as in getWalletZReceivedTransactions()
// TODO: some day refactor to use object containers
strTransactions[i][0] = "\u2606T (Public)";
strTransactions[i][1] = trans.getString("category", "ERROR!");
strTransactions[i][2] = trans.get("confirmations").toString();
strTransactions[i][3] = trans.get("amount").toString();
strTransactions[i][4] = trans.get("time").toString();
strTransactions[i][5] = trans.getString("address", notListed + " (Z Address not listed by wallet!)");
strTransactions[i][6] = trans.get("txid").toString();
strTransactions[i][3] = " ";
strTransactions[i][4] = trans.get("amount").toString();
strTransactions[i][5] = trans.get("time").toString();
strTransactions[i][6] = trans.getString("address", notListed + " (Z Address not listed by wallet!)");
strTransactions[i][7] = trans.get("txid").toString();

}

return strTransactions;
}


public synchronized String[] getWalletZAddresses()
// Changed to list return to add viewing key
public synchronized List<List> getWalletZAddresses()
throws WalletCallException, IOException, InterruptedException
{

// Modified for the Viewing key for YODA 2.0.8
// TODO : return the VK advice from the cli ?
JsonArray jsonAddresses = executeCommandAndGetJsonArray("z_listaddresses", null);
String strAddresses[] = new String[jsonAddresses.size()];
JsonArray jsonAddressesVK = executeCommandAndGetJsonArray("z_listaddresses", "true");
List<String> strAddresses = new ArrayList<String>(); // [jsonAddresses.size()+jsonAddressesVK.size()];
List<Boolean> isVKonly = new ArrayList<Boolean>(); //[jsonAddresses.size()+jsonAddressesVK.size()];

for (int i = 0; i < jsonAddresses.size(); i++)
{
strAddresses[i] = jsonAddresses.get(i).asString();
strAddresses.add(jsonAddresses.get(i).asString());
isVKonly.add(false);
}

return strAddresses;
// The order of the keys can not be defined (viwing or spending)
// Also a secound loop needs to be done to diferiencate it... :-|
// TODO: Find a better way or maybe return it from cli directly.
for (int i = 0; i < jsonAddressesVK.size(); i++)
{
if(strAddresses.contains(jsonAddressesVK.get(i).asString()) == false)
{
strAddresses.add(jsonAddressesVK.get(i).asString());
isVKonly.add(true);
}

}

List<List> retVal = new ArrayList<List>();
retVal.add(strAddresses);
retVal.add(isVKonly);
return retVal;
}


public synchronized String[][] getWalletZReceivedTransactions()
throws WalletCallException, IOException, InterruptedException
{
String[] zAddresses = this.getWalletZAddresses();

// Modified to get also the Viewing Key
List<List> zAdrrData = this.getWalletZAddresses();
List<String> zAddresses = zAdrrData.get(0);
List<Boolean> isVKsOnly = zAdrrData.get(1);

List<String[]> zReceivedTransactions = new ArrayList<String[]>();

int k = 0;
for (String zAddress : zAddresses)
{

boolean isVKonly = isVKsOnly.get(k);
k++;

JsonArray jsonTransactions = executeCommandAndGetJsonArray(
"z_listreceivedbyaddress", wrapStringParameter(zAddress), "0");
for (int i = 0; i < jsonTransactions.size(); i++)
{
String[] currentTransaction = new String[7];
String[] currentTransaction = new String[8];
JsonObject trans = jsonTransactions.get(i).asObject();

String txID = trans.getString("txid", "ERROR!");
Expand All @@ -295,10 +328,11 @@ public synchronized String[][] getWalletZReceivedTransactions()
currentTransaction[0] = "\u2605Z (Private)";
currentTransaction[1] = "receive";
currentTransaction[2] = this.getWalletTransactionConfirmations(txID);
currentTransaction[3] = trans.get("amount").toString();
currentTransaction[4] = this.getWalletTransactionTime(txID); // TODO: minimize sub-calls
currentTransaction[5] = zAddress;
currentTransaction[6] = trans.get("txid").toString();
currentTransaction[3] = isVKonly ? ("vk") : ("");
currentTransaction[4] = trans.get("amount").toString();
currentTransaction[5] = this.getWalletTransactionTime(txID); // TODO: minimize sub-calls
currentTransaction[6] = zAddress;
currentTransaction[7] = trans.get("txid").toString();

zReceivedTransactions.add(currentTransaction);
}
Expand Down Expand Up @@ -1139,6 +1173,20 @@ else if (isTestnet == true ? first_letter.equals("9") || first_letter.equals("c"
}
else throw new WalletCallException("Unexpected response from wallet: " + strResult); // Obviously an error
}
// The Viewing Key bigin with z : zxviews1qvnx7...
else if (first_letter.equals("Z") || first_letter.equals("z"))
{
String strResult = this.executeCommandAndGetSingleStringResponse(
"-rpcclienttimeout=5000", "z_importviewingkey", wrapStringParameter(key));

// TODO: Give the possibility to rescan. By default the VK do not rescan.

if (!strResult.trim().toLowerCase(Locale.ROOT).contains("error"))
{
return strResult == null ? "" : strResult.trim();
}
else throw new WalletCallException("Unexpected response from wallet: " + strResult); // Obviously an error
}
else
{
throw new WalletCallException(isTestnet == true ? "TestNet private key should start with a '9' or 'c'" : "Single private key should start with L, K, or 5");
Expand Down
2 changes: 1 addition & 1 deletion src/java/com/bitcoinz/btczui/BtczUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public class BtczUI
public BtczUI(StartupProgressDialog progressDialog)
throws IOException, InterruptedException, WalletCallException
{
super("BitcoinZ Wallet 2.0.7-u3");
super("BitcoinZ Wallet 2.0.8");

if (progressDialog != null)
{
Expand Down
27 changes: 14 additions & 13 deletions src/java/com/bitcoinz/btczui/DashboardPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -587,16 +587,17 @@ private void updateWalletTransactionsTable()
private JTable createTransactionsTable(String rowData[][])
throws WalletCallException, IOException, InterruptedException
{
String columnNames[] = { "Type", "Direction", "Confirmed?", "Amount", "Date", "Destination Address"};
String columnNames[] = { "Type", "Direction", "Confirmed?", " ", "Amount", "Date", "Destination Address"};
JTable table = new TransactionTable(
rowData, columnNames, this.parentFrame, this.clientCaller, this.installationObserver);
table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
table.getColumnModel().getColumn(0).setPreferredWidth(190);
table.getColumnModel().getColumn(1).setPreferredWidth(145);
table.getColumnModel().getColumn(2).setPreferredWidth(170);
table.getColumnModel().getColumn(3).setPreferredWidth(210);
table.getColumnModel().getColumn(4).setPreferredWidth(405);
table.getColumnModel().getColumn(5).setPreferredWidth(800);
table.getColumnModel().getColumn(3).setPreferredWidth(80);
table.getColumnModel().getColumn(4).setPreferredWidth(210);
table.getColumnModel().getColumn(5).setPreferredWidth(405);
table.getColumnModel().getColumn(6).setPreferredWidth(800);

return table;
}
Expand Down Expand Up @@ -628,15 +629,15 @@ private String[][] getTransactionsDataFromWallet()
public int compare(String[] o1, String[] o2)
{
Date d1 = new Date(0);
if (!o1[4].equals("N/A"))
if (!o1[5].equals("N/A"))
{
d1 = new Date(Long.valueOf(o1[4]).longValue() * 1000L);
d1 = new Date(Long.valueOf(o1[5]).longValue() * 1000L);
}

Date d2 = new Date(0);
if (!o2[4].equals("N/A"))
if (!o2[5].equals("N/A"))
{
d2 = new Date(Long.valueOf(o2[4]).longValue() * 1000L);
d2 = new Date(Long.valueOf(o2[5]).longValue() * 1000L);
}

if (d1.equals(d2))
Expand Down Expand Up @@ -684,23 +685,23 @@ public int compare(String[] o1, String[] o2)
};

// Date
if (!trans[4].equals("N/A"))
if (!trans[5].equals("N/A"))
{
trans[4] = new Date(Long.valueOf(trans[4]).longValue() * 1000L).toLocaleString();
trans[5] = new Date(Long.valueOf(trans[5]).longValue() * 1000L).toLocaleString();
}

// Amount
try
{
double amount = Double.valueOf(trans[3]);
double amount = Double.valueOf(trans[4]);
if (amount < 0d)
{
amount = -amount;
}
trans[3] = df.format(amount);
trans[4] = df.format(amount);
} catch (NumberFormatException nfe)
{
Log.error("Error occurred while formatting amount: " + trans[3] +
Log.error("Error occurred while formatting amount: " + trans[4] +
" - " + nfe.getMessage() + "!");
}

Expand Down
Loading

0 comments on commit 94cd5b2

Please sign in to comment.