nem-apps-lib icon indicating copy to clipboard operation
nem-apps-lib copied to clipboard

Send failed for NEW Address

Open kunalransing opened this issue 6 years ago • 2 comments

Hi, My user can add his other NEM wallet's address which can be new, so below code is not working since not able to get public key using KeyConvertor.getPublicKeyFromAddress().

		NemAnnounceResult result = TransferTransactionBuilder
			    .sender(new Account(new KeyPair(PrivateKey.fromHexString("---private key----")))) 
			    .recipient(new Account(new KeyPair(PublicKey.fromHexString(**KeyConvertor.getPublicKeyFromAddress**("TCX3DLZ4YEJF2YRPXFG3VN6R2Y5ZEFUH32VADHXH")))))
			    .amount(Amount.fromMicroNem( amount.multiply(BigDecimal.valueOf(MICRONEMS_IN_NEM)).longValue()))
			    .fee(Amount.fromMicroNem( fee.multiply(BigDecimal.valueOf(MICRONEMS_IN_NEM)).longValue()) )
			    .buildAndSendTransaction();

How to send coins in above case ? Please help me. Thanks.

kunalransing avatar Apr 16 '18 10:04 kunalransing

Any update ? Please help.

kunalransing avatar May 04 '18 06:05 kunalransing

Only accounts that have already published a transaction have a public key assigned to the account. Otherwise the field is null.

See NIS1 API documentation https://nemproject.github.io/#account-related-requests

This is the reason why .getPublicKeyFromAddress cannot be used to get the public key for the account.

To send a simple transfer transaction without an encrypted message, it is not necessary to have the public key of the recipient (address is enough).

dexterslabor avatar May 25 '18 09:05 dexterslabor