Closed cpuchainorg closed 5 months ago
Would like to know if there is a reference function to determine address type from script or address string
I have a code like this but it doesn't cover every address types
function getScriptType(script) { if (script[0] === bitcoin.opcodes.OP_1 && script[1] === 32) { return 'taproot' } if (script[0] == bitcoin.opcodes.OP_0 && script[1] == 20) { return 'bech32' } if (script[0] == bitcoin.opcodes.OP_HASH160 && script[1] == 20) { return 'segwit' } if ( script[0] == bitcoin.opcodes.OP_DUP && script[1] == bitcoin.opcodes.OP_HASH160 && script[2] == 20 ) { return 'legacy' } }
We have encapsulated these methods
I think this is enough You can visit here https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/ts_src/psbt/psbtutils.ts#L18-L24
Would like to know if there is a reference function to determine address type from script or address string
I have a code like this but it doesn't cover every address types