PHP WebShell
Текущая директория: /usr/lib/node_modules/bitgo/node_modules/stellar-base/lib/operations
Просмотр файла: create_account.js
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createAccount = createAccount;
var _xdr = require('../xdr');
var _xdr2 = _interopRequireDefault(_xdr);
var _keypair = require('../keypair');
var _strkey = require('../strkey');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Create and fund a non existent account.
* @function
* @alias Operation.createAccount
* @param {object} opts Options object
* @param {string} opts.destination - Destination account ID to create an account for.
* @param {string} opts.startingBalance - Amount in XLM the account should be funded for. Must be greater
* than the [reserve balance amount](https://developers.stellar.org/docs/glossary/fees/).
* @param {string} [opts.source] - The source account for the payment. Defaults to the transaction's source account.
* @returns {xdr.CreateAccountOp} Create account operation
*/
function createAccount(opts) {
if (!_strkey.StrKey.isValidEd25519PublicKey(opts.destination)) {
throw new Error('destination is invalid');
}
if (!this.isValidAmount(opts.startingBalance, true)) {
throw new TypeError('startingBalance must be of type String, represent a non-negative number and have at most 7 digits after the decimal');
}
var attributes = {};
attributes.destination = _keypair.Keypair.fromPublicKey(opts.destination).xdrAccountId();
attributes.startingBalance = this._toXDRAmount(opts.startingBalance);
var createAccountOp = new _xdr2.default.CreateAccountOp(attributes);
var opAttributes = {};
opAttributes.body = _xdr2.default.OperationBody.createAccount(createAccountOp);
this.setSourceAccount(opAttributes, opts);
return new _xdr2.default.Operation(opAttributes);
}Выполнить команду
Для локальной разработки. Не используйте в интернете!