Advertisement
obernardovieira

stellar multi sig test

Sep 6th, 2018
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. app.get('/mstest', (request, response) => {
  2.  
  3.     var bobPair = StellarSdk.Keypair.fromSecret("SAN5EIFHBYNOGYNNQWI27DRQ67HHOLEMBM4V3IGSOX2QNNW2O3RBA27Y");
  4.     var alicePair = StellarSdk.Keypair.fromSecret("SDLNYNCBBS5NBGQTWWQR7CMUUADA4NGBUY6WU3TOEKVWET5VGOEKFD4K");
  5.  
  6.     var fromPair = StellarSdk.Keypair.fromSecret("SBABNCR62PCVUZSJL73KCNKFIQPWYPLAT2IHRCLERHGHCSIWE6HIDS3T");
  7.     var toPair = StellarSdk.Keypair.fromSecret("SDSLMS35MK5X3NOTHEBQW6M22GDDT2OJ76NW4ROOFTNVIKANIR4DFEOC");
  8.  
  9.     var bobAccount;
  10.     var aliceAccount;
  11.  
  12.     server.loadAccount(fromPair.publicKey())
  13.         .then(function (account) {
  14.  
  15.  
  16.             var transaction = new StellarSdk.TransactionBuilder(account)
  17.                 .addOperation(StellarSdk.Operation.payment({
  18.                     destination: toPair.publicKey(),
  19.                     asset: StellarSdk.Asset.native(),
  20.                     amount: '5',
  21.                 }))
  22.                 .build();
  23.  
  24.             transaction.sign(bobPair);
  25.             transaction.sign(alicePair);
  26.  
  27.             server.submitTransaction(transaction)
  28.                 .then(() => {
  29.                     response.send('5 lumens sent to ' + toPair.publicKey())
  30.                 })
  31.                 .catch((err) => {
  32.                     console.log(err.response.data.extras.result_codes);
  33.                     response.send('An error ocurred!')
  34.                 });
  35.  
  36.  
  37.         }).then(result => {
  38.             console.log('cenas!' + result.response.data.extras.result_codes);
  39.         })
  40.         .catch(function (error) {
  41.             console.error('Error!', error);
  42.         });
  43. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement