--- /dev/null
+import {createKey, resetKeyPassword, createPubkey} from '../wasm/func';
+
+/**
+ * Represents a keysApi.
+ * @constructor
+ */
+function keysApi(http) {
+ this.http = http;
+}
+
+/**
+ * Create a new key, will generate the xpub.
+ *
+ * @param {Object} params - Parameters for accounts create.
+ * @param {String} params.alias - key alias,
+ * @param {String} params.password - key Password.
+ * @returns {Promise} key alias, key xpub
+ */
+keysApi.prototype.create = function(params) {
+ let inputParams = params
+ inputParams.auth = params.password
+ delete(inputParams['password'])
+ let promise = new Promise((resolve, reject) => {
+ createKey(inputParams).then(resp =>{
+ let jsonData = JSON.parse(resp.data);
+ const result = {
+ alias: jsonData.alias,
+ xpub: jsonData.xpub,
+ crypto: jsonData.crypto
+ };
+ resolve(result);
+ }).catch(error => {
+ reject(error);
+ });
+ });
+
+ return promise;
+};
+
+/**
+ * Reset key password, will generate the new xpub.
+ *
+ * @param {Object} params - Parameters for accounts create.
+ * @param {String} params.xpub - key alias,
+ * @param {String} params.oldPassword - key oldPassword.
+ * @param {String} params.newPassword - key newPassword.
+ * @param {Object} params.crypto - key crypto
+ * @returns {Promise} key alias, key xpub
+ */
+keysApi.prototype.resetKeyPassword = function(params) {
+ let inputParams = params
+ inputParams.rootXPub = params.xpub
+ delete(inputParams['xpub'])
+ let promise = new Promise((resolve, reject) => {
+ resetKeyPassword(inputParams).then(resp =>{
+ let jsonData = JSON.parse(resp.data);
+ const result = {
+ alias: jsonData.alias,
+ xpub: jsonData.xpub,
+ crypto: jsonData.crypto
+ };
+ resolve(result);
+ }).catch(error => {
+ reject(error);
+ });
+ });
+
+ return promise;
+};
+
+/**
+ * Create a new key.
+ *
+ * @param {String} xpub - xpub.
+ * @returns {Promise} xpub, pubkey, derived_path
+ *
+ */
+keysApi.prototype.createPubkey = function(xpub) {
+ let retPromise = new Promise((resolve, reject) => {
+ let data = {};
+ data.xpub = xpub;
+ data.seed = 1;
+ createPubkey(data).then((resp) => {
+ let jsonData = JSON.parse(resp.data);
+ resolve(jsonData);
+ }).catch(error => {
+ reject(error);
+ });
+ });
+ return retPromise;
+};
+
+export default keysApi;
\ No newline at end of file
+import {convertArguements} from '../utils/convertArguement';
+
/**
* Represents a transactionsApi.
* @constructor
*/
-import {convertArguements} from '../utils/convertArguement';
-
function transactionsApi(http) {
this.http = http;
}
*
* @param {Object} obj - Argument Object
* @param {String} obj.type - Argument Type, included data, address, string, integer, boolean.
- * @param {String|Number|Boolean}- obj.raw_data.value - data value
+ * @param {Object} obj.raw_data - Object Raw Data
+ * @param {String|Number|Boolean} obj.raw_data.value - data value
*/
transactionsApi.prototype.convertArguement = function (obj) {
return convertArguements(obj);
import axios from 'axios';
-import {handleApiError} from "./utils/http";
+import {handleApiError} from './utils/http';
const basePath = 'api/v1/btm/';
import queryApi from './api/query.js';
import accountsApi from './api/accounts.js';
import transactionsApi from './api/transactions.js';
+import keysApi from './api/keys.js';
import keysSDK from './sdk/keys.js';
import accountsSDK from './sdk/accounts.js';
import transactionSDK from './sdk/transaction.js';
this.http = new http(baseURL);
this.query = new queryApi(this.http);
this.accounts = new accountsApi(this.http);
+ this.keys = new keysApi(this.http);
this.transactions = new transactionsApi(this.http);
}
import {createAccount, createAccountReceiver} from '../wasm/func';
import {handleApiError, handleAxiosError} from '../utils/http';
-/**
- * Represents a accountSDK.
- * @constructor
- */
+
function accountsSDK(bytom){
this.http = bytom.serverHttp;
this.bytom = bytom;
import {getDB} from '../db/db';
-/**
- * Represents a keysSDK.
- * @constructor
- */
function keysSDK() {
}
import { handleAxiosError } from '../utils/http';
-/**
- * Represents a querySDK.
- * @constructor
- */
function querySDK(bytom) {
this.bytom =bytom;
this.http = bytom.serverHttp;
import { getDB } from '../db/db';
import keysSDK from "./keys";
-/**
- * Represents a transactionSDK.
- * @constructor
- */
function transactionSDK(bytom) {
this.http = bytom.serverHttp;
this.bytom = bytom;
* @param {String} to destination address
* @param {String} asset hexdecimal asset id
* @param {Number} amount transfer amount
- * @param {String} from source address
* @param {Number} fee transaction fee amount
+ * @param {Number} confirmations - transaction confirmations
* @returns {Promise}
*/
-transactionSDK.prototype.buildPayment = function(guid, to, asset, amount, from, fee) {
+transactionSDK.prototype.buildPayment = function(guid, to, asset, amount, fee, confirmations) {
let net = this.bytom.net;
let retPromise = new Promise((resolve, reject) => {
let pm = {guid: guid, to: to, asset: asset, amount: amount};
- if (from) {
- pm.from = from;
- }
if (fee) {
pm.fee = fee;
}
+ if (confirmations) {
+ pm.confirmations = confirmations;
+ }
this.http.request('merchant/build-payment', pm, net).then(resp => {
if (resp.status !== 200 || resp.data.code !== 200) {
reject(handleApiError(resp));
import {initDB, getDB} from '../db/db';
-/**
- * Represents a transactionSDK.
- * @constructor
- */
function walletSDK(bytom) {
this.bytom = bytom;
}