Change EULA
Added memo to bitshares send request
This commit is contained in:
parent
1514d32457
commit
a13bbadd2e
4 changed files with 46 additions and 6 deletions
|
@ -8,6 +8,7 @@ import com.google.common.primitives.UnsignedLong;
|
|||
|
||||
import org.bitcoinj.core.ECKey;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
|
@ -58,6 +59,7 @@ import cy.agorise.graphenej.UserAccount;
|
|||
import cy.agorise.graphenej.models.AccountProperties;
|
||||
import cy.agorise.graphenej.models.BlockHeader;
|
||||
import cy.agorise.graphenej.models.HistoricalTransfer;
|
||||
import cy.agorise.graphenej.objects.Memo;
|
||||
import cy.agorise.graphenej.operations.TransferOperationBuilder;
|
||||
|
||||
/**
|
||||
|
@ -585,9 +587,16 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
|||
.setTransferAmount(new AssetAmount(UnsignedLong.valueOf(sendRequest.getAmount()), new Asset(idAsset)))
|
||||
.setFee(new AssetAmount(UnsignedLong.valueOf(0), feeAsset));
|
||||
if (sendRequest.getMemo() != null) {
|
||||
//builder.setMemo(new Memo(fromUserAccount,toUserAccount,0,sendRequest.getMemo().getBytes()));
|
||||
//TODO memo
|
||||
System.out.println("transaction has memo");
|
||||
try {
|
||||
//TODO change authority for memo
|
||||
Address fromAddress = new Address(fromUserAccount.getActive().getKeyAuthList().get(0).getKey(), "BTS");
|
||||
Address toAddress = new Address(toUserAccount.getActive().getKeyAuthList().get(0).getKey(), "BTS");
|
||||
builder.setMemo(new Memo(fromAddress,toAddress,BigInteger.ZERO,sendRequest.getMemo().getBytes()));
|
||||
//TODO add random nonce
|
||||
}catch ( Exception e){
|
||||
e.printStackTrace();
|
||||
//TODO error
|
||||
}
|
||||
}
|
||||
ArrayList<BaseOperation> operationList = new ArrayList<>();
|
||||
operationList.add(builder.build());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<integer name="license_version">1</integer>
|
||||
<integer name="license_version">2</integer>
|
||||
|
||||
</resources>
|
File diff suppressed because one or more lines are too long
|
@ -1,8 +1,19 @@
|
|||
package cy.agorise.crystalwallet;
|
||||
|
||||
import org.bitcoinj.core.Base58;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
import cy.agorise.graphenej.Invoice;
|
||||
import cy.agorise.graphenej.LineItem;
|
||||
import cy.agorise.graphenej.Util;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
|
@ -10,8 +21,28 @@ import static org.junit.Assert.*;
|
|||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
|
||||
//static String qrCode = "CQEZu91fWYH9dr2kRx2SxfBABxaKXWF7wwAn5Y4oeoe5aXoouAahm1P7a42eog7HtihvPhwHqFzeMBScuxgEonfq1euo9sZwUte9Zy5tbVK9tr3WR8kFXShCCantyM2iXGuucSXLsvpCdgNBUL5tEdZm27Lws71mhTHwy13WutDJBHDGpTn68His6f69F4kTQcZG9Ri9L1PXm";
|
||||
static String qrCode = "Y1cyE5NiEfp6icMmzP1VFiQEYuXgX3xHjTBkVBZquZZxxbZWPrefG4D8f1zPEEhmuvcJpcgWEn5Fj2YsKzvzUViRQy3r1SY3usSK6Y1vuWpAcZDZkJxDUKnhPchTj7yT3jXQmnz2EU1fvzgpN12nF2bkRvnYmo9wtCVEECgaXwvVyzz92ZAo5ju71dh";
|
||||
|
||||
@Test
|
||||
public void addition_isCorrect() throws Exception {
|
||||
assertEquals(4, 2 + 2);
|
||||
Invoice invoice = Invoice.fromQrCode(qrCode);
|
||||
System.out.println("To : " + invoice.getTo());
|
||||
System.out.println("Currency : " +invoice.getCurrency());
|
||||
System.out.println("Memo : " +invoice.getMemo());
|
||||
|
||||
|
||||
double amount = 0.0;
|
||||
for (LineItem nextItem : invoice.getLineItems()) {
|
||||
amount += nextItem.getQuantity() * nextItem.getPrice();
|
||||
}
|
||||
DecimalFormat df = new DecimalFormat("####.####");
|
||||
df.setRoundingMode(RoundingMode.CEILING);
|
||||
df.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.ENGLISH));
|
||||
System.out.println("Amount : " +amount);
|
||||
|
||||
System.out.println(new String(Util.decompress(Base58.decode(qrCode),Util.LZMA)));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue