commit
0e04026d87
|
@ -1,3 +1,34 @@
|
|||
// Address
|
||||
// =======
|
||||
//
|
||||
// Handles a bitcoin address
|
||||
//
|
||||
//
|
||||
// Synopsis
|
||||
// --------
|
||||
// ```
|
||||
// var address = new Address('1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa');
|
||||
// if (address.isValid()) {
|
||||
// //...
|
||||
// }
|
||||
//
|
||||
// // Also an address can be created from
|
||||
// // public keys
|
||||
// var address = Address.fromPubKey(myPubkey);
|
||||
//
|
||||
// // Or from a ScriptPubKey (from a transaction output)
|
||||
// var address = Address.fromScriptPubKey(scriptPubKey);
|
||||
//
|
||||
// // Multisig address p2sh handling
|
||||
// var myPukeys = [pubkey0, pubkey1, pubkey2];
|
||||
// var p2shAddress = Address.fromPubKeys(2, myPubkeys);
|
||||
// if (p2shAddress.isScript()) { //true
|
||||
// }
|
||||
//
|
||||
//
|
||||
// ```
|
||||
|
||||
|
||||
'use strict';
|
||||
var imports = require('soop').imports();
|
||||
var coinUtil = imports.coinUtil || require('../util');
|
||||
|
@ -43,7 +74,6 @@ Address.fromPubKeys = function(mReq, pubKeys, network, opts) {
|
|||
}
|
||||
|
||||
var script = Script.createMultisig(mReq, pubKeys, opts);
|
||||
|
||||
return Address.fromScript(script, network);
|
||||
};
|
||||
|
||||
|
@ -101,7 +131,7 @@ Address.fromScriptPubKey = function(scriptPubKey, network) {
|
|||
return ret;
|
||||
};
|
||||
|
||||
|
||||
// validates the address
|
||||
Address.prototype.validate = function() {
|
||||
this.doAsBinary(function() {
|
||||
Address.super(this, 'validate', arguments);
|
||||
|
@ -115,6 +145,7 @@ Address.prototype.isValid = function() {
|
|||
return answer;
|
||||
};
|
||||
|
||||
// returns the network information (livenet or testnet, as described on networks.js) of the address
|
||||
Address.prototype.network = function() {
|
||||
var version = this.version();
|
||||
|
||||
|
@ -130,6 +161,7 @@ Address.prototype.network = function() {
|
|||
return answer;
|
||||
};
|
||||
|
||||
// returns true is the address is a pay-to-script (P2SH) address type.
|
||||
Address.prototype.isScript = function() {
|
||||
return this.isValid() && this.version() === this.network().P2SHVersion;
|
||||
};
|
||||
|
|
|
@ -926,6 +926,7 @@ TransactionBuilder.prototype._checkMergeability = function(b) {
|
|||
|
||||
};
|
||||
|
||||
// TODO this could be on Script class
|
||||
TransactionBuilder.prototype._mergeInputSigP2sh = function(input,s0,s1) {
|
||||
var p2sh = this._p2shInput(input);
|
||||
var redeemScript = new Script(p2sh.scriptBuf);
|
||||
|
@ -963,6 +964,7 @@ TransactionBuilder.prototype._mergeInputSigP2sh = function(input,s0,s1) {
|
|||
return s0.getBuffer();
|
||||
};
|
||||
|
||||
// TODO this could be on Script class
|
||||
TransactionBuilder.prototype._mergeInputSig = function(index, s0buf, s1buf) {
|
||||
if (buffertools.compare(s0buf,s1buf) === 0)
|
||||
return s0buf;
|
||||
|
@ -996,7 +998,8 @@ TransactionBuilder.prototype._mergeInputSig = function(index, s0buf, s1buf) {
|
|||
return this._mergeInputSigP2sh(input,s0, s1);
|
||||
};
|
||||
|
||||
TransactionBuilder.prototype._mergeTx = function(tx, ignoreConflictingSignatures) {
|
||||
// TODO this could be on Transaction class
|
||||
TransactionBuilder.prototype._mergeTx = function(tx) {
|
||||
var v0 = this.tx;
|
||||
var v1 = tx;
|
||||
|
||||
|
|
Loading…
Reference in New Issue