To create an account on a Stellar private network, I need to pay some lumens from my root account. Once I created the key-pair, I tried making a payment from the root account. It fails because, the payment destination account does not exist.
Can you please help me understand, how to create an account?
Transaction - results in 400
var StellarSdk = require('stellar-sdk');
var HORIZON_ENDPOINT = process.env.HORIZON_ENDPOINT;
var NETWORK_PASSPHRASE = process.env.NETWORK_PASSPHRASE;
var fromWallet = process.argv[2];
var toWallet = process.argv[3];
var xferAmount = process.argv[4];
StellarSdk.Network.use(new StellarSdk.Network(NETWORK_PASSPHRASE));
var opts = new StellarSdk.Config.setAllowHttp(true);
var server = new StellarSdk.Server(HORIZON_ENDPOINT, opts);
var sourceKeys = StellarSdk.Keypair.fromSecret(fromWallet);
var destinationId = toWallet;
server.loadAccount(sourceKeys.publicKey())
.then(function(sourceAccount) {
var transaction = new StellarSdk.TransactionBuilder(sourceAccount)
.addOperation(StellarSdk.Operation.payment({
destination: destinationId,
asset: StellarSdk.Asset.native(),
amount: xferAmount
}))
.addMemo(StellarSdk.Memo.text('Test Transaction'))
.build();
transaction.sign(sourceKeys);
return server.submitTransaction(transaction);
})
.then(function(result) {
console.log('Success! Results:', result);
})
.catch(function(error) {
console.error('Something went wrong!', error);
});
The XDR envelope for the HTTP 400
is:
sourceAccount: [publicKeyTypeEd25519]
ed25519: GAC...L7C
fee: 100
seqNum: 1
timeBounds: none
memo: [memoText]
text: Test Transaction
operations: Array[1]
[0]
sourceAccount: none
body: [payment]
paymentOp
destination: [publicKeyTypeEd25519]
ed25519: GBH...FL3
asset: [assetTypeNative]
amount: 25.36 (raw: 253600000)
signatures: Array[1]
[0]
hint: G______________________________________________2JKHC____
signature: PVg...9DQ==
And, the result code is:
TransactionResult
feeCharged: 100
result: [txFailed]
results: Array[1]
[0]: [opInner]
tr: [payment]
paymentResult: [paymentNoDestination]