bitcoinjs-lib
bitcoinjs-lib copied to clipboard
bitcoin.script.classifyOutput is not a function
I have been trying to find it's alternative for hours now but lack of official documentation makes it difficult to find proper method
after going through number of issues i know that this function was deprecated or removed but what is its alternative ?
install v3 instead.
or update your code to use v4.
install v3 instead.
or update your code to use v4.
it is already v4
"bitcoinjs-lib": "^4.0.2",
update your code to use v4.
package.json is not code.
"update your code to use v4" means "stop using bitcoin.script.classifyOutput since it is no longer available in v4"
update your code to use v4.
package.json is not code.
"update your code to use v4" means "stop using bitcoin.script.classifyOutput since it is no longer available in v4"
thats what i am asking what to use instead of classifyOutput ?
@mfaizan1 what is your use case for classifyOutput?
thats what i am asking what to use instead of classifyOutput?
There is no 1:1 exact replacement for classifyOutput.
Please show us some code and for what you are using classifyOutput.
Most likely you can accomplish the same goal with the payments API.
thats what i am asking what to use instead of classifyOutput?
There is no 1:1 exact replacement for classifyOutput.
Please show us some code and for what you are using classifyOutput.
Most likely you can accomplish the same goal with the payments API. @dcousens here is the code i am trying to use.
var decodeOutput = function(tx){
var format = function(out, n){
var vout = {
satoshi: out.value,
value: (1e-8 * out.value).toFixed(8),
n: n,
scriptPubKey: {
asm: Btc.script.toASM(out.script),
hex: out.script.toString('hex'),
type: Btc.script.classifyOutput(out.script),
addresses: [],
},
};
switch(vout.scriptPubKey.type){
case 'pubkeyhash':
case 'scripthash':
vout.scriptPubKey.addresses.push(Btc.address.fromOutputScript(out.script, Btc.networks.regtest));
break;
}
return vout
}
var result = [];
tx.outs.forEach(function(out, n){
result.push(format(out, n));
})
return result
}
"bitcoinjs-lib": "^4.0.2",
- Quick 'dirty' fix :
bitcoin.script.classifyOutput = require('./node_modules/bitcoinjs-lib/src/classify').output;
Please don't
thats what i am asking what to use instead of classifyOutput?
There is no 1:1 exact replacement for classifyOutput. Please show us some code and for what you are using classifyOutput. Most likely you can accomplish the same goal with the payments API. @dcousens here is the code i am trying to use.
var decodeOutput = function(tx){ var format = function(out, n){ var vout = { satoshi: out.value, value: (1e-8 * out.value).toFixed(8), n: n, scriptPubKey: { asm: Btc.script.toASM(out.script), hex: out.script.toString('hex'), type: Btc.script.classifyOutput(out.script), addresses: [], }, }; switch(vout.scriptPubKey.type){ case 'pubkeyhash': case 'scripthash': vout.scriptPubKey.addresses.push(Btc.address.fromOutputScript(out.script, Btc.networks.regtest)); break; } return vout } var result = []; tx.outs.forEach(function(out, n){ result.push(format(out, n)); }) return result }
Did you ever get this figured out IC nobody answered you. I have same question.
@mfaizan1 , @mmvphil I fixed decodeOutput function to align with the latest bitcoinjs-lib version.
Please refer to https://github.com/bitcoinjs/bitcoinjs-lib/issues/760#issuecomment-1692806359.