Skip to content

Commit

Permalink
Merge pull request #65 from MarcelusCH/master
Browse files Browse the repository at this point in the history
Update for 2.0.7-u3 | Add Raw Tx with data field
  • Loading branch information
cryptorex authored Jul 7, 2022
2 parents bd47504 + d03d512 commit 1bbc193
Show file tree
Hide file tree
Showing 12 changed files with 1,201 additions and 252 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# BitcoinZ Wallet 2.0.7-u2
# BitcoinZ Wallet 2.0.7-u3

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

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-u2.deb"
<deb destfile="${ubuntu.package.dir}/bitcoinz-wallet_2.0.7-u3.deb"
control="${src.dir}/resources/ubuntu-package"
verbose="true">

Expand Down
18 changes: 7 additions & 11 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-u2 \n \n" +
" Version 2.0.7-u3 \n \n" +

" Copyright (c) 2017-2022 BitcoinZ team \n" +
" Copyright (c) 2016-2018 Ivan Vaklinov &lt;[email protected]&gt; \n" +
Expand Down Expand Up @@ -115,8 +115,6 @@ public AboutDialog(JFrame parent) throws UnsupportedEncodingException{





// ************ About Panel start here ****************************
// Logo
URL iconUrl = this.getClass().getClassLoader().getResource("images/bitcoinz60x60.png");
Expand All @@ -130,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-u2</html>");
"BitcoinZ Wallet UI</span></b><br>&nbsp;Version 2.0.7-u3</html>");

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

"<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>"+
"- Code tweak and refresh. <br><br>"+

"<b><u>v2.0.7-u2 (FEB-2022)</u></b><br>"+
"- Complete BTCZ'ify of the source code. <br>"+
"- Refresh of the About dialog box. <br>"+
Expand All @@ -198,8 +201,6 @@ public AboutDialog(JFrame parent) throws UnsupportedEncodingException{
"<b><u>v2.0.7</u></b><br>"+
"- BitcoinZ Yoda node update. <br>"+



"</div>"+
"</html>");

Expand All @@ -211,18 +212,13 @@ public AboutDialog(JFrame parent) throws UnsupportedEncodingException{
JScrollPane updatePanel = new JScrollPane(scrollPanel);






// ************ System Panel start here ****************************
JPanel systemInfoPanel = new JPanel();
systemInfoPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
systemInfoPanel.setLayout(new BorderLayout(3, 3));




// Add the panels to the TAB panel
tabs.add("About", aboutPanel);
tabs.add("Update Log", updatePanel);
Expand Down
118 changes: 118 additions & 0 deletions src/java/com/bitcoinz/btczui/BTCZClientCaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,85 @@ public synchronized String createNewAddress(boolean isZAddress)
}







// Returns tx hash
public synchronized String sendRAWtx(String from, String to, String amount, String memo, String transactionFee)
throws WalletCallException, IOException, InterruptedException
{

StringBuilder hexMemo = new StringBuilder();
for (byte c : memo.getBytes("UTF-8"))
{
String hexChar = Integer.toHexString((int)c);
if (hexChar.length() < 2)
{
hexChar = "0" + hexChar;
}
hexMemo.append(hexChar);
}

DecimalFormatSymbols decSymbols = new DecimalFormatSymbols(Locale.ROOT);


// Transaction fee as a number
if ((transactionFee == null) || (transactionFee.trim().length() <= 0)) {
transactionFee = "0.0001"; // Default value
} else {
transactionFee = new DecimalFormat(
"########0.00######", decSymbols).format(Double.valueOf(transactionFee));
}


// Get the unspent array "[\"t1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\"]@
JsonArray responseUnspent = this.executeCommandAndGetJsonArray("listunspent", "0", "99999", "[\""+from+"\"]");
JsonObject jsonObj = responseUnspent.get(0).asObject();
String status = jsonObj.getString("status", "ERROR");
Log.info("The unspent are: " + responseUnspent.toString());

// Get all unspent amount
Double amountUnspentTot = 0.0;
for (int i=0;i<responseUnspent.size();i++) {
jsonObj = responseUnspent.get(i).asObject();
amountUnspentTot += jsonObj.getDouble("amount", 0.00);
}


// Get the return amount
Double returnAmount = amountUnspentTot - (Double.valueOf(amount) + Double.valueOf(transactionFee));

// Set the tx json array
String txAddr = "";
if (to == from) {
amount += returnAmount;
txAddr = "{\""+to+"\" : "+new DecimalFormat("########0.00######", decSymbols).format(Double.valueOf(amount))+", \"data\" : \""+hexMemo+"\"}";
} else if (returnAmount == 0) {
txAddr = "{\""+to+"\" : "+new DecimalFormat("########0.00######", decSymbols).format(Double.valueOf(amount))+", \"data\" : \""+hexMemo+"\"}";
} else {
txAddr = "{\""+to+"\" : "+new DecimalFormat("########0.00######", decSymbols).format(Double.valueOf(amount))+", \""+from+"\" : "+new DecimalFormat("########0.00######", decSymbols).format(returnAmount)+", \"data\" : \""+hexMemo+"\"}";
}

Log.info("The tx are: " + txAddr);
String rawTX = this.executeCommandAndGetSingleStringResponse("createrawtransaction", wrapStringParameter(responseUnspent.toString()), wrapStringParameter(txAddr));

Log.info("The following raw TX will be signed: " + rawTX.trim());
JsonObject signedTX = this.executeCommandAndGetJsonObject("signrawtransaction", rawTX.trim());

Log.info("The following signed TX will be sent: " + signedTX.getString("hex", "ERROR"));
String txHex = this.executeCommandAndGetSingleStringResponse("sendrawtransaction", signedTX.getString("hex", "ERROR"));

return txHex.trim();
}







// Returns OPID
public synchronized String sendCash(String from, String to, String amount, String memo, String transactionFee)
throws WalletCallException, IOException, InterruptedException
Expand Down Expand Up @@ -1106,6 +1185,24 @@ private JsonArray executeCommandAndGetJsonArray(String command1, String command2
}


private JsonArray executeCommandAndGetJsonArray(String command1, String command2, String command3, String command4)
throws WalletCallException, IOException, InterruptedException
{
JsonValue response = this.executeCommandAndGetJsonValue(command1, command2, command3, command4);

if (response.isArray())
{
return response.asArray();
} else
{
throw new WalletCallException("Unexpected non-array response from wallet: " + response.toString());
}
}





private JsonValue executeCommandAndGetJsonValue(String command1, String command2)
throws WalletCallException, IOException, InterruptedException
{
Expand All @@ -1131,6 +1228,27 @@ private JsonValue executeCommandAndGetJsonValue(String command1, String command2
}



private JsonValue executeCommandAndGetJsonValue(String command1, String command2, String command3, String command4)
throws WalletCallException, IOException, InterruptedException
{
String strResponse = this.executeCommandAndGetSingleStringResponse(command1, command2, command3, command4);

JsonValue response = null;
try
{
response = Json.parse(strResponse);
} catch (ParseException pe)
{
throw new WalletCallException(strResponse + "\n" + pe.getMessage() + "\n", pe);
}

return response;
}




private String executeCommandAndGetSingleStringResponse(String command1)
throws WalletCallException, IOException, InterruptedException
{
Expand Down
30 changes: 26 additions & 4 deletions src/java/com/bitcoinz/btczui/BtczUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
import com.bitcoinz.btczui.BTCZInstallationObserver.DaemonInfo;
import com.bitcoinz.btczui.BTCZInstallationObserver.InstallationDetectionException;
import com.bitcoinz.btczui.msg.MessagingPanel;
import com.bitcoinz.btczui.msg.MessagingStorage;
//import com.bitcoinz.btczui.msg.MessagingOptions;



/**
Expand Down Expand Up @@ -101,8 +104,10 @@ public class BtczUI
private DashboardPanel dashboard;
private AddressesPanel addresses;
private SendCashPanel sendPanel;
private RawTXPanel rawTXPanel;
private AddressBookPanel addressBookPanel;
private MessagingPanel messagingPanel;
private MessagingStorage messagingStorage;
private List<Image> imageList;

JTabbedPane tabs;
Expand All @@ -111,7 +116,7 @@ public class BtczUI
public BtczUI(StartupProgressDialog progressDialog)
throws IOException, InterruptedException, WalletCallException
{
super("BitcoinZ Wallet 2.0.7-u2");
super("BitcoinZ Wallet 2.0.7-u3");

if (progressDialog != null)
{
Expand Down Expand Up @@ -159,12 +164,24 @@ public BtczUI(StartupProgressDialog progressDialog)
tabs.addTab("Send cash ",
new ImageIcon(cl.getResource("images/send.png")),
sendPanel = new SendCashPanel(clientCaller, errorReporter, installationObserver, backupTracker));

tabs.addTab("Raw Transaction ",
new ImageIcon(cl.getResource("images/send.png")),
rawTXPanel = new RawTXPanel(clientCaller, errorReporter, installationObserver, backupTracker));

tabs.addTab("Address book ",
new ImageIcon(cl.getResource("images/address-book.png")),
addressBookPanel = new AddressBookPanel(sendPanel, tabs));

tabs.addTab("Messaging ",
new ImageIcon(cl.getResource("images/messaging.png")),
messagingPanel = new MessagingPanel(this, sendPanel, tabs, clientCaller, errorReporter));
new ImageIcon(cl.getResource("images/messaging.png")),
messagingPanel = new MessagingPanel(this, sendPanel, tabs, clientCaller, errorReporter));

// Disable Messaging tab option
messagingStorage = new MessagingStorage();
boolean msgDisabled = messagingStorage.getMessagingOptions().isMessagingDisabled();
if (msgDisabled) {tabs.setEnabledAt(5,false);}

contentPane.add(tabs);

this.walletOps = new WalletOperations(
Expand Down Expand Up @@ -235,9 +252,14 @@ public BtczUI(StartupProgressDialog progressDialog)
shareFileVia.add(menuItemShareFileViaIPFS = new JMenuItem("IPFS", KeyEvent.VK_F));
menuItemShareFileViaIPFS.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, accelaratorKeyMask));

mb.add(messaging);
// TODO: Move the zMessaging disable option somwhere else.
// This will allows to also disable the menu.
//if (!msgDisabled) {
mb.add(messaging);
//}

// TODO: Temporarily disable encryption until further notice - Oct 24 2016
// Enabled as own user risk !
//menuItemEncrypt.setEnabled(false);

this.setJMenuBar(mb);
Expand Down
Loading

0 comments on commit 1bbc193

Please sign in to comment.