symbol / symbol-openapi

OpenAPI specification for catapult-rest
https://nemtech.github.io/api.html
Apache License 2.0
12 stars 6 forks source link

Failure_Core_Insufficient_Balance #295

Open qlfgggggg opened 2 years ago

qlfgggggg commented 2 years ago

I have sufficient balance in testnet.

qlfgggggg commented 2 years ago
@Test
public void firstApplication() throws ExecutionException, InterruptedException, IOException {
    /* start block 01 */
    // replace with node endpoint
    try (final RepositoryFactory repositoryFactory = new RepositoryFactoryVertxImpl(
            "https://mikun-testnet.tk:3001")) {
        // replace with mosaic id   这个每次都要修改
        final String mosaicIdHex = "191AA3B1984EB8A3";
        final MosaicId mosaicId = new MosaicId(mosaicIdHex);

        // replace with customer address  这个是customer address
        final String rawAddress = "TCASUE-D2RURZ-TF35J6-X2PFT7-DPMCQZ-BT532E-76Q";
        // final String rawAddress = "TBOZBN-PYLQP6-ZIOMGM-ZZS5IC-5IAQOA-H23B6G-NHI";
        // final String rawAddress = "TDFYDF-R4V6U3-NOU7RE-LXNVXE-2UJDKW-NEYSU2-ODQ";
        final UnresolvedAddress recipientAddress = Address.createFromRawAddress(rawAddress);
        final NetworkType networkType = repositoryFactory.getNetworkType().toFuture().get();

        final Mosaic mosaic = new Mosaic(mosaicId, BigInteger.valueOf(1));
        String url = "https://mikun-testnet.tk:3001/network/properties";
        Map<String,String> map = new HashMap<>();
        Map<String,String> map1 = new HashMap<>();
        HttpClientUtil.Response response = HttpClientUtil.get(url, map, map1);

        String body = response.getBody();
        JSONObject jsonObject = JSONObject.parseObject(body);
        String network = jsonObject.getString("network");
        JSONObject jsonObject1 = JSON.parseObject(network);
        String epochAdjustment = jsonObject1.getString("epochAdjustment");
        String e = epochAdjustment.substring(0,epochAdjustment.length()-1);
        Deadline deadline = Deadline.create(Duration.ofSeconds(Long.valueOf(e)));
        final TransferTransaction transferTransaction = TransferTransactionFactory
                .create(
                        networkType,
                        deadline,
                        recipientAddress,
                        Collections.singletonList(mosaic))
                .maxFee(BigInteger.valueOf(2000000)).build();
        /* end block 01 */

        /* start block 02 */
        // replace with ticket vendor private key
        final String privateKey = "F73EECD4A5DF1C34F03E86D952B09C21C7C99EBF69EFF56D5D4085815202439C";
        // replace with network generation hash
        // final String generationHash = repositoryFactory.getGenerationHash().toFuture().get();
        final String generationHash = "7FCCD304802016BEBBCD342A332F91FF1F3BB5E902988B352697BE245F48E836";

        final Account account = Account
                .createFromPrivateKey(privateKey, networkType);
        final SignedTransaction signedTransaction = account
                .sign(transferTransaction, generationHash);
        /* end block 02 */

        /* start block 03 */
        final TransactionRepository transactionRepository = repositoryFactory
                .createTransactionRepository();
        transactionRepository.announce(signedTransaction).toFuture().get();
    }
    /* end block 03 */
}
qlfgggggg commented 2 years ago

symbol-cli transaction mosaic --amount 10 --supply-mutable \ --divisibility 0 --duration 2 --max-fee 2000000 \ --sync --profile testweb

yilmazbahadir commented 2 years ago

Hi @qlfgggggg, are you sure there is a mosaic in TEST_NET with the ID 191AA3B1984EB8A3?

https://401-joey-dual.symboltest.net:3001/mosaics/191AA3B1984EB8A3 image

When I check the balance for the following privateKey in the testnet explorer, I can't see any balance regarding the mosaicID:191AA3B1984EB8A3 you used. final String privateKey = "F73EECD4A5DF1C34F03E86D952B09C21C7C99EBF69EFF56D5D4085815202439C";

symbol-cli converter privateKeyToPublicKey -n TEST_NET --private-key F73EECD4A5DF1C34F03E86D952B09C21C7C99EBF69EFF56D5D4085815202439C
> A928490719CBE77D0061F42E2F5425C0EB2C0C56FE74BFF2994208886A26FAD1

symbol-cli converter publicKeyToAddress -n TEST_NET --public-key A928490719CBE77D0061F42E2F5425C0EB2C0C56FE74BFF2994208886A26FAD1
> TBOZBN-PYLQP6-ZIOMGM-ZZS5IC-5IAQOA-H23B6G-NHI

Please check the details: https://testnet.symbol.fyi/accounts/TBOZBNPYLQP6ZIOMGMZZS5IC5IAQOAH23B6GNHI image