Added bitshares faucet api only with text
This commit is contained in:
parent
376b6278b3
commit
3005b60935
2 changed files with 37 additions and 8 deletions
|
@ -1,5 +1,7 @@
|
|||
package cy.agorise.crystalwallet.apigenerator;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
/**
|
||||
* Created by henry on 15/10/2017.
|
||||
*/
|
||||
|
@ -16,7 +18,30 @@ public abstract class BitsharesFaucetApiGenerator {
|
|||
* @return The bitshares id of the registered account, or null
|
||||
*/
|
||||
public static String registerBitsharesAccount(String accountName, String ownerKey, String activeKey, String memoKey){
|
||||
CreateAccountPetition petition = new CreateAccountPetition();
|
||||
Account account = new Account();
|
||||
account.name=accountName;
|
||||
account.owner_key=ownerKey;
|
||||
account.active_key=activeKey;
|
||||
account.memo_key=memoKey;
|
||||
petition.account=account;
|
||||
Gson gson = new Gson();
|
||||
String jsonPetition = gson.toJson(petition);
|
||||
System.out.println("create account petition :" + jsonPetition);
|
||||
|
||||
//TODO faucet function
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static class CreateAccountPetition{
|
||||
Account account;
|
||||
}
|
||||
|
||||
private static class Account{
|
||||
String name;
|
||||
String owner_key;
|
||||
String active_key;
|
||||
String memo_key;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,20 +60,24 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
|||
|
||||
GrapheneAccount grapheneAccount = (GrapheneAccount) account;
|
||||
|
||||
BitsharesFaucetApiGenerator.registerBitsharesAccount(grapheneAccount.getName(),
|
||||
String btsIdAccount = BitsharesFaucetApiGenerator.registerBitsharesAccount(grapheneAccount.getName(),
|
||||
new Address(grapheneAccount.getOwnerKey(),"BTS").toString(),
|
||||
new Address(grapheneAccount.getActiveKey(),"BTS").toString(),
|
||||
new Address(grapheneAccount.getMemoKey(),"BTS").toString());
|
||||
if(btsIdAccount !=null) {
|
||||
grapheneAccount.setAccountId(btsIdAccount);
|
||||
|
||||
CrystalDatabase db = CrystalDatabase.getAppDatabase(context);
|
||||
db.cryptoNetAccountDao().insertCryptoNetAccount(grapheneAccount);
|
||||
long idAccount = db.cryptoNetAccountDao().insertCryptoNetAccount(grapheneAccount)[0];
|
||||
grapheneAccount.setId(idAccount);
|
||||
db.grapheneAccountInfoDao().insertGrapheneAccountInfo(new GrapheneAccountInfo(grapheneAccount));
|
||||
|
||||
GrapheneApiGenerator.subscribeBitsharesAccount(grapheneAccount.getId(), grapheneAccount.getAccountId(), context);
|
||||
this.refreshAccountTransactions(account.getId(), context);
|
||||
this.refreshAccountTransactions(grapheneAccount.getId(), context);
|
||||
GrapheneApiGenerator.getAccountBalance(grapheneAccount.getId(), grapheneAccount.getAccountId(), context);
|
||||
return grapheneAccount;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue