forked from byteball/ocore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwallet_general.js
43 lines (35 loc) · 1.5 KB
/
wallet_general.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*jslint node: true */
"use strict";
var db = require('./db.js');
var device = require('./device.js');
function sendOfferToSign(device_address, address, signing_path, objUnsignedUnit, assocPrivatePayloads){
var body = {address: address, signing_path: signing_path, unsigned_unit: objUnsignedUnit};
if (assocPrivatePayloads && Object.keys(assocPrivatePayloads).length > 0)
body.private_payloads = assocPrivatePayloads;
device.sendMessageToDevice(device_address, "sign", body);
}
// unlike similar function in network, this function sends multiple chains in a single package
function sendPrivatePayments(device_address, arrChains, bForwarded, conn, onSaved){
var body = {chains: arrChains};
if (bForwarded)
body.forwarded = true;
device.sendMessageToDevice(device_address, "private_payments", body, {
ifOk: function(){},
ifError: function(){},
onSaved: onSaved
}, conn);
}
// notification about public payment
function sendPaymentNotification(device_address, unit){
device.sendMessageToDevice(device_address, "payment_notification", unit);
}
function readMyAddresses(handleAddresses){
db.query("SELECT address FROM my_addresses UNION SELECT shared_address AS address FROM shared_addresses", function(rows){
var arrAddresses = rows.map(function(row){ return row.address; });
handleAddresses(arrAddresses);
});
}
exports.sendOfferToSign = sendOfferToSign;
exports.sendPrivatePayments = sendPrivatePayments;
exports.sendPaymentNotification = sendPaymentNotification;
exports.readMyAddresses = readMyAddresses;