desc hash
This commit is contained in:
parent
8223ab882a
commit
fdcd4a7c32
2 changed files with 8 additions and 4 deletions
|
|
@ -1,14 +1,14 @@
|
|||
import { OpenChannelRequest, Invoice } from "../../../proto/lnd/lightning";
|
||||
|
||||
export const AddInvoiceReq = (value: number, memo = "", expiry = 60 * 60, privateHints = false): Invoice => ({
|
||||
export const AddInvoiceReq = (value: number, descriptionHash = Buffer.alloc(0), expiry = 60 * 60, privateHints = false): Invoice => ({
|
||||
expiry: BigInt(expiry),
|
||||
memo: memo,
|
||||
memo: "",
|
||||
private: privateHints,
|
||||
value: BigInt(value),
|
||||
|
||||
fallbackAddr: "",
|
||||
cltvExpiry: 0n,
|
||||
descriptionHash: Buffer.alloc(0),
|
||||
descriptionHash,
|
||||
features: {},
|
||||
isAmp: false,
|
||||
rPreimage: Buffer.alloc(0),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
//const grpc = require('@grpc/grpc-js');
|
||||
import crypto from 'crypto'
|
||||
import { credentials, Metadata } from '@grpc/grpc-js'
|
||||
import { GrpcTransport } from "@protobuf-ts/grpc-transport";
|
||||
import fs from 'fs'
|
||||
|
|
@ -136,7 +137,10 @@ export default class {
|
|||
|
||||
async NewInvoice(value: number, memo: string, expiry: number): Promise<Invoice> {
|
||||
this.checkReady()
|
||||
const res = await this.lightning.addInvoice(AddInvoiceReq(value, memo, expiry), DeadLineMetadata())
|
||||
const encoder = new TextEncoder()
|
||||
const ecoded = encoder.encode(memo)
|
||||
const hashed = crypto.createHash('sha256').update(ecoded).digest();
|
||||
const res = await this.lightning.addInvoice(AddInvoiceReq(value, hashed, expiry), DeadLineMetadata())
|
||||
return { payRequest: res.response.paymentRequest }
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue