Skip to content
Snippets Groups Projects
Commit faab2283 authored by Adrien M's avatar Adrien M
Browse files

add transfer operation

parent 842b9140
No related branches found
No related tags found
No related merge requests found
...@@ -118,5 +118,22 @@ module.exports = { ...@@ -118,5 +118,22 @@ module.exports = {
this.comment(username, password, body.substr(0, 30), body, null, parent_author, parent_permlink, function(e,r) { this.comment(username, password, body.substr(0, 30), body, null, parent_author, parent_permlink, function(e,r) {
cb(e,r); cb(e,r);
}) })
},
transfer: function(username, password, to, amount, asset, memo, cb) {
if (amount.toFixed(3) <= 0) cb('Cannot transfer a negative amount (aka: stealing)');
if (asset != 'SBD' && asset != 'STEEM') cb('Wrong asset. Must be STEEM or SBD');
var tx = {
extensions: [],
operations: [['transfer', {
from: username,
to: to,
amount: formatter.amount(amount, asset),
memo: memo
}]]
};
var privKeys = steemAuth.getPrivateKeys(username, password, ['active']);
this.send(username, password, tx, privKeys, function(err, result) {
cb(err, result);
})
} }
}; };
...@@ -35,5 +35,9 @@ module.exports = { ...@@ -35,5 +35,9 @@ module.exports = {
return permlink; return permlink;
} }
else return this.sanitizePermlink(title) else return this.sanitizePermlink(title)
},
amount: function(amount, asset) {
// maybe improve this
return amount.toFixed(3) + ' ' + asset;
} }
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment