web3labs / erc20-rest-service

ERC-20 token standard RESTful service using Spring Boot and web3j
https://blk.io
182 stars 103 forks source link

Have to run Spring Boot RESTful server on the same machine with full node? #3

Open soulmachine opened 6 years ago

soulmachine commented 6 years ago

If I add a new api /newAddress to the Controller.java, and this API makes use of WalletUtils.generateFullNewWalletFile(), then I realize that my RESTful server have to access the keystore directory, which means my RESTful server has to run on the full node, am I correct?

    @RequestMapping(value = "/newAddress")
    String newAccount() throws Exception {
        // wallet file is named like `UTC--2018-03-16T05-09-05.79000000Z--3ae52004fd3e16c3b70b92ca0a9b382c786bf27e.json`
        String walletFileName = WalletUtils.generateFullNewWalletFile(getEncryptPassphrase(),
                new File(getKeystoreDir()));
        // in which `3ae52004fd3e16c3b70b92ca0a9b382c786bf27e` is address
        String[] fetchAddress = walletFileName.split("--");
        String address = "0x" + fetchAddress[fetchAddress.length-1].split("\\.")[0];
        return address;
    }
macrotea commented 2 years ago

why not read the file to parse json and get the address?