下载钱包
https://github.com/dashpay/dash/releases/download/v0.15.0.0/dashcore-0.15.0.0-win64-setup.exe
配置文件
#rpcuser, rpcpassword, rpcport
rpcuser=
rpcpassword=
rpcport=19998
#rpcbind=127.0.0.1
rpcbind=0.0.0.0
rpcallowip=
listen=1
server=1
daemon=1
上代码
public class DashApi extends BitcoinJSONRPCClient implements CoinBaseApi {
static Logger logger = Logger.getLogger(QtumApi.class) ;
private String rpcUrl ;
private String rpcPwd ;
private String rpcName ;
private String rpcPost ;
private static final String coinName = "DASH" ;
public DashApi(URL rpcUrl) throws MalformedURLException {
super(rpcUrl);
}
初始化链接
public static DashApi getInstance(String rpcUrl,String rpcPwd,String rpcName,String rpcPost){
try{
URL url=new URL("http://" + rpcName + ":" + rpcPwd + "@" + rpcUrl + ":" + rpcPost + "/") ;
return new DashApi(url) ;
}catch (Exception e){
logger.error(coinName+"创建链接失败!{"+e.getMessage()+"}") ;
}
return null ;
}
创建地址
public String newAddress(String obj) {
return this.getNewAddress() ;
}
获取余额
public double getBalanceNumber(String address) {
return super.getBalance().doubleValue() ;
}
解锁钱包(十秒)
public boolean walletpassphrase(String pwd, long times) {
this.walletPassPhrase(pwd,10);
return false;
}
转账
public String send(String from, String to, String amount, String privateKey) {
try{
String s = this.sendToAddress(to, BigDecimal.valueOf( Double.valueOf(amount)));
return s ;
}catch (Exception e){
logger.warn(coinName+"转账失败!{"+e.getMessage()+"}");
}
return null ;
}
获取 txid中的详细信息
public RawTransaction getRawTransaction(String txid){
RawTransaction rawTransaction = getRawTransaction(txid) ;
return rawTransaction;
}
查询钱包中的交易记录
public List<Transaction> listTransactions(int count){
List<Transaction> transactions = listTransactions("*", count);
return transactions ;
}