@okxweb3/coin-bitcoin
Version:
@ok/coin-bitcoin is a Bitcoin SDK for building Web3 wallets and applications. It supports BTC, BSV, DOGE, LTC, and TBTC, enabling private key management, transaction signing, address generation, and inscriptions like BRC-20, Runes, CAT, and Atomicals.
29 lines • 967 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.canAdd = exports.check = exports.expected = exports.encode = exports.decode = void 0;
const typeFields_1 = require("../../typeFields");
function decode(keyVal) {
if (keyVal.key[0] !== typeFields_1.InputTypes.NON_WITNESS_UTXO) {
throw new Error('Decode Error: could not decode nonWitnessUtxo with key 0x' +
keyVal.key.toString('hex'));
}
return keyVal.value;
}
exports.decode = decode;
function encode(data) {
return {
key: Buffer.from([typeFields_1.InputTypes.NON_WITNESS_UTXO]),
value: data,
};
}
exports.encode = encode;
exports.expected = 'Buffer';
function check(data) {
return Buffer.isBuffer(data);
}
exports.check = check;
function canAdd(currentData, newData) {
return !!currentData && !!newData && currentData.nonWitnessUtxo === undefined;
}
exports.canAdd = canAdd;
//# sourceMappingURL=nonWitnessUtxo.js.map