mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-29 08:35:49 +00:00
UT: Add helper for setting transfer rate.
This commit is contained in:
committed by
Stefan Thomas
parent
f5988fd66e
commit
9e36297c0e
@@ -1046,6 +1046,9 @@ Transaction.prototype.send_max = function (send_max) {
|
||||
Transaction.prototype.transfer_rate = function (rate) {
|
||||
this.transaction.TransferRate = Number(rate);
|
||||
|
||||
if (this.transaction.TransferRate < 1e9)
|
||||
throw 'invalidTransferRate';
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -147,6 +147,25 @@ var payment = function (remote, src, dst, amount, callback) {
|
||||
.submit();
|
||||
};
|
||||
|
||||
var transfer_rate = function (remote, src, billionths, callback) {
|
||||
assert(4 === arguments.length);
|
||||
|
||||
remote.transaction()
|
||||
.account_set(src)
|
||||
.transfer_rate(billionths)
|
||||
.on('proposed', function (m) {
|
||||
// console.log("proposed: %s", JSON.stringify(m));
|
||||
|
||||
callback(m.result != 'tesSUCCESS');
|
||||
})
|
||||
.on('error', function (m) {
|
||||
// console.log("error: %s", JSON.stringify(m));
|
||||
|
||||
callback(m);
|
||||
})
|
||||
.submit();
|
||||
};
|
||||
|
||||
var verify_balance = function (remote, src, amount_json, callback) {
|
||||
assert(4 === arguments.length);
|
||||
var amount = Amount.from_json(amount_json);
|
||||
@@ -195,6 +214,7 @@ exports.create_accounts = create_accounts;
|
||||
exports.credit_limit = credit_limit;
|
||||
exports.payment = payment;
|
||||
exports.build_teardown = build_teardown;
|
||||
exports.transfer_rate = transfer_rate;
|
||||
exports.verify_balance = verify_balance;
|
||||
exports.verify_balances = verify_balances;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user