2

So I am trying to do a transaction in the private network, I have named it standalone, I am using SSL. I started the network using docker, then created a keypair, then in another terminal ran node to use javascript, below is my code:

var StellarSdk = require('stellar-sdk');

var server = new StellarSdk.Server('https://localhost:8000/tx?blob=Base64');

var kp = StellarSdk.Keypair.fromRawEd25519Seed(StellarSdk.hash("Standalone Network ; February 2017"))

var sourcePublicKey = kp.publicKey();

var receiverPublicKey = "GAI5VFPPZHJXE2O2MNMKAUBBUOMJOT6LUQYO2Q3NJXNAOGHXOYUVZMVW"

StellarSdk.Network.useTestNetwork();

server.loadAccount(sourcePublicKey)
.then(function(account) {
   var transaction = new StellarSdk.TransactionBuilder(account)
      .addOperation(StellarSdk.Operation.payment({
        destination: receiverPublicKey,
        asset: StellarSdk.Asset.native(),
        amount: '350.1234567',
  }))
  .build();
  transaction.sign(kp);
  console.log(transaction.toEnvelope().toXDR('base64'));
  server.submitTransaction(transaction)
   .then(function(transactionResult) 
     {console.log(JSON.stringify(transactionResult, null, 2));
      console.log('\nSuccess! View the transaction at: ');
      console.log(transactionResult._links.transaction.href);})
   .catch(function(err) {
      console.log('An error has occured:');
      console.log(err);
    });
   })
 .catch(function(e) 
 {console.error(e);
});

After running the above lines of code, I get a result:

Promise {
  <pending>,
  domain:
   Domain {
     domain: null,
     _events: { error: [Function: debugDomainError] },
     _eventsCount: 1,
     _maxListeners: undefined,
     members: [] } }

Error: Error: write EPROTO 139644081280832:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:827:

    at _handleNetworkError (/home/ec2-user/node_modules/stellar-sdk/lib/call_builder.js:273:31)
    at <anonymous>

P.S.: I have modified the Network.js file inside the node_modules folder and added a new passphrase for the standalone network and then modified the useTestNetwork Function to use the standalone network passphrase, not the testnetwork passphrase. Please let me know, what changes do I have to make in order to make this work.

1 Answer 1

0

Your var server = new StellarSdk.Server('https://localhost:8000/tx?blob=Base64'); is wrong, and should point at the server, not a specific endpoint.

3
  • I tried localhost:8000, still got the below response: Promise { <pending>, domain: Domain { domain: null, _events: { error: [Function: debugDomainError] }, _eventsCount: 1, _maxListeners: undefined, members: [] } } > Error: Error: write EPROTO 140423567779648:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:827: at _handleNetworkError (/home/ec2-user/node_modules/stellar-sdk/lib/call_builder.js:273:31) at <anonymous>
    – Deb
    Commented Sep 10, 2018 at 11:04
  • 1
    The error was because of SSL certificate, I used var server = new StellarSdk.Server('127.0.0.1:8000', {allowHttp: true}); and that error got resolved.
    – Deb
    Commented Sep 10, 2018 at 20:07
  • "{allowHttp: true}" helps, which let u try the functionality with HTTP. Try HTTPS later after things work.
    – cesarm
    Commented Sep 12, 2018 at 1:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.