XRPLF / xrpl.js

A JavaScript/TypeScript API for interacting with the XRP Ledger in Node.js and the browser
https://xrpl.org/
1.21k stars 512 forks source link

How to fix tefBAD_AUTH_MASTER #937

Closed luongquocdinh closed 6 years ago

luongquocdinh commented 6 years ago

I have domain authentication and get the ripple.txt file. It has an account and validation_public_key.

I use it for payment but error:

{
   "resultCode": "tefBAD_AUTH_MASTER"
   "resultMessage": "Auth for unclaimed account needs correct master key."
}

My code

const RippleAPI = require('ripple-lib').RippleAPI

// TESTNET ADDRESS 1
const ADDRESS_1 = process.argv[2];
const SECRET_1 = process.argv[3];

// TESTNET ADDRESS 2
const ADDRESS_2 = process.argv[4];

const instructions = {maxLedgerVersionOffset: 5}
const currency = 'XRP'
const amount = process.argv[5];

const payment = {
  source: {
    address: ADDRESS_1,
    maxAmount: {
      value: amount,
      currency: currency
    }
  },
  destination: {
    address: ADDRESS_2,
    amount: {
      value: amount,
      currency: currency
    }
  }
}

const api = new RippleAPI({
  server: 'wss://s1.ripple.com'                 // MAINNET
  //server: 'wss://s.altnet.rippletest.net:51233'   // TESTNET
})

api.connect().then(() => {
  console.log('Connected...')
  api.preparePayment(ADDRESS_1, payment, instructions).then(prepared => {
    const {signedTransaction, id} = api.sign(prepared.txJSON, SECRET_1)
    console.log(id)
    api.submit(signedTransaction).then(result => {
      console.log(JSON.stringify(result, null, 2))
      api.disconnect()
    })
  })
}).catch(console.error)

I took the secret value as the validation_public_key value in the ripple.txt file. Was it right?

Help me

Thank you

intelliot commented 6 years ago

Why do you want to use the validation_public_key as the secret?

Normally, you need to generate a secret. One way to do this is with generateAddress.

luongquocdinh commented 6 years ago

Yes, but how to fix error - tefBAD_AUTH_MASTER? I understand this error is because the single signature provided to authorize this transaction does not match the master key, but no regular key is associated with this address.

How to overlap master key and the single signature provided to authorize this transaction. Validate domain again?

Thanks

intelliot commented 6 years ago

The XRP Ledger account that you use for payments typically does not need a domain associated with it.

tefBAD_AUTH_MASTER means that the secret does not match the address. For the XRP Test Net, you can generate an address and secret at https://developers.ripple.com/xrp-test-net-faucet.html

luongquocdinh commented 6 years ago

I lost the secret key of my account. How can get the secret key from the account?

Thanks.

intelliot commented 6 years ago

How did you lose it?

The secret is generally not recoverable. You will need to generate a new secret (which will have a different address, of course).

luongquocdinh commented 6 years ago

Thanks, I fixed it 👍