@Test public void testFromTx() throws Exception { }
public static List<Tx> fromTx(TxJson sourceJson, Wallet wallet, Map<String, String> mapMember){ HashMap<String, Tx> txs = new HashMap<>(); for (History.Elem e : sourceJson.history.sent){ Tx tx = new Tx(); long amount = 0; for (History.Output o : e.outputs){ if (o.getPublicKey()!=null && !o.getPublicKey().equals(sourceJson.pubkey)){ tx.setPublicKey(o.getPublicKey()); tx.setBase(o.base); amount -= o.amount; } } if (tx.getPublicKey()==null){ tx.setPublicKey(sourceJson.pubkey); } String uid = mapMember.containsKey(tx.getPublicKey()) ? mapMember.get(tx.getPublicKey()) : ""; tx.setUid(uid); tx.setAmount(amount); tx.setCurrency(wallet.getCurrency()); tx.setWallet(wallet); tx.setState(TxState.VALID.name()); tx.setComment(e.comment); tx.setEnc(e.comment.length()>3 && e.comment.substring(0,3).equals("ENC")); tx.setTime(e.time); tx.setHash(e.hash); tx.setBlockNumber(e.block_number); tx.setLocktime(e.locktime); tx.setUd(false); txs.put(e.hash,tx); } for (History.Elem e : sourceJson.history.received){ if (!txs.containsKey(e.hash)){ Tx tx = new Tx(); long amount = 0; for (History.Output o : e.outputs) { if (o.getPublicKey() != null){ if (o.getPublicKey().equals(sourceJson.pubkey)){ amount += o.amount; tx.setBase(o.base); } } } tx.setPublicKey(e.issuers[0]); if (tx.getPublicKey()==null){ tx.setPublicKey(sourceJson.pubkey); } String uid = mapMember.containsKey(tx.getPublicKey()) ? mapMember.get(tx.getPublicKey()) : ""; tx.setUid(uid); tx.setAmount(amount); tx.setCurrency(wallet.getCurrency()); tx.setWallet(wallet); tx.setState(TxState.VALID.name()); tx.setComment(e.comment); tx.setEnc(e.comment.length()>3 && e.comment.substring(0,3).equals("ENC")); tx.setTime(e.time); tx.setHash(e.hash); tx.setBlockNumber(e.block_number); tx.setLocktime(e.locktime); tx.setUd(false); txs.put(e.hash,tx); } } for (History.Elem e : sourceJson.history.sending){ Tx tx = new Tx(); long amount = 0; for (History.Output o : e.outputs){ if (o.getPublicKey()!=null && !o.getPublicKey().equals(sourceJson.pubkey)){ tx.setPublicKey(o.getPublicKey()); amount -= o.amount; tx.setBase(o.base); } } if (tx.getPublicKey()==null){ tx.setPublicKey(sourceJson.pubkey); } String uid = mapMember.containsKey(tx.getPublicKey()) ? mapMember.get(tx.getPublicKey()) : ""; tx.setUid(uid); tx.setAmount(amount); tx.setCurrency(wallet.getCurrency()); tx.setWallet(wallet); tx.setState(TxState.PENDING.name()); tx.setComment(e.comment); tx.setEnc(e.comment.length()>3 && e.comment.substring(0,3).equals("ENC")); tx.setTime(Long.valueOf("999999999999")); tx.setHash(e.hash); tx.setBlockNumber(0); tx.setLocktime(e.locktime); tx.setUd(false); txs.put(e.hash,tx); } for (History.Elem e : sourceJson.history.pending){ if (!txs.containsKey(e.hash)){ Tx tx = new Tx(); long amount = 0; for (History.Output o : e.outputs) { if (o.getPublicKey() != null){ if (o.getPublicKey().equals(sourceJson.pubkey)){ amount += o.amount; tx.setBase(o.base); } } } tx.setPublicKey(e.issuers[0]); if (tx.getPublicKey()==null){ tx.setPublicKey(sourceJson.pubkey); } String uid = mapMember.containsKey(tx.getPublicKey()) ? mapMember.get(tx.getPublicKey()) : ""; tx.setUid(uid); tx.setAmount(amount); tx.setCurrency(wallet.getCurrency()); tx.setWallet(wallet); tx.setState(TxState.PENDING.name()); tx.setComment(e.comment); tx.setEnc(e.comment.length()>3 && e.comment.substring(0,3).equals("ENC")); tx.setTime(Long.valueOf("999999999999")); tx.setHash(e.hash); tx.setBlockNumber(0); tx.setLocktime(e.locktime); tx.setUd(false); txs.put(e.hash,tx); } } return new ArrayList<Tx>(txs.values()); }
TxJson implements Serializable { public static List<Tx> fromTx(TxJson sourceJson, Wallet wallet, Map<String, String> mapMember){ HashMap<String, Tx> txs = new HashMap<>(); for (History.Elem e : sourceJson.history.sent){ Tx tx = new Tx(); long amount = 0; for (History.Output o : e.outputs){ if (o.getPublicKey()!=null && !o.getPublicKey().equals(sourceJson.pubkey)){ tx.setPublicKey(o.getPublicKey()); tx.setBase(o.base); amount -= o.amount; } } if (tx.getPublicKey()==null){ tx.setPublicKey(sourceJson.pubkey); } String uid = mapMember.containsKey(tx.getPublicKey()) ? mapMember.get(tx.getPublicKey()) : ""; tx.setUid(uid); tx.setAmount(amount); tx.setCurrency(wallet.getCurrency()); tx.setWallet(wallet); tx.setState(TxState.VALID.name()); tx.setComment(e.comment); tx.setEnc(e.comment.length()>3 && e.comment.substring(0,3).equals("ENC")); tx.setTime(e.time); tx.setHash(e.hash); tx.setBlockNumber(e.block_number); tx.setLocktime(e.locktime); tx.setUd(false); txs.put(e.hash,tx); } for (History.Elem e : sourceJson.history.received){ if (!txs.containsKey(e.hash)){ Tx tx = new Tx(); long amount = 0; for (History.Output o : e.outputs) { if (o.getPublicKey() != null){ if (o.getPublicKey().equals(sourceJson.pubkey)){ amount += o.amount; tx.setBase(o.base); } } } tx.setPublicKey(e.issuers[0]); if (tx.getPublicKey()==null){ tx.setPublicKey(sourceJson.pubkey); } String uid = mapMember.containsKey(tx.getPublicKey()) ? mapMember.get(tx.getPublicKey()) : ""; tx.setUid(uid); tx.setAmount(amount); tx.setCurrency(wallet.getCurrency()); tx.setWallet(wallet); tx.setState(TxState.VALID.name()); tx.setComment(e.comment); tx.setEnc(e.comment.length()>3 && e.comment.substring(0,3).equals("ENC")); tx.setTime(e.time); tx.setHash(e.hash); tx.setBlockNumber(e.block_number); tx.setLocktime(e.locktime); tx.setUd(false); txs.put(e.hash,tx); } } for (History.Elem e : sourceJson.history.sending){ Tx tx = new Tx(); long amount = 0; for (History.Output o : e.outputs){ if (o.getPublicKey()!=null && !o.getPublicKey().equals(sourceJson.pubkey)){ tx.setPublicKey(o.getPublicKey()); amount -= o.amount; tx.setBase(o.base); } } if (tx.getPublicKey()==null){ tx.setPublicKey(sourceJson.pubkey); } String uid = mapMember.containsKey(tx.getPublicKey()) ? mapMember.get(tx.getPublicKey()) : ""; tx.setUid(uid); tx.setAmount(amount); tx.setCurrency(wallet.getCurrency()); tx.setWallet(wallet); tx.setState(TxState.PENDING.name()); tx.setComment(e.comment); tx.setEnc(e.comment.length()>3 && e.comment.substring(0,3).equals("ENC")); tx.setTime(Long.valueOf("999999999999")); tx.setHash(e.hash); tx.setBlockNumber(0); tx.setLocktime(e.locktime); tx.setUd(false); txs.put(e.hash,tx); } for (History.Elem e : sourceJson.history.pending){ if (!txs.containsKey(e.hash)){ Tx tx = new Tx(); long amount = 0; for (History.Output o : e.outputs) { if (o.getPublicKey() != null){ if (o.getPublicKey().equals(sourceJson.pubkey)){ amount += o.amount; tx.setBase(o.base); } } } tx.setPublicKey(e.issuers[0]); if (tx.getPublicKey()==null){ tx.setPublicKey(sourceJson.pubkey); } String uid = mapMember.containsKey(tx.getPublicKey()) ? mapMember.get(tx.getPublicKey()) : ""; tx.setUid(uid); tx.setAmount(amount); tx.setCurrency(wallet.getCurrency()); tx.setWallet(wallet); tx.setState(TxState.PENDING.name()); tx.setComment(e.comment); tx.setEnc(e.comment.length()>3 && e.comment.substring(0,3).equals("ENC")); tx.setTime(Long.valueOf("999999999999")); tx.setHash(e.hash); tx.setBlockNumber(0); tx.setLocktime(e.locktime); tx.setUd(false); txs.put(e.hash,tx); } } return new ArrayList<Tx>(txs.values()); } }
TxJson implements Serializable { public static List<Tx> fromTx(TxJson sourceJson, Wallet wallet, Map<String, String> mapMember){ HashMap<String, Tx> txs = new HashMap<>(); for (History.Elem e : sourceJson.history.sent){ Tx tx = new Tx(); long amount = 0; for (History.Output o : e.outputs){ if (o.getPublicKey()!=null && !o.getPublicKey().equals(sourceJson.pubkey)){ tx.setPublicKey(o.getPublicKey()); tx.setBase(o.base); amount -= o.amount; } } if (tx.getPublicKey()==null){ tx.setPublicKey(sourceJson.pubkey); } String uid = mapMember.containsKey(tx.getPublicKey()) ? mapMember.get(tx.getPublicKey()) : ""; tx.setUid(uid); tx.setAmount(amount); tx.setCurrency(wallet.getCurrency()); tx.setWallet(wallet); tx.setState(TxState.VALID.name()); tx.setComment(e.comment); tx.setEnc(e.comment.length()>3 && e.comment.substring(0,3).equals("ENC")); tx.setTime(e.time); tx.setHash(e.hash); tx.setBlockNumber(e.block_number); tx.setLocktime(e.locktime); tx.setUd(false); txs.put(e.hash,tx); } for (History.Elem e : sourceJson.history.received){ if (!txs.containsKey(e.hash)){ Tx tx = new Tx(); long amount = 0; for (History.Output o : e.outputs) { if (o.getPublicKey() != null){ if (o.getPublicKey().equals(sourceJson.pubkey)){ amount += o.amount; tx.setBase(o.base); } } } tx.setPublicKey(e.issuers[0]); if (tx.getPublicKey()==null){ tx.setPublicKey(sourceJson.pubkey); } String uid = mapMember.containsKey(tx.getPublicKey()) ? mapMember.get(tx.getPublicKey()) : ""; tx.setUid(uid); tx.setAmount(amount); tx.setCurrency(wallet.getCurrency()); tx.setWallet(wallet); tx.setState(TxState.VALID.name()); tx.setComment(e.comment); tx.setEnc(e.comment.length()>3 && e.comment.substring(0,3).equals("ENC")); tx.setTime(e.time); tx.setHash(e.hash); tx.setBlockNumber(e.block_number); tx.setLocktime(e.locktime); tx.setUd(false); txs.put(e.hash,tx); } } for (History.Elem e : sourceJson.history.sending){ Tx tx = new Tx(); long amount = 0; for (History.Output o : e.outputs){ if (o.getPublicKey()!=null && !o.getPublicKey().equals(sourceJson.pubkey)){ tx.setPublicKey(o.getPublicKey()); amount -= o.amount; tx.setBase(o.base); } } if (tx.getPublicKey()==null){ tx.setPublicKey(sourceJson.pubkey); } String uid = mapMember.containsKey(tx.getPublicKey()) ? mapMember.get(tx.getPublicKey()) : ""; tx.setUid(uid); tx.setAmount(amount); tx.setCurrency(wallet.getCurrency()); tx.setWallet(wallet); tx.setState(TxState.PENDING.name()); tx.setComment(e.comment); tx.setEnc(e.comment.length()>3 && e.comment.substring(0,3).equals("ENC")); tx.setTime(Long.valueOf("999999999999")); tx.setHash(e.hash); tx.setBlockNumber(0); tx.setLocktime(e.locktime); tx.setUd(false); txs.put(e.hash,tx); } for (History.Elem e : sourceJson.history.pending){ if (!txs.containsKey(e.hash)){ Tx tx = new Tx(); long amount = 0; for (History.Output o : e.outputs) { if (o.getPublicKey() != null){ if (o.getPublicKey().equals(sourceJson.pubkey)){ amount += o.amount; tx.setBase(o.base); } } } tx.setPublicKey(e.issuers[0]); if (tx.getPublicKey()==null){ tx.setPublicKey(sourceJson.pubkey); } String uid = mapMember.containsKey(tx.getPublicKey()) ? mapMember.get(tx.getPublicKey()) : ""; tx.setUid(uid); tx.setAmount(amount); tx.setCurrency(wallet.getCurrency()); tx.setWallet(wallet); tx.setState(TxState.PENDING.name()); tx.setComment(e.comment); tx.setEnc(e.comment.length()>3 && e.comment.substring(0,3).equals("ENC")); tx.setTime(Long.valueOf("999999999999")); tx.setHash(e.hash); tx.setBlockNumber(0); tx.setLocktime(e.locktime); tx.setUd(false); txs.put(e.hash,tx); } } return new ArrayList<Tx>(txs.values()); }  }
TxJson implements Serializable { public static List<Tx> fromTx(TxJson sourceJson, Wallet wallet, Map<String, String> mapMember){ HashMap<String, Tx> txs = new HashMap<>(); for (History.Elem e : sourceJson.history.sent){ Tx tx = new Tx(); long amount = 0; for (History.Output o : e.outputs){ if (o.getPublicKey()!=null && !o.getPublicKey().equals(sourceJson.pubkey)){ tx.setPublicKey(o.getPublicKey()); tx.setBase(o.base); amount -= o.amount; } } if (tx.getPublicKey()==null){ tx.setPublicKey(sourceJson.pubkey); } String uid = mapMember.containsKey(tx.getPublicKey()) ? mapMember.get(tx.getPublicKey()) : ""; tx.setUid(uid); tx.setAmount(amount); tx.setCurrency(wallet.getCurrency()); tx.setWallet(wallet); tx.setState(TxState.VALID.name()); tx.setComment(e.comment); tx.setEnc(e.comment.length()>3 && e.comment.substring(0,3).equals("ENC")); tx.setTime(e.time); tx.setHash(e.hash); tx.setBlockNumber(e.block_number); tx.setLocktime(e.locktime); tx.setUd(false); txs.put(e.hash,tx); } for (History.Elem e : sourceJson.history.received){ if (!txs.containsKey(e.hash)){ Tx tx = new Tx(); long amount = 0; for (History.Output o : e.outputs) { if (o.getPublicKey() != null){ if (o.getPublicKey().equals(sourceJson.pubkey)){ amount += o.amount; tx.setBase(o.base); } } } tx.setPublicKey(e.issuers[0]); if (tx.getPublicKey()==null){ tx.setPublicKey(sourceJson.pubkey); } String uid = mapMember.containsKey(tx.getPublicKey()) ? mapMember.get(tx.getPublicKey()) : ""; tx.setUid(uid); tx.setAmount(amount); tx.setCurrency(wallet.getCurrency()); tx.setWallet(wallet); tx.setState(TxState.VALID.name()); tx.setComment(e.comment); tx.setEnc(e.comment.length()>3 && e.comment.substring(0,3).equals("ENC")); tx.setTime(e.time); tx.setHash(e.hash); tx.setBlockNumber(e.block_number); tx.setLocktime(e.locktime); tx.setUd(false); txs.put(e.hash,tx); } } for (History.Elem e : sourceJson.history.sending){ Tx tx = new Tx(); long amount = 0; for (History.Output o : e.outputs){ if (o.getPublicKey()!=null && !o.getPublicKey().equals(sourceJson.pubkey)){ tx.setPublicKey(o.getPublicKey()); amount -= o.amount; tx.setBase(o.base); } } if (tx.getPublicKey()==null){ tx.setPublicKey(sourceJson.pubkey); } String uid = mapMember.containsKey(tx.getPublicKey()) ? mapMember.get(tx.getPublicKey()) : ""; tx.setUid(uid); tx.setAmount(amount); tx.setCurrency(wallet.getCurrency()); tx.setWallet(wallet); tx.setState(TxState.PENDING.name()); tx.setComment(e.comment); tx.setEnc(e.comment.length()>3 && e.comment.substring(0,3).equals("ENC")); tx.setTime(Long.valueOf("999999999999")); tx.setHash(e.hash); tx.setBlockNumber(0); tx.setLocktime(e.locktime); tx.setUd(false); txs.put(e.hash,tx); } for (History.Elem e : sourceJson.history.pending){ if (!txs.containsKey(e.hash)){ Tx tx = new Tx(); long amount = 0; for (History.Output o : e.outputs) { if (o.getPublicKey() != null){ if (o.getPublicKey().equals(sourceJson.pubkey)){ amount += o.amount; tx.setBase(o.base); } } } tx.setPublicKey(e.issuers[0]); if (tx.getPublicKey()==null){ tx.setPublicKey(sourceJson.pubkey); } String uid = mapMember.containsKey(tx.getPublicKey()) ? mapMember.get(tx.getPublicKey()) : ""; tx.setUid(uid); tx.setAmount(amount); tx.setCurrency(wallet.getCurrency()); tx.setWallet(wallet); tx.setState(TxState.PENDING.name()); tx.setComment(e.comment); tx.setEnc(e.comment.length()>3 && e.comment.substring(0,3).equals("ENC")); tx.setTime(Long.valueOf("999999999999")); tx.setHash(e.hash); tx.setBlockNumber(0); tx.setLocktime(e.locktime); tx.setUd(false); txs.put(e.hash,tx); } } return new ArrayList<Tx>(txs.values()); }  static TxJson fromJson(String response); static List<String> fromTxGetSourcesPending(TxJson sourceJson); static List<Tx> fromTx(TxJson sourceJson, Wallet wallet, Map<String, String> mapMember); static Map<String, List<String>> fromTxGetMapSourcePending(TxJson txJson); }
TxJson implements Serializable { public static List<Tx> fromTx(TxJson sourceJson, Wallet wallet, Map<String, String> mapMember){ HashMap<String, Tx> txs = new HashMap<>(); for (History.Elem e : sourceJson.history.sent){ Tx tx = new Tx(); long amount = 0; for (History.Output o : e.outputs){ if (o.getPublicKey()!=null && !o.getPublicKey().equals(sourceJson.pubkey)){ tx.setPublicKey(o.getPublicKey()); tx.setBase(o.base); amount -= o.amount; } } if (tx.getPublicKey()==null){ tx.setPublicKey(sourceJson.pubkey); } String uid = mapMember.containsKey(tx.getPublicKey()) ? mapMember.get(tx.getPublicKey()) : ""; tx.setUid(uid); tx.setAmount(amount); tx.setCurrency(wallet.getCurrency()); tx.setWallet(wallet); tx.setState(TxState.VALID.name()); tx.setComment(e.comment); tx.setEnc(e.comment.length()>3 && e.comment.substring(0,3).equals("ENC")); tx.setTime(e.time); tx.setHash(e.hash); tx.setBlockNumber(e.block_number); tx.setLocktime(e.locktime); tx.setUd(false); txs.put(e.hash,tx); } for (History.Elem e : sourceJson.history.received){ if (!txs.containsKey(e.hash)){ Tx tx = new Tx(); long amount = 0; for (History.Output o : e.outputs) { if (o.getPublicKey() != null){ if (o.getPublicKey().equals(sourceJson.pubkey)){ amount += o.amount; tx.setBase(o.base); } } } tx.setPublicKey(e.issuers[0]); if (tx.getPublicKey()==null){ tx.setPublicKey(sourceJson.pubkey); } String uid = mapMember.containsKey(tx.getPublicKey()) ? mapMember.get(tx.getPublicKey()) : ""; tx.setUid(uid); tx.setAmount(amount); tx.setCurrency(wallet.getCurrency()); tx.setWallet(wallet); tx.setState(TxState.VALID.name()); tx.setComment(e.comment); tx.setEnc(e.comment.length()>3 && e.comment.substring(0,3).equals("ENC")); tx.setTime(e.time); tx.setHash(e.hash); tx.setBlockNumber(e.block_number); tx.setLocktime(e.locktime); tx.setUd(false); txs.put(e.hash,tx); } } for (History.Elem e : sourceJson.history.sending){ Tx tx = new Tx(); long amount = 0; for (History.Output o : e.outputs){ if (o.getPublicKey()!=null && !o.getPublicKey().equals(sourceJson.pubkey)){ tx.setPublicKey(o.getPublicKey()); amount -= o.amount; tx.setBase(o.base); } } if (tx.getPublicKey()==null){ tx.setPublicKey(sourceJson.pubkey); } String uid = mapMember.containsKey(tx.getPublicKey()) ? mapMember.get(tx.getPublicKey()) : ""; tx.setUid(uid); tx.setAmount(amount); tx.setCurrency(wallet.getCurrency()); tx.setWallet(wallet); tx.setState(TxState.PENDING.name()); tx.setComment(e.comment); tx.setEnc(e.comment.length()>3 && e.comment.substring(0,3).equals("ENC")); tx.setTime(Long.valueOf("999999999999")); tx.setHash(e.hash); tx.setBlockNumber(0); tx.setLocktime(e.locktime); tx.setUd(false); txs.put(e.hash,tx); } for (History.Elem e : sourceJson.history.pending){ if (!txs.containsKey(e.hash)){ Tx tx = new Tx(); long amount = 0; for (History.Output o : e.outputs) { if (o.getPublicKey() != null){ if (o.getPublicKey().equals(sourceJson.pubkey)){ amount += o.amount; tx.setBase(o.base); } } } tx.setPublicKey(e.issuers[0]); if (tx.getPublicKey()==null){ tx.setPublicKey(sourceJson.pubkey); } String uid = mapMember.containsKey(tx.getPublicKey()) ? mapMember.get(tx.getPublicKey()) : ""; tx.setUid(uid); tx.setAmount(amount); tx.setCurrency(wallet.getCurrency()); tx.setWallet(wallet); tx.setState(TxState.PENDING.name()); tx.setComment(e.comment); tx.setEnc(e.comment.length()>3 && e.comment.substring(0,3).equals("ENC")); tx.setTime(Long.valueOf("999999999999")); tx.setHash(e.hash); tx.setBlockNumber(0); tx.setLocktime(e.locktime); tx.setUd(false); txs.put(e.hash,tx); } } return new ArrayList<Tx>(txs.values()); }  static TxJson fromJson(String response); static List<String> fromTxGetSourcesPending(TxJson sourceJson); static List<Tx> fromTx(TxJson sourceJson, Wallet wallet, Map<String, String> mapMember); static Map<String, List<String>> fromTxGetMapSourcePending(TxJson txJson); public String currency; public String pubkey; public History history; }