<commit_before>'use strict';


var imports = require('soop').imports();
var bitcore = require('bitcore');
var util = bitcore.util;
var Transaction = bitcore.Transaction;
var BuilderMockV0 = require('./BuilderMockV0');;
var TransactionBuilder = bitcore.TransactionBuilder;
var Script = bitcore.Script;
var buffertools = bitcore.buffertools;
var preconditions = require('preconditions').instance();

function TxProposal(opts) {
  this.creator = opts.creator;
  this.createdTs = opts.createdTs;
  this.seenBy = opts.seenBy || {};
  this.signedBy = opts.signedBy || {};
  this.rejectedBy = opts.rejectedBy || {};
  this.builder = opts.builder;
  this.sentTs = opts.sentTs || null;
  this.sentTxid = opts.sentTxid || null;
  this.inputChainPaths = opts.inputChainPaths || [];
  this.comment = opts.comment || null;
}

TxProposal.prototype.getID = function() {
  return this.builder.build().getNormalizedHash().toString('hex');
};

TxProposal.prototype.toObj = function() {
  var o = JSON.parse(JSON.stringify(this));
  delete o['builder'];
  o.builderObj = this.builder.toObj();
  return o;
};


TxProposal.prototype.setSent = function(sentTxid) {
  this.sentTxid = sentTxid;
  this.sentTs = Date.now();
};

TxProposal.fromObj = function(o, forceOpts) {
  var t = new TxProposal(o);

  // force opts is requested.
  for (var k in forceOpts) {
    o.builderObj.opts[k] = forceOpts[k];
  }

  try {
    t.builder = TransactionBuilder.fromObj(o.builderObj);

  } catch (e) {
    if (!o.version) {
      t.builder = new BuilderMockV0(o.builderObj);
      t.readonly = 1;
    };
  }

  return t;
};


TxProposal.prototype.isValid = function() {
  if (this.builder.signhash && this.builder.signhash !== Transaction.SIGHASH_ALL) {
    return false;<commit_msg>fix tests<commit_after>'use strict';


var imports = require('soop').imports();
var bitcore = require('bitcore');
var util = bitcore.util;
var Transaction = bitcore.Transaction;
var BuilderMockV0 = require('./BuilderMockV0');;
var TransactionBuilder = bitcore.TransactionBuilder;
var Script = bitcore.Script;
var buffertools = bitcore.buffertools;
var preconditions = require('preconditions').instance();

function TxProposal(opts) {
  this.creator = opts.creator;
  this.createdTs = opts.createdTs;
  this.seenBy = opts.seenBy || {};
  this.signedBy = opts.signedBy || {};
  this.rejectedBy = opts.rejectedBy || {};
  this.builder = opts.builder;
  this.sentTs = opts.sentTs || null;
  this.sentTxid = opts.sentTxid || null;
  this.inputChainPaths = opts.inputChainPaths || [];
  this.comment = opts.comment || null;
}

TxProposal.prototype.getID = function() {
  return this.builder.build().getNormalizedHash().toString('hex');
};

TxProposal.prototype.toObj = function() {
  var o = JSON.parse(JSON.stringify(this));
  delete o['builder'];
  o.builderObj = this.builder.toObj();
  return o;
};


TxProposal.prototype.setSent = function(sentTxid) {
  this.sentTxid = sentTxid;
  this.sentTs = Date.now();
};

TxProposal.fromObj = function(o, forceOpts) {
  var t = new TxProposal(o);

  try {
    // force opts is requested.
    for (var k in forceOpts) {
      o.builderObj.opts[k] = forceOpts[k];
    }
    t.builder = TransactionBuilder.fromObj(o.builderObj);

  } catch (e) {
    if (!o.version) {
      t.builder = new BuilderMockV0(o.builderObj);
      t.readonly = 1;
    };
  }

  return t;
};


TxProposal.prototype.isValid = function() {
  if (this.builder.signhash && this.builder.signhash !== Transaction.SIGHASH_ALL) {
    return false;
{'fraction_non_alphanumeric': 0.15090025721634753, 'fraction_numerical': 0.002286367533581023, 'mean_word_length': 3.992867332382311, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5423300', 'n_tokens_mistral': 1187, 'n_tokens_neox': 1170, 'n_words': 230}