Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.get('/multisig/:accf/:acct', (request, response) => {
- var pairSecond = StellarSdk.Keypair.fromSecret(request.params.accf);
- var mainPair = StellarSdk.Keypair.fromSecret(request.params.acct);
- var pairToBePaid = StellarSdk.Keypair.fromSecret("SCK3Z2STK2BQ6WT3XDUJ4MM3TUO2NOWRYJBOAJTQHBPV5EGA7YKRGFHX");
- server.loadAccount(mainPair.publicKey()).then((account) => {
- var transaction = new StellarSdk.TransactionBuilder(account)
- .addOperation(StellarSdk.Operation.payment({
- destination: pairToBePaid.publicKey(),
- asset: StellarSdk.Asset.native(),
- amount: "2" // 2000 XLM
- }))
- .addOperation(StellarSdk.Operation.setOptions({
- setFlags: 1,
- signer: {
- ed25519PublicKey: pairSecond.publicKey(),
- weight: 1
- },
- masterWeight: 1, // set master key weight
- lowThreshold: 1,
- medThreshold: 2, // a payment is medium threshold
- highThreshold: 2 // make sure to have enough weight to add up to the high threshold!
- }))
- .build();
- // now we need to sign the transaction with both the root and the secondaryAddress
- transaction.sign(pairSecond);
- transaction.sign(mainPair);
- server.submitTransaction(transaction)
- .then(() => {
- response.send('2 lumens sent to ' + pairToBePaid.publicKey())
- })
- .catch((err) => {
- console.log(err.response.data.extras.result_codes);
- response.send('An error ocurred!')
- });
- }).catch((err) => {
- console.log(err.response.data.extras.result_codes);
- response.send('An error ocurred!')
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement