Fix API call DELETE /crosschain/tradeoffer regarding PoW MESSAGE reference

This commit is contained in:
catbref 2020-07-29 10:38:32 +01:00
parent 098e2623d6
commit e2dc91c1ea

View File

@ -13,6 +13,7 @@ import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Random;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.ToIntFunction; import java.util.function.ToIntFunction;
@ -1127,13 +1128,12 @@ public class CrossChainResource {
} }
private byte[] buildAtMessage(Repository repository, byte[] senderPublicKey, String atAddress, byte[] messageData) throws DataException { private byte[] buildAtMessage(Repository repository, byte[] senderPublicKey, String atAddress, byte[] messageData) throws DataException {
PublicKeyAccount creatorAccount = new PublicKeyAccount(repository, senderPublicKey); // senderPublicKey is actually ephemeral trade public key, so there is no corresponding account and hence no reference
long txTimestamp = NTP.getTime(); long txTimestamp = NTP.getTime();
byte[] lastReference = creatorAccount.getLastReference();
if (lastReference == null) Random random = new Random();
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_REFERENCE); byte[] lastReference = new byte[Transformer.SIGNATURE_LENGTH];
random.nextBytes(lastReference);
int version = 4; int version = 4;
int nonce = 0; int nonce = 0;