The below code is the multisig transaction to submit to stellar horizon testnet. When I am submitting the transaction, I am getting the submission failed error.
var alice_public_key = 'GD2HPONSMOTEJQUE2WIUBPMWZ7WPAE7EBLW2RRD2XH6CIJHKCZKAYMZ3';
var alice_seed = 'SCQUFZIFKMF3CYXAYKPKBQZRF33O3YKJMQXL63PVW7O66GBQOTVKR3A5';
second_public_addr = 'GAYSO44LPX32TKXS5QWJ7ZVKW6DF42NOE22ZJJPXZZMAUIEVKKP5MYV5'
second_private_key = 'SAFSKKF4Q7HBO65HPTZ5I23HOJZ2WEQ4H4YRBSDQGQA222EWK5PPFZI4'
var destinationId = 'GA2C5RFPE6GCKMY3US5PAB6UZLKIGSPIUKSLRB6Q723BM2OARMDUYEJ5';
var StellarSdk = require('stellar-sdk');
var server = new StellarSdk.Server('https://horizon-testnet.stellar.org');
server.loadAccount(destinationId)
.catch(StellarSdk.NotFoundError, function (error) {
throw new Error('The destination account does not exist!');
})
.then(function() {
server.loadAccount(alice_public_key)
.then(function(account) {
// console.log(account.sequence)
var rootKeypair = StellarSdk.Keypair.fromSecret(alice_seed)
var account = new StellarSdk.Account(alice_public_key, account.sequence);
var transaction = new StellarSdk.TransactionBuilder(account)
.addOperation(StellarSdk.Operation.setOptions({
signer: {
ed25519PublicKey: second_public_addr,
weight: 1
}
}))
.addOperation(StellarSdk.Operation.setOptions({
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();
transaction.sign(rootKeypair);
// var x_transaction = transaction;
// console.log(x_transaction)
var transaction = new StellarSdk.TransactionBuilder(account)
.addOperation(StellarSdk.Operation.payment({
destination: destinationId,
asset: StellarSdk.Asset.native(),
amount: "10" // 2000 XLM
}))
.addMemo(StellarSdk.Memo.text('Test Transaction'))
.build();
var secondKeypair = StellarSdk.Keypair.fromSecret(second_private_key);
transaction.sign(rootKeypair);
transaction.sign(secondKeypair);
console.log(transaction)
server.submitTransaction(transaction)
.then(function (transactionResult) {
console.log(transactionResult);
})
.catch(function (err) {
console.error(err);
});
});
})
ERROR:
{ [BadResponseError: Transaction submission failed. Server responded: 400 Bad Request]
name: 'BadResponseError',
message: 'Transaction submission failed. Server responded: 400 Bad Request',
data:
{ type: 'https://stellar.org/horizon-errors/transaction_failed',
title: 'Transaction Failed',
status: 400,
detail: 'The transaction failed when submitted to the stellar network. The `extras.result_codes` field on this response contains further details. Descriptions of each code can be found at: https://www.stellar.org/developers/learn/concepts/list-of-operations.html',
extras:
{ envelope_xdr: 'AAAAAPR3ubJjpkTChNWRQL2Wz+zwE+QK7ajEern8JCTqFlQMAAAAZABrCz0AAAAIAAAAAAAAAAEAAAAQVGVzdCBUcmFuc2FjdGlvbgAAAAEAAAAAAAAAAQAAAACxymL+yL1Pze4i36tOuCt15BqNw6/XhAT4br3o8p0zpAAAAAAAAAAABfXhAAAAAAAAAAAC6hZUDAAAAECywXEM2F1RUKIKgP5rfnhey0Yr3vjuJdjZMGkExSb7zE2qbrYxs3hBN2Qk/ZsNy9SSbav/79vgNb3ePv5AvFcJ8p0zpAAAAEDGsDwv0p/714rrzSrdhNZ+sP0qr3wWp36VWUnbkzIlhievvJ3Tie7P6iP7iVU5Vobiwh+2mcaz5vLnSFnu3sgG',
result_codes: [Object],
result_xdr: 'AAAAAAAAAAD////7AAAAAA==' } } }