@Override public List<AbstractAddress> getReceivedFrom() { return ImmutableList.of((AbstractAddress) new NxtAddress(type, tx.getSenderId())); }
public NxtFamilyWallet(String id, NxtFamilyKey key, CoinType type) { super(type, id); rootKey = key; address = new NxtAddress(type, key.getPublicKey()); balance = type.value(0); addressesStatus = new HashMap<>(); addressesSubscribed = new ArrayList<>(); addressesPendingSubscription = new ArrayList<>(); statusPendingUpdates = new HashMap<>(); //fetchingTransactions = new HashSet<>(); rawtransactions = new HashMap<>(); listeners = new CopyOnWriteArrayList<>(); }
@Override public List<AbstractOutput> getSentTo() { return ImmutableList.of(new AbstractOutput(new NxtAddress(type, tx.getRecipientId()), Value.valueOf(type, tx.getAmountNQT()))); }
public static NxtAddress fromString(CoinType type, String address) throws AddressMalformedException { try { return new NxtAddress(type, Crypto.rsDecode(address.replace(type.getAddressPrefix(), "")), address); } catch (Exception e) { throw new AddressMalformedException(e); } }
if (possibleType instanceof NxtFamily) { try { address = new NxtAddress(possibleType, addressToken); putWithValidation(FIELD_ADDRESS, address); break;
@Test public void testHDAccountNxt() throws MnemonicException, UnreadableWalletException { DeterministicSeed seed = new DeterministicSeed(recoveryPhrase, null, "", 0); DeterministicKey masterKey = HDKeyDerivation.createMasterPrivateKey(seed.getSeedBytes()); DeterministicHierarchy hierarchy = new DeterministicHierarchy(masterKey); DeterministicKey entropy = hierarchy.get(NxtMain.get().getBip44Path(0), false, true); NxtFamilyKey nxtKey = new NxtFamilyKey(entropy, null, null); byte[] privateKey = nxtKey.getPrivateKey(); byte[] publicKey = nxtKey.getPublicKey(); NxtAddress address = new NxtAddress(NxtMain.get(), publicKey); assertArrayEquals(nxtPrivateKey, privateKey); assertArrayEquals(nxtPublicKey, publicKey); assertEquals(nxtRsAddress, address.toString()); assertEquals(nxtAccountId, address.getAccountId()); }
@Test public void testAltChainsConvertToCoinURI() throws Exception { byte[] hash160 = BitAddress.from(BitcoinMain.get(), MAINNET_GOOD_ADDRESS).getHash160(); String goodAddressStr; BitAddress goodAddress; // Litecoin goodAddress = BitAddress.from(LTC, hash160); goodAddressStr = goodAddress.toString(); assertEquals("litecoin:" + goodAddressStr + "?amount=12.34&label=Hello&message=AMessage", CoinURI.convertToCoinURI(goodAddress, LTC.value("12.34"), "Hello", "AMessage")); // Dogecoin goodAddress = BitAddress.from(DOGE, hash160); goodAddressStr = goodAddress.toString(); assertEquals("dogecoin:" + goodAddressStr + "?amount=12.34&label=Hello&message=AMessage", CoinURI.convertToCoinURI(goodAddress, DOGE.value("12.34"), "Hello", "AMessage")); // Peercoin goodAddress = BitAddress.from(PPC, hash160); goodAddressStr = goodAddress.toString(); assertEquals("peercoin:" + goodAddressStr + "?amount=12.34&label=Hello&message=AMessage", CoinURI.convertToCoinURI(goodAddress, PPC.value("12.34"), "Hello", "AMessage")); // Darkcoin goodAddress = BitAddress.from(DASH, hash160); goodAddressStr = goodAddress.toString(); assertEquals("dash:" + goodAddressStr + "?amount=12.34&label=Hello&message=AMessage", CoinURI.convertToCoinURI(goodAddress, DASH.value("12.34"), "Hello", "AMessage")); // NXT String pubkeyStr = "3c1c0b3f8f87d6efdc2694ce43f848375a4f761624d255e5fc1194a4ebc76755"; byte[] pubkey = Hex.decode(pubkeyStr); NxtAddress nxtGoodAddress = new NxtAddress(NXT, pubkey); goodAddressStr = nxtGoodAddress.toString(); assertEquals("nxt:" + goodAddressStr + "?amount=12.34&label=Hello&message=AMessage&pubkey="+pubkeyStr, CoinURI.convertToCoinURI(nxtGoodAddress, NXT.value("12.34"), "Hello", "AMessage", pubkeyStr)); }