Skip to content
Snippets Groups Projects
Commit 4c727fa7 authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

- Fix sending a TX with amount like 17800100 (les zéro du millieu posait problème)

parent 242a23e0
No related branches found
No related tags found
No related merge requests found
...@@ -385,7 +385,7 @@ public class TransactionRemoteServiceImpl extends BaseRemoteServiceImpl implemen ...@@ -385,7 +385,7 @@ public class TransactionRemoteServiceImpl extends BaseRemoteServiceImpl implemen
// Avoid to get outputs on lower base // Avoid to get outputs on lower base
if (amountBase < inputs.minBase && !isBase(amount, inputs.minBase)) { if (amountBase < inputs.minBase && !isBase(amount, inputs.minBase)) {
amount = truncBase(amount, inputs.minBase); amount = truncBaseOrMinBase(amount, inputs.minBase);
log.debug("TX Amount has been truncate to " + amount); log.debug("TX Amount has been truncate to " + amount);
} }
else if (amountBase > 0) { else if (amountBase > 0) {
...@@ -427,11 +427,18 @@ public class TransactionRemoteServiceImpl extends BaseRemoteServiceImpl implemen ...@@ -427,11 +427,18 @@ public class TransactionRemoteServiceImpl extends BaseRemoteServiceImpl implemen
} }
private long truncBase(long amount, int base) { private long truncBase(long amount, int base) {
long pow = (long)Math.pow(10, base);
if (amount < pow) return 0;
return (long)(Math.floor(amount / pow ) * pow);
}
private long truncBaseOrMinBase(long amount, int base) {
long pow = (long)Math.pow(10, base); long pow = (long)Math.pow(10, base);
if (amount < pow) return pow; if (amount < pow) return pow;
return (long)(Math.floor(amount / pow ) * pow); return (long)(Math.floor(amount / pow ) * pow);
} }
private long powBase(long amount, int base) { private long powBase(long amount, int base) {
if (base <= 0) return amount; if (base <= 0) return amount;
return (long) (amount * Math.pow(10, base)); return (long) (amount * Math.pow(10, base));
......
...@@ -139,7 +139,7 @@ duniter.keyring.password: def ...@@ -139,7 +139,7 @@ duniter.keyring.password: def
# Enable security, to disable HTTP access to the default ES admin API # Enable security, to disable HTTP access to the default ES admin API
# #
duniter.security.enable: false duniter.security.enable: true
# #
# Security token prefix (default: 'duniter-') # Security token prefix (default: 'duniter-')
# #
...@@ -153,9 +153,9 @@ duniter.security.enable: false ...@@ -153,9 +153,9 @@ duniter.security.enable: false
# #
# Should synchronize data using P2P # Should synchronize data using P2P
# #
duniter.data.sync.enable: false duniter.data.sync.enable: true
#duniter.data.sync.host: data.duniter.fr duniter.data.sync.host: data.duniter.fr
#duniter.data.sync.port: 80 duniter.data.sync.port: 80
# ---------------------------------- Duniter4j SMTP server ------------------------- # ---------------------------------- Duniter4j SMTP server -------------------------
# #
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment