nem-apps-lib
nem-apps-lib copied to clipboard
Send failed for NEW Address
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.
Any update ? Please help.
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).