diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/service/bma/TransactionRemoteServiceImpl.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/service/bma/TransactionRemoteServiceImpl.java index 5125270f8171b1a648907436c4289e8082ac7844..053f37ef26de45ad56fcc526b5449d0ec2ca2e2a 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/service/bma/TransactionRemoteServiceImpl.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/service/bma/TransactionRemoteServiceImpl.java @@ -385,7 +385,7 @@ public class TransactionRemoteServiceImpl extends BaseRemoteServiceImpl implemen // Avoid to get outputs on lower base 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); } else if (amountBase > 0) { @@ -427,11 +427,18 @@ public class TransactionRemoteServiceImpl extends BaseRemoteServiceImpl implemen } 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); if (amount < pow) return pow; return (long)(Math.floor(amount / pow ) * pow); } + private long powBase(long amount, int base) { if (base <= 0) return amount; return (long) (amount * Math.pow(10, base)); diff --git a/duniter4j-es-assembly/src/test/es-home/config/elasticsearch.yml b/duniter4j-es-assembly/src/test/es-home/config/elasticsearch.yml index bc8c9dae0aad45a7b7e154ca8a0871972614314d..4fd157adf2cc1bd3aeb45f7ee7f6979f735cbec2 100644 --- a/duniter4j-es-assembly/src/test/es-home/config/elasticsearch.yml +++ b/duniter4j-es-assembly/src/test/es-home/config/elasticsearch.yml @@ -139,7 +139,7 @@ duniter.keyring.password: def # 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-') # @@ -153,9 +153,9 @@ duniter.security.enable: false # # Should synchronize data using P2P # -duniter.data.sync.enable: false -#duniter.data.sync.host: data.duniter.fr -#duniter.data.sync.port: 80 +duniter.data.sync.enable: true +duniter.data.sync.host: data.duniter.fr +duniter.data.sync.port: 80 # ---------------------------------- Duniter4j SMTP server ------------------------- #