I want to see my account bitcoin address via JavaScript, I use the following code, but it only displays:
[ 'error', 10112, 'signature: invalid' ]
when run, I followed the code from the source docs.
const CryptoJS = require('crypto-js') // Standard JavaScript cryptography library
const fetch = require('node-fetch') // "Fetch" HTTP req library
const apiKey = 'xxxxxxxxx'
const apiSecret = 'xxxxxxxxxx'
const apiPath = 'v2/auth/w/deposit/address'// Example path
fetch(`https://api.bitfinex.com/${apiPath}`, {
method: 'POST',
body: JSON.stringify({
wallet: 'trading',
method: 'bitcoin',
op_renew: 0 // 1 for new address
}),
headers: {
'Content-Type': 'application/json',
'bfx-apikey': apiKey
}
})
.then(res => res.json())
.then(json => console.log(json))
.catch(err => {
console.log(err)
})
It looks like the error message "signature: invalid" suggests an issue with the authentication signature you are using. The Bitfinex API requires you to sign your request using your API key and secret.