You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
826 B

10 years ago
'use strict';
10 years ago
var Bitcore = require('bitcore');
function Address() {
this.version = '1.0.0';
};
Address.create = function(opts) {
opts = opts || {};
10 years ago
var x = new Address();
x.createdOn = Math.floor(Date.now() / 1000);
x.address = opts.address;
x.path = opts.path;
x.publicKeys = opts.publicKeys;
return x;
10 years ago
};
Address.fromObj = function(obj) {
var x = new Address();
10 years ago
x.createdOn = obj.createdOn;
x.address = obj.address;
x.path = obj.path;
10 years ago
x.publicKeys = obj.publicKeys;
return x;
10 years ago
};
10 years ago
/**
* getScriptPubKey
*
* @param {number} threshold - amount of required signatures to spend the output
* @return {Script}
*/
Address.prototype.getScriptPubKey = function(threshold) {
10 years ago
return Bitcore.Script.buildMultisigOut(this.publicKeys, threshold).toScriptHashOut();
10 years ago
};
10 years ago
module.exports = Address;