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.
35 lines
742 B
35 lines
742 B
'use strict';
|
|
|
|
var Bitcore = require('bitcore');
|
|
|
|
function Address(opts) {
|
|
opts = opts || {};
|
|
|
|
this.createdOn = Math.floor(Date.now() / 1000);
|
|
this.address = opts.address;
|
|
this.path = opts.path;
|
|
this.publicKeys = opts.publicKeys;
|
|
};
|
|
|
|
Address.fromObj = function (obj) {
|
|
var x = new Address();
|
|
|
|
x.createdOn = obj.createdOn;
|
|
x.address = obj.address;
|
|
x.path = obj.path;
|
|
x.publicKeys = obj.publicKeys;
|
|
return x;
|
|
};
|
|
|
|
|
|
/**
|
|
* getScriptPubKey
|
|
*
|
|
* @param {number} threshold - amount of required signatures to spend the output
|
|
* @return {Script}
|
|
*/
|
|
Address.prototype.getScriptPubKey = function (threshold) {
|
|
return Bitcore.Script.buildMultisigOut(this.publicKeys, threshold).toScriptHashOut();
|
|
};
|
|
|
|
module.exports = Address;
|
|
|