Skip to content

Commit 7ecf838

Browse files
Weston SiegenthalerWeston Siegenthaler
Weston Siegenthaler
authored and
Weston Siegenthaler
committed
simplified ECKey method naming convention
1 parent e2126ee commit 7ecf838

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

src/bitcoin.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
$(function () {
158158
var key = new Bitcoin.ECKey(Crypto.util.hexToBytes("5c0b98e524ad188ddef35dc6abba13c34a351a05409e5d285403718b93336a4a"));
159159
key = new Bitcoin.ECKey(Crypto.util.hexToBytes("180cb41c7c600be951b5d3d0a7334acc7506173875834f7a6c4c786a28fcbb19"));
160-
//console.log(key.getBitcoinAddress().toString());
160+
//console.log(key.getAddress().toString());
161161
//var message = Crypto.util.hexToBytes("2aec28d323ee7b06a799d540d224b351161fe48967174ca5e43164e86137da11");
162162
//message = [0];
163163
//var out = key.sign(message);

src/ecdsa.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ Bitcoin.ECDSA = (function () {
462462
for (var i = 0; i < 4; i++) {
463463
try {
464464
var pubkey = Bitcoin.ECDSA.recoverPubKey(r, s, hash, i);
465-
if (pubkey.getBitcoinAddress().toString() == address) {
465+
if (pubkey.getAddress().toString() == address) {
466466
return i;
467467
}
468468
} catch (e) {}

src/eckey.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ Bitcoin.ECKey = (function () {
109109
}
110110
};
111111

112-
ECKey.prototype.getBitcoinAddress = function () {
112+
ECKey.prototype.getAddress = function () {
113113
var hash = this.getPubKeyHash();
114114
var addr = new Bitcoin.Address(hash);
115115
return addr;
@@ -132,8 +132,8 @@ Bitcoin.ECKey = (function () {
132132
/**
133133
* Private key encoded as standard Wallet Import Format (WIF)
134134
*/
135-
ECKey.prototype.getBitcoinWalletImportFormat = function () {
136-
var bytes = this.getBitcoinPrivateKeyByteArray();
135+
ECKey.prototype.getWalletImportFormat = function () {
136+
var bytes = this.getPrivateKeyByteArray();
137137
bytes.unshift(ECKey.privateKeyPrefix); // prepend 0x80 byte
138138
if (this.compressed) bytes.push(0x01); // append 0x01 byte for compressed format
139139
var checksum = Crypto.SHA256(Crypto.SHA256(bytes, { asBytes: true }), { asBytes: true });
@@ -145,21 +145,21 @@ Bitcoin.ECKey = (function () {
145145
/**
146146
* Private key encoded as hexadecimal string.
147147
*/
148-
ECKey.prototype.getBitcoinHexFormat = function () {
149-
return Crypto.util.bytesToHex(this.getBitcoinPrivateKeyByteArray()).toString().toUpperCase();
148+
ECKey.prototype.getHexFormat = function () {
149+
return Crypto.util.bytesToHex(this.getPrivateKeyByteArray()).toString().toUpperCase();
150150
};
151151

152152
/**
153153
* Private key encoded as Base64 string.
154154
*/
155-
ECKey.prototype.getBitcoinBase64Format = function () {
156-
return Crypto.util.bytesToBase64(this.getBitcoinPrivateKeyByteArray());
155+
ECKey.prototype.getBase64Format = function () {
156+
return Crypto.util.bytesToBase64(this.getPrivateKeyByteArray());
157157
};
158158

159159
/**
160160
* Private key encoded as raw byte array.
161161
*/
162-
ECKey.prototype.getBitcoinPrivateKeyByteArray = function () {
162+
ECKey.prototype.getPrivateKeyByteArray = function () {
163163
// Get a copy of private key as a byte array
164164
var bytes = this.priv.toByteArrayUnsigned();
165165
// zero pad if private key is less than 32 bytes
@@ -170,11 +170,11 @@ Bitcoin.ECKey = (function () {
170170
ECKey.prototype.toString = function (format) {
171171
format = format || "";
172172
if (format.toString().toLowerCase() == "base64" || format.toString().toLowerCase() == "b64") {
173-
return this.getBitcoinBase64Format(); // Base 64
173+
return this.getBase64Format(); // Base 64
174174
} else if (format.toString().toLowerCase() == "wif") {
175-
return this.getBitcoinWalletImportFormat(); // Wallet Import Format
175+
return this.getWalletImportFormat(); // Wallet Import Format
176176
} else {
177-
return this.getBitcoinHexFormat(); // Hex
177+
return this.getHexFormat(); // Hex
178178
}
179179
};
180180

src/message.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Bitcoin.Message = (function () {
3131

3232
var obj = Bitcoin.ECDSA.parseSig(sig);
3333

34-
var address = key.getBitcoinAddress().toString();
34+
var address = key.getAddress().toString();
3535
var i = Bitcoin.ECDSA.calcPubkeyRecoveryParam(address, obj.r, obj.s, hash);
3636

3737
i += 27;
@@ -60,7 +60,7 @@ Bitcoin.Message = (function () {
6060

6161
pubKey.setCompressed(isCompressed);
6262

63-
var expectedAddress = pubKey.getBitcoinAddress().toString();
63+
var expectedAddress = pubKey.getAddress().toString();
6464

6565
return (address === expectedAddress);
6666
};

src/wallet.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Bitcoin.Wallet = (function () {
4343
key.setPub(pub);
4444
}
4545

46-
this.addressHashes.push(key.getBitcoinAddress().getHashBase64());
46+
this.addressHashes.push(key.getAddress().getHashBase64());
4747
};
4848

4949
/**
@@ -120,14 +120,14 @@ Bitcoin.Wallet = (function () {
120120
this.getAllAddresses = function () {
121121
var addresses = [];
122122
for (var i = 0; i < keys.length; i++) {
123-
addresses.push(keys[i].getBitcoinAddress());
123+
addresses.push(keys[i].getAddress());
124124
}
125125
return addresses;
126126
};
127127

128128
this.getCurAddress = function () {
129129
if (keys[this.addressPointer]) {
130-
return keys[this.addressPointer].getBitcoinAddress();
130+
return keys[this.addressPointer].getAddress();
131131
} else {
132132
return null;
133133
}
@@ -144,7 +144,7 @@ Bitcoin.Wallet = (function () {
144144
if (!keys[this.addressPointer]) {
145145
this.generateAddress();
146146
}
147-
return keys[this.addressPointer].getBitcoinAddress();
147+
return keys[this.addressPointer].getAddress();
148148
};
149149

150150
/**

0 commit comments

Comments
 (0)