diff --git a/dist/src/controllers/confirmations.js b/dist/src/controllers/confirmations.js index 3abae89..f218f3b 100644 --- a/dist/src/controllers/confirmations.js +++ b/dist/src/controllers/confirmations.js @@ -118,12 +118,13 @@ function receiveHeartbeat(payload) { console.log('=> received heartbeat'); const dat = payload.content || payload; const sender_pub_key = dat.sender.pub_key; - const amount = dat.message.amount; + const receivedAmount = dat.message.amount; if (!(sender_pub_key && sender_pub_key.length === 66)) return console.log('no sender'); - if (!amount) + if (!receivedAmount) return console.log('no amount'); const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } }); + const amount = Math.round(receivedAmount / 2); const MIN_SATS = 3; const amt = Math.max(amount || MIN_SATS); const opts = { diff --git a/dist/src/controllers/confirmations.js.map b/dist/src/controllers/confirmations.js.map index f733aba..58ae70c 100644 --- a/dist/src/controllers/confirmations.js.map +++ b/dist/src/controllers/confirmations.js.map @@ -1 +1 @@ -{"version":3,"file":"confirmations.js","sourceRoot":"","sources":["../../../src/controllers/confirmations.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,wCAAgC;AAChC,sCAAkC;AAClC,0CAAyC;AACzC,2CAA0C;AAC1C,sCAAqC;AACrC,6BAA4B;AAE5B,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,6BAA6B,CAAC,CAAC,CAAA;AAE9E,SAAgB,gBAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE;IACxD,IAAI,CAAC,MAAM;QAAE,OAAM;IACnB,OAAO,CAAC,WAAW,CAAC;QACnB,IAAI;QACJ,MAAM;QACN,OAAO,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE;QACvB,IAAI,EAAE,SAAS,CAAC,aAAa,CAAC,YAAY;KAC1C,CAAC,CAAA;AACH,CAAC;AARD,4CAQC;AAED,SAAsB,mBAAmB,CAAC,OAAO;;QAChD,OAAO,CAAC,GAAG,CAAC,0BAA0B,EAAE,CAAC,OAAO,CAAC,OAAO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AI,CAAC,CAAC,cAAc,IAAI,cAAc,CAAC,MAAM,KAAG,EAAE,CAAC;YAAE,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;QACpF,IAAI,CAAC,MAAM;YAAE,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;QAE5C,MAAM,KAAK,GAAG,MAAM,eAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,CAAA;QAExE,MAAM,QAAQ,GAAG,CAAC,CAAA;QAClB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,QAAQ,CAAC,CAAA;QACxC,MAAM,IAAI,GAAG;YACZ,GAAG;YACH,IAAI,EAAC,cAAc;YACnB,IAAI,EAAe;gBAClB,IAAI,EAAE,SAAS,CAAC,aAAa,CAAC,sBAAsB;gBACpD,OAAO,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE;gBACxB,MAAM,EAAE,EAAC,OAAO,EAAE,KAAK,CAAC,SAAS,EAAC;aAClC;SACD,CAAA;QACD,IAAI;YACH,MAAM,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;YAC/B,OAAO,IAAI,CAAA;SACX;QAAC,OAAO,CAAC,EAAE;YACX,OAAO,KAAK,CAAA;SACZ;IACF,CAAC;CAAA;AA7BD,4CA6BC"} \ No newline at end of file +{"version":3,"file":"confirmations.js","sourceRoot":"","sources":["../../../src/controllers/confirmations.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,wCAAgC;AAChC,sCAAkC;AAClC,0CAAyC;AACzC,2CAA0C;AAC1C,sCAAqC;AACrC,6BAA4B;AAE5B,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,6BAA6B,CAAC,CAAC,CAAA;AAE9E,SAAgB,gBAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,E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;YACX,OAAO,KAAK,CAAA;SACZ;IACF,CAAC;CAAA;AA9BD,4CA8BC"} \ No newline at end of file diff --git a/src/controllers/confirmations.ts b/src/controllers/confirmations.ts index 15a4d3e..f8d94ee 100644 --- a/src/controllers/confirmations.ts +++ b/src/controllers/confirmations.ts @@ -106,13 +106,14 @@ export async function receiveHeartbeat(payload) { const dat = payload.content || payload const sender_pub_key = dat.sender.pub_key - const amount = dat.message.amount + const receivedAmount = dat.message.amount if (!(sender_pub_key && sender_pub_key.length===66)) return console.log('no sender') - if (!amount) return console.log('no amount') + if (!receivedAmount) return console.log('no amount') const owner = await models.Contact.findOne({ where: { isOwner: true } }) + const amount = Math.round(receivedAmount/2) const MIN_SATS = 3 const amt = Math.max(amount || MIN_SATS) const opts = {