bitcore-lib-doge
Version:
A pure and powerful JavaScript Dogecoin library.
74 lines (63 loc) • 2.23 kB
JavaScript
;
var should = require('chai').should();
var bitcore = require('../../..');
const Address = require('../../../../bitcore-lib-ltc/lib/address');
var Transaction = bitcore.Transaction;
var PrivateKey = bitcore.PrivateKey;
var Script = bitcore.Script;
describe('PublicKeyInput', function() {
var utxo = {
txid: '7f3b688cb224ed83e12d9454145c26ac913687086a0a62f2ae0bc10934a4030f',
vout: 0,
address: 'DHnorEyi4DLN44eksMTFZHRJuAyJJ5S1yU',
scriptPubKey: '76a9148ac36246b6395d7a569524b53e17987730fbefdb88ac',
amount: 50,
confirmations: 104,
spendable: true
};
var privateKey = PrivateKey.fromWIF('QUsNNw934sS8DjjTNKAkpZbN2RUFW1YaNz6PHYgkFMaj8uWhCuLc');
var address = privateKey.toAddress();
utxo.address.should.equal(address.toString());
var destKey = new PrivateKey();
it('will correctly sign a publickey out transaction', function() {
var tx = new Transaction();
tx.from(utxo);
tx.to(destKey.toAddress(), 10000);
tx.sign(privateKey);
tx.inputs[0].script.toBuffer().length.should.be.above(0);
});
it('count can count missing signatures', function() {
var tx = new Transaction();
tx.from(utxo);
tx.to(destKey.toAddress(), 10000);
var input = tx.inputs[0];
input.isFullySigned().should.equal(false);
tx.sign(privateKey);
input.isFullySigned().should.equal(true);
});
it('it\'s size can be estimated', function() {
var tx = new Transaction();
tx.from(utxo);
tx.to(destKey.toAddress(), 10000);
var input = tx.inputs[0];
input._estimateSize().should.equal(148);
});
it('it\'s signature can be removed', function() {
var tx = new Transaction();
tx.from(utxo);
tx.to(destKey.toAddress(), 10000);
var input = tx.inputs[0];
tx.sign(privateKey);
input.isFullySigned().should.equal(true);
input.clearSignatures();
input.isFullySigned().should.equal(false);
});
it('returns an empty array if private key mismatches', function() {
var tx = new Transaction();
tx.from(utxo);
tx.to(destKey.toAddress(), 10000);
var input = tx.inputs[0];
var signatures = input.getSignatures(tx, new PrivateKey(), 0);
signatures.length.should.equal(0);
});
});