Skip to content

Commit

Permalink
feat(GUI): memo field for transactions on GUI wallet (#1182)
Browse files Browse the repository at this point in the history
  • Loading branch information
kehiy authored Mar 27, 2024
1 parent 6c7ff75 commit 3ba0150
Show file tree
Hide file tree
Showing 8 changed files with 227 additions and 26 deletions.
47 changes: 43 additions & 4 deletions cmd/gtk/assets/ui/dialog_transaction_bond.ui
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<!-- Generated with glade 3.40.0 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<object class="GtkDialog" id="id_dialog_transaction_bond">
Expand Down Expand Up @@ -220,14 +220,53 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Amount:</property>
<property name="label" translatable="yes">Memo:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">11</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="id_entry_memo">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="width-chars">32</property>
<property name="caps-lock-warning">False</property>
<property name="input-purpose">number</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">12</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">13</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Amount:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">14</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="id_entry_amount">
<property name="visible">True</property>
Expand All @@ -241,7 +280,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">12</property>
<property name="position">15</property>
</packing>
</child>
<child>
Expand All @@ -254,7 +293,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">13</property>
<property name="position">16</property>
</packing>
</child>
</object>
Expand Down
46 changes: 42 additions & 4 deletions cmd/gtk/assets/ui/dialog_transaction_transfer.ui
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<!-- Generated with glade 3.40.0 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<object class="GtkDialog" id="id_dialog_transaction_transfer">
Expand Down Expand Up @@ -180,14 +180,52 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Amount:</property>
<property name="label" translatable="yes">Memo:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">8</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="id_entry_memo">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="width-chars">32</property>
<property name="caps-lock-warning">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">9</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">10</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Amount:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">11</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="id_entry_amount">
<property name="visible">True</property>
Expand All @@ -201,7 +239,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">9</property>
<property name="position">12</property>
</packing>
</child>
<child>
Expand All @@ -214,7 +252,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">10</property>
<property name="position">13</property>
</packing>
</child>
</object>
Expand Down
48 changes: 44 additions & 4 deletions cmd/gtk/assets/ui/dialog_transaction_unbond.ui
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<!-- Generated with glade 3.40.0 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<object class="GtkDialog" id="id_dialog_transaction_unbond">
Expand Down Expand Up @@ -105,7 +105,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
<property name="position">1</property>
</packing>
</child>
<child>
Expand All @@ -117,18 +117,58 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Memo:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="id_entry_memo">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="width-chars">32</property>
<property name="caps-lock-warning">False</property>
<property name="input-purpose">number</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">7</property>
<property name="position">6</property>
</packing>
</child>
</object>
Expand Down
65 changes: 61 additions & 4 deletions cmd/gtk/assets/ui/dialog_transaction_withdraw.ui
Original file line number Diff line number Diff line change
@@ -1,7 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<!-- Generated with glade 3.40.0 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<object class="GtkRecentChooserDialog">
<property name="can-focus">False</property>
<property name="type-hint">dialog</property>
<property name="limit">20</property>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="layout-style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkDialog" id="id_dialog_transaction_withdraw">
<property name="width-request">600</property>
<property name="can-focus">False</property>
Expand Down Expand Up @@ -173,13 +202,41 @@
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Memo:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">7</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="id_entry_memo">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="width-chars">32</property>
<property name="caps-lock-warning">False</property>
<property name="input-purpose">number</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">8</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">9</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
Expand All @@ -190,7 +247,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">8</property>
<property name="position">10</property>
</packing>
</child>
<child>
Expand All @@ -206,7 +263,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">9</property>
<property name="position">11</property>
</packing>
</child>
<child>
Expand All @@ -219,7 +276,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">10</property>
<property name="position">12</property>
</packing>
</child>
</object>
Expand Down
11 changes: 9 additions & 2 deletions cmd/gtk/dialog_transaction_bond.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func broadcastTransactionBond(wlt *wallet.Wallet) {
publicKeyEntry := getEntryObj(builder, "id_entry_public_key")
amountEntry := getEntryObj(builder, "id_entry_amount")
amountHint := getLabelObj(builder, "id_hint_amount")
memoEntry := getEntryObj(builder, "id_entry_memo")
getButtonObj(builder, "id_button_cancel").SetImage(CancelIcon())
getButtonObj(builder, "id_button_send").SetImage(SendIcon())

Expand Down Expand Up @@ -63,6 +64,7 @@ func broadcastTransactionBond(wlt *wallet.Wallet) {
receiver, _ := receiverEntry.GetText()
publicKey, _ := publicKeyEntry.GetText()
amountStr, _ := amountEntry.GetText()
memo, _ := memoEntry.GetText()

amt, err := amount.FromString(amountStr)
if err != nil {
Expand All @@ -71,7 +73,11 @@ func broadcastTransactionBond(wlt *wallet.Wallet) {
return
}

trx, err := wlt.MakeBondTx(sender, receiver, publicKey, amt)
opts := []wallet.TxOption{
wallet.OptionMemo(memo),
}

trx, err := wlt.MakeBondTx(sender, receiver, publicKey, amt, opts...)
if err != nil {
errorCheck(err)

Expand All @@ -83,10 +89,11 @@ You are going to sign and broadcast this transaction:
From: %s
To: %s
Amount: %s
Memo: %s
Fee: %s
THIS ACTION IS NOT REVERSIBLE. Do you want to continue?`,
sender, receiver, amt, trx.Fee())
sender, receiver, amt, trx.Memo(), trx.Fee())

signAndBroadcastTransaction(dlg, msg, wlt, trx)

Expand Down
Loading

0 comments on commit 3ba0150

Please sign in to comment.