diff --git a/app/lnd/utils/index.js b/app/lnd/utils/index.js deleted file mode 100644 index 7662d117..00000000 --- a/app/lnd/utils/index.js +++ /dev/null @@ -1,42 +0,0 @@ -import zbase32 from 'zbase32' - -function convertBigEndianBufferToLong(longBuffer) { - let longValue = 0 - const byteArray = Buffer.from(longBuffer).swap64() - - for (let i = byteArray.length - 1; i >= 0; i -= 1) { - longValue = (longValue * 256) + byteArray[i] - } - - return longValue -} - -export function decodeInvoice(payreq) { - const payreqBase32 = zbase32.decode(payreq) - - const bufferHexRotated = Buffer.from(payreqBase32).toString('hex') - const bufferHex = bufferHexRotated.substr(bufferHexRotated.length - 1, bufferHexRotated.length) - + bufferHexRotated.substr(0, bufferHexRotated.length - 1) - const buffer = Buffer.from(bufferHex, 'hex') - - const pubkeyBuffer = buffer.slice(0, 33); - const pubkey = pubkeyBuffer.toString('hex'); - - const paymentHashBuffer = buffer.slice(33, 65) - const paymentHashHex = paymentHashBuffer.toString('hex') - - const valueBuffer = buffer.slice(65, 73) - - const amount = convertBigEndianBufferToLong(valueBuffer) - - return { - payreq, - pubkey, - amount, - r_hash: paymentHashHex - } -} - -export default { - decodeInvoice -} diff --git a/package.json b/package.json index f1bc3739..a9b05e78 100644 --- a/package.json +++ b/package.json @@ -222,8 +222,7 @@ "reselect": "^3.0.1", "satoshi-bitcoin": "^1.0.4", "source-map-support": "^0.4.15", - "xtend": "^4.0.1", - "zbase32": "^0.0.2" + "xtend": "^4.0.1" }, "devEngines": { "node": ">=7.x", diff --git a/yarn.lock b/yarn.lock index 35894bd7..df63de9b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9376,10 +9376,6 @@ yauzl@2.4.1: dependencies: fd-slicer "~1.0.1" -zbase32@^0.0.2: - version "0.0.2" - resolved "https://registry.yarnpkg.com/zbase32/-/zbase32-0.0.2.tgz#169c6f2130a6c27a84247017538b56826a54b283" - zip-stream@^1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/zip-stream/-/zip-stream-1.1.1.tgz#5216b48bbb4d2651f64d5c6e6f09eb4a7399d557"