Skip to content

Commit

Permalink
Implement CIP19 (#67)
Browse files Browse the repository at this point in the history
* Add new table and re-generate jOOQ files

* Include indirect incoming transactions when getting transactions from db and through API call parameter (implemented looking up indirect incoming transactions)

* Put multi out transactions into Indirect Incoming

* Add rollback to tests

* Table isn't versioned...

* UI Integration

* Configuration option for service

* Check in missing files

* Oops

* Revert accidental test variable change

* Tests
  • Loading branch information
harryjph committed Mar 14, 2019
1 parent 02a68c1 commit cf10fab
Show file tree
Hide file tree
Showing 89 changed files with 2,126 additions and 635 deletions.
4 changes: 4 additions & 0 deletions conf/brs-default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,7 @@ brs.debugLogUnconfirmed = false

# Timeout in Seconds to wait for a graceful shutdown
brs.ShutdownTimeout = 180

# Enable the indirect incoming tracker service. This allows you to see transactions where you are paid
# but are not the direct recipient eg. Multi-Outs.
IndirectIncomingService.Enable = true
3 changes: 2 additions & 1 deletion html/ui/js/brs.messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ var BRS = (function(BRS, $, undefined) {
"firstIndex": 0,
"lastIndex": 74,
"type": 1,
"subtype": 0
"subtype": 0,
"includeIndirect": false
}, function(response) {
if (response.transactions && response.transactions.length) {
for (var i = 0; i < response.transactions.length; i++) {
Expand Down
20 changes: 15 additions & 5 deletions html/ui/js/brs.modals.account.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ var BRS = (function(BRS, $, undefined) {
BRS.sendRequest("getAccountTransactions", {
"account": BRS.userInfoModal.user,
"firstIndex": 0,
"lastIndex": 99
"lastIndex": 99,
"includeIndirect": true
}, function(response) {
if (response.transactions && response.transactions.length) {
var rows = "";
Expand All @@ -129,13 +130,22 @@ var BRS = (function(BRS, $, undefined) {
var transactionType = "Unknown";

if (transaction.type == 0) {
transactionType = $.t("ordinary_payment");
switch (transaction.subtype) {
case 0:
transactionType = $.t("ordinary_payment");
break;

case 1:
transactionType = "Multi-out payment";
break;

case 2:
transactionType = "Multi-out Same payment";
break;
}
}
else if (transaction.type == 1) {
switch (transaction.subtype) {
case 0:
transactionType = $.t("arbitrary_message");
break;
case 1:
transactionType = $.t("alias_assignment");
break;
Expand Down
102 changes: 85 additions & 17 deletions html/ui/js/brs.modals.transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,92 @@ var BRS = (function(BRS, $, undefined) {
}

if (transaction.type == 0) {
switch (transaction.subtype) {
case 0:
data = {
"type": $.t("ordinary_payment"),
"amount": transaction.amountNQT,
"fee": transaction.feeNQT,
"recipient": BRS.getAccountTitle(transaction, "recipient"),
"sender": BRS.getAccountTitle(transaction, "sender")
};

$("#transaction_info_table tbody").append(BRS.createInfoTable(data));
$("#transaction_info_table").show();
switch (transaction.subtype) {
case 0:
data = {
"type": $.t("ordinary_payment"),
"amount": transaction.amountNQT,
"fee": transaction.feeNQT,
"recipient": BRS.getAccountTitle(transaction, "recipient"),
"sender": BRS.getAccountTitle(transaction, "sender")
};

$("#transaction_info_table tbody").append(BRS.createInfoTable(data));
$("#transaction_info_table").show();

break;
case 1:
if (transaction.attachment == null || transaction.attachment.recipients == null) {
incorrect = true;
return;
}
var recipientHtml = "";
var nxtAddress = new NxtAddress();
for (var i = 0; i < transaction.attachment.recipients.length; i++) {
var recipient = transaction.attachment.recipients[i];
nxtAddress.set(recipient[0]);
var address = nxtAddress.toString();
var amount = BRS.formatAmount(recipient[1]) + " BURST";
if (i !== 0) {
recipientHtml += "<br />";
}
if (address === BRS.accountRS) {
recipientHtml += "<b>"+address+": "+amount+"</b>";
} else {
recipientHtml += address+": "+amount;
}
}

break;
default:
incorrect = true;
break;
}
data = {
"type": "Multi-out Payment",
"amount": transaction.amountNQT,
"fee": transaction.feeNQT,
"recipient_formatted_html": recipientHtml,
"sender": BRS.getAccountTitle(transaction, "sender")
};

$("#transaction_info_table tbody").append(BRS.createInfoTable(data));
$("#transaction_info_table").show();

break;
case 2:
if (transaction.attachment == null || transaction.attachment.recipients == null) {
incorrect = true;
return;
}
var amountEach = parseInt(transaction.amountNQT) / transaction.attachment.recipients.length;
var recipientHtml = "";
var nxtAddress = new NxtAddress();
for (var i = 0; i < transaction.attachment.recipients.length; i++) {
var recipient = transaction.attachment.recipients[i];
nxtAddress.set(recipient);
var address = nxtAddress.toString();
if (i !== 0) {
recipientHtml += "<br />";
}
if (address === BRS.accountRS) {
recipientHtml += "<b>"+address+"</b>";
} else {
recipientHtml += address;
}
}

data = {
"type": "Multi-out Same Payment",
"amount_formatted_html": BRS.formatAmount(transaction.amountNQT) + " BURST (" + BRS.formatAmount(amountEach.toString()) + " BURST for each recipient)",
"fee": transaction.feeNQT,
"recipient_formatted_html": recipientHtml,
"sender": BRS.getAccountTitle(transaction, "sender")
};

$("#transaction_info_table tbody").append(BRS.createInfoTable(data));
$("#transaction_info_table").show();

break;
default:
incorrect = true;
break;
}
}
else if (transaction.type == 1) {
switch (transaction.subtype) {
Expand Down
Loading

0 comments on commit cf10fab

Please sign in to comment.