Browse Source

fix NESTED_PUBKEY_HASH

utxos
Evan Feenstra 4 years ago
parent
commit
f1e6a2d71e
  1. 2
      dist/src/controllers/queries.js
  2. 2
      dist/src/controllers/queries.js.map
  3. 6
      dist/src/utils/lightning.js
  4. 2
      dist/src/utils/lightning.js.map
  5. 2
      src/controllers/queries.ts
  6. 8
      src/utils/lightning.ts

2
dist/src/controllers/queries.js

@ -84,7 +84,7 @@ exports.receiveQuery = (payload) => __awaiter(void 0, void 0, void 0, function*
let result = '';
switch (q.type) {
case 'onchain_address':
const addy = yield lightning.newAddress('np2wkh');
const addy = yield lightning.newAddress(lightning.NESTED_PUBKEY_HASH);
const acc = {
date: new Date(),
pubkey: sender_pub_key,

2
dist/src/controllers/queries.js.map

@ -1 +1 @@
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/controllers/queries.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,sCAA+C;AAC/C,sCAAkC;AAClC,sCAAqC;AACrC,4CAAoC;AACpC,oCAAmC;AACnC,gDAA+C;AAU/C,IAAI,OAAO,GAA2B,EAAE,CAAA;AAExC,0FAA0F;AAC1F,MAAM,UAAU,GAAG,oEAAoE,CAAA;AAEvF,SAAsB,kBAAkB,CAAC,GAAG,EAAE,GAAG;;QAC/C,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAA;QAC9B,MAAM,KAAK,GAAG,MAAM,eAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,CAAA;QACxE,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC;QAE1B,MAAM,KAAK,GAAS;YAClB,IAAI,EAAC,iBAAiB;YACtB,IAAI;YACJ,GAAG;SACJ,CAAA;QAEF,MAAM,IAAI,GAAG;YACZ,GAAG,EAAE,mBAAS,CAAC,cAAc;YAC7B,IAAI,EAAE,UAAU;YAChB,IAAI,EAAe;gBAClB,IAA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/lightning.js

@ -144,7 +144,11 @@ const queryRoute = (pub_key, amt) => __awaiter(void 0, void 0, void 0, function*
});
});
exports.queryRoute = queryRoute;
function newAddress(type = 'np2wkh') {
exports.WITNESS_PUBKEY_HASH = 0;
exports.NESTED_PUBKEY_HASH = 1;
exports.UNUSED_WITNESS_PUBKEY_HASH = 2;
exports.UNUSED_NESTED_PUBKEY_HASH = 3;
function newAddress(type = exports.NESTED_PUBKEY_HASH) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise(function (resolve, reject) {
return __awaiter(this, void 0, void 0, function* () {

2
dist/src/utils/lightning.js.map

File diff suppressed because one or more lines are too long

2
src/controllers/queries.ts

@ -84,7 +84,7 @@ export const receiveQuery = async (payload) => {
let result = ''
switch (q.type) {
case 'onchain_address':
const addy = await lightning.newAddress('np2wkh')
const addy = await lightning.newAddress(lightning.NESTED_PUBKEY_HASH)
const acc = {
date: new Date(),
pubkey: sender_pub_key,

8
src/utils/lightning.ts

@ -136,8 +136,12 @@ const queryRoute = async (pub_key, amt) => {
})
}
export type NewAddressType = 'np2wkh'
export async function newAddress(type:NewAddressType='np2wkh'): Promise<string> {
export const WITNESS_PUBKEY_HASH = 0;
export const NESTED_PUBKEY_HASH = 1;
export const UNUSED_WITNESS_PUBKEY_HASH = 2;
export const UNUSED_NESTED_PUBKEY_HASH = 3;
export type NewAddressType = 0|1|2|3
export async function newAddress(type:NewAddressType=NESTED_PUBKEY_HASH): Promise<string> {
return new Promise(async function (resolve, reject) {
let lightning = await loadLightning()
lightning.newAddress(

Loading…
Cancel
Save