@okxweb3/coin-stellar
Version:
@ok/coin-stellar is a Stellar SDK for building Web3 wallets and applications. It supports Stellar and PI blockchains, enabling private key management, address generation, transaction signing, trustline creation, and asset transfers
27 lines • 1.26 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createAccount = void 0;
const xdr_1 = __importDefault(require("../xdr"));
const keypair_1 = require("../keypair");
const strkey_1 = require("../strkey");
function createAccount(opts) {
if (!strkey_1.StrKey.isValidEd25519PublicKey(opts.destination)) {
throw new Error('destination is invalid');
}
if (!this.isValidAmount(opts.startingBalance, true)) {
throw new TypeError(this.constructAmountRequirementsError('startingBalance'));
}
const attributes = {};
attributes.destination = keypair_1.Keypair.fromPublicKey(opts.destination).xdrAccountId();
attributes.startingBalance = this._toXDRAmount(opts.startingBalance);
const createAccountOp = new xdr_1.default.CreateAccountOp(attributes);
const opAttributes = {};
opAttributes.body = xdr_1.default.OperationBody.createAccount(createAccountOp);
this.setSourceAccount(opAttributes, opts);
return new xdr_1.default.Operation(opAttributes);
}
exports.createAccount = createAccount;
//# sourceMappingURL=create_account.js.map