How to use the stellar-base.Keypair.fromAddress function in stellar-base

To help you get started, we’ve selected a few stellar-base examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stellar / js-stellar-sdk / src / operation.js View on Github external
static createAccount(opts) {
        if (!opts.destination) {
            throw new Error("Must provide a destination for a payment operation");
        }
        if (!opts.startingBalance) {
            throw new Error("Must provide a starting balance");
        }
        let attributes = {};
        attributes.destination  = Keypair.fromAddress(opts.destination).publicKey();
        attributes.startingBalance = Hyper.fromString(String(opts.startingBalance));
        let createAccount = new xdr.CreateAccountOp(attributes);

        let opAttributes = {};
        opAttributes.body = xdr.OperationBody.createAccount(createAccount);
        if (opts.source) {
            opAttributes.sourceAccount = Keypair.fromAddress(opts.source).publicKey();
        }
        let op = new xdr.Operation(opAttributes);
        return op;
    }
github stellar / js-stellar-sdk / src / operation.js View on Github external
static inflation(opts={}) {
        let opAttributes = {};
        opAttributes.body = xdr.OperationBody.inflation();
        if (opts.source) {
            opAttributes.sourceAccount = Keypair.fromAddress(opts.source).publicKey();
        }
        let op = new xdr.Operation(opAttributes);
        return op;
    }
github stellar / js-stellar-sdk / src / operation.js View on Github external
static changeTrust(opts) {
        let attributes      = {};
        attributes.line     = opts.currency.toXdrObject();
        let limit           = opts.limit ? limit : "9223372036854775807";
        attributes.limit    = Hyper.fromString(limit);
        if (opts.source) {
            attributes.source   = opts.source ? opts.source.masterKeypair : null;
        }
        let changeTrustOP = new xdr.ChangeTrustOp(attributes);

        let opAttributes = {};
        opAttributes.body = xdr.OperationBody.changeTrust(changeTrustOP);
        if (opts.source) {
            opAttributes.sourceAccount = Keypair.fromAddress(opts.source).publicKey();
        }
        let op = new xdr.Operation(opAttributes);
        return op;
    }
github stellar / js-stellar-sdk / src / operation.js View on Github external
}
        if (opts.signer) {
            let signer = new xdr.Signer({
                pubKey: Keypair.fromAddress(opts.signer.address).publicKey(),
                weight: opts.signer.weight
            });
            attributes.signer = signer;
        }
        if (opts.homeDomain) {
            attributes.homeDomain = opts.homeDomain;
        }
        let setOptionsOp = new xdr.SetOptionsOp(attributes);
        let opAttributes = {};
        opAttributes.body = xdr.OperationBody.setOption(setOptionsOp);
        if (opts.source) {
            opAttributes.sourceAccount = Keypair.fromAddress(opts.source).publicKey();
        }
        let op = new xdr.Operation(opAttributes);
        return op;
    }
github stellar / js-stellar-sdk / src / operation.js View on Github external
}


        let attributes = {};
        attributes.sendCurrency = opts.sendCurrency.toXdrObject();
        attributes.sendMax      = Hyper.fromString(String(opts.sendMax));
        attributes.destination  = Keypair.fromAddress(opts.destination).publicKey();
        attributes.destCurrency = opts.destCurrency.toXdrObject();
        attributes.destAmount       = Hyper.fromString(String(opts.destAmount));
        attributes.path         = opts.path ? opts.path : [];
        let payment = new xdr.PathPaymentOp(attributes);

        let opAttributes = {};
        opAttributes.body = xdr.OperationBody.pathPayment(payment);
        if (opts.source) {
            opAttributes.sourceAccount = Keypair.fromAddress(opts.source).publicKey();
        }
        let op = new xdr.Operation(opAttributes);
        return op;
    }
github stellar / js-stellar-sdk / src / operation.js View on Github external
static payment(opts) {
        if (!opts.destination) {
            throw new Error("Must provide a destination for a payment operation");
        }
        if (!opts.currency) {
            throw new Error("Must provide a currency for a payment operation");
        }
        if (!opts.amount) {
            throw new Error("Must provide an amount for a payment operation");
        }

        let attributes = {};
        attributes.destination  = Keypair.fromAddress(opts.destination).publicKey();
        attributes.currency     = opts.currency.toXdrObject();
        attributes.amount       = Hyper.fromString(String(opts.amount));
        let payment = new xdr.PaymentOp(attributes);

        let opAttributes = {};
        opAttributes.body = xdr.OperationBody.payment(payment);
        if (opts.source) {
            opAttributes.sourceAccount = Keypair.fromAddress(opts.source).publicKey();
        }
        let op = new xdr.Operation(opAttributes);
        return op;
    }
github stellar / js-stellar-sdk / src / operation.js View on Github external
static accountMerge(opts) {
        let opAttributes = {};
        opAttributes.body = xdr.OperationBody.accountMerge(
            Keypair.fromAddress(opts.destination).publicKey()
        );
        if (opts.source) {
            opAttributes.sourceAccount = Keypair.fromAddress(opts.source).publicKey();
        }
        let op = new xdr.Operation(opAttributes);
        return op;
    }
github stellar / js-stellar-sdk / src / operation.js View on Github external
throw new Error("Must provide a currency for a payment operation");
        }
        if (!opts.amount) {
            throw new Error("Must provide an amount for a payment operation");
        }

        let attributes = {};
        attributes.destination  = Keypair.fromAddress(opts.destination).publicKey();
        attributes.currency     = opts.currency.toXdrObject();
        attributes.amount       = Hyper.fromString(String(opts.amount));
        let payment = new xdr.PaymentOp(attributes);

        let opAttributes = {};
        opAttributes.body = xdr.OperationBody.payment(payment);
        if (opts.source) {
            opAttributes.sourceAccount = Keypair.fromAddress(opts.source).publicKey();
        }
        let op = new xdr.Operation(opAttributes);
        return op;
    }
github stellar / js-stellar-sdk / src / operation.js View on Github external
static createAccount(opts) {
        if (!opts.destination) {
            throw new Error("Must provide a destination for a payment operation");
        }
        if (!opts.startingBalance) {
            throw new Error("Must provide a starting balance");
        }
        let attributes = {};
        attributes.destination  = Keypair.fromAddress(opts.destination).publicKey();
        attributes.startingBalance = Hyper.fromString(String(opts.startingBalance));
        let createAccount = new xdr.CreateAccountOp(attributes);

        let opAttributes = {};
        opAttributes.body = xdr.OperationBody.createAccount(createAccount);
        if (opts.source) {
            opAttributes.sourceAccount = Keypair.fromAddress(opts.source).publicKey();
        }
        let op = new xdr.Operation(opAttributes);
        return op;
    }
github stellar / js-stellar-sdk / src / operation.js View on Github external
static allowTrust(opts) {
        let attributes = {};
        attributes.trustor = Keypair.fromAddress(opts.trustor).publicKey();
        let code = opts.currencyCode.length == 3 ? opts.currencyCode + "\0" : opts.currencyCode;
        attributes.currency = xdr.AllowTrustOpCurrency.currencyTypeAlphanum(code);
        attributes.authorize = opts.authorize;
        let allowTrustOp = new xdr.AllowTrustOp(attributes);

        let opAttributes = {};
        opAttributes.body = xdr.OperationBody.allowTrust(allowTrustOp);
        if (opts.source) {
            opAttributes.sourceAccount = Keypair.fromAddress(opts.source).publicKey();
        }
        let op = new xdr.Operation(opAttributes);
        return op;
    }