Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,17 @@ export { AbstractPayload };
export { CoinbasePayload } from './typings/transaction/payload/CoinbasePayload';
export { CommitmentTxPayload } from './typings/transaction/payload/CommitmentTxPayload';
export { MnHfSignalPayload } from './typings/transaction/payload/MnHfSignalPayload';
export { ProRegTxPayload } from './typings/transaction/payload/ProRegTxPayload';
export {
ProRegTxPayload,
ProRegTxPayloadJSON,
CollateralShare,
CollateralShareJSON,
} from './typings/transaction/payload/ProRegTxPayload';
export {
MasternodeAddresses,
MasternodePayout,
MasternodePayoutJSON,
} from './typings/transaction/payload/MasternodePayout';
export { ProUpRegTxPayload } from './typings/transaction/payload/ProUpRegTxPayload';
export { ProUpRevTxPayload } from './typings/transaction/payload/ProUpRevTxPayload';
export { ProUpServTxPayload } from './typings/transaction/payload/ProUpServTxPayload';
Expand Down
5 changes: 3 additions & 2 deletions lib/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ const constants = {
CURRENT_PROTOCOL_VERSION: 70211,
SML_ENTRY_VERSION_1_SIZE: 151,
SML_ENTRY_TYPE_2_ADDITION_SIZE: 22,
// ProTxVersion::ExtAddr: addresses are serialized as ExtNetInfo
SML_ENTRY_EXT_ADDR_VERSION: 3,
// ProTxVersion::ExtAddr: ProTx payloads and SML entries serialize addresses
// as ExtNetInfo, and ProTx payloads have payout lists
PROTX_EXT_ADDR_VERSION: 3,
Comment thread
PastaPastaPasta marked this conversation as resolved.
Resolved
NULL_HASH: '0000000000000000000000000000000000000000000000000000000000000000',
// In duffs
INSTANTSEND_FEE_PER_INPUT: 10000,
Expand Down
13 changes: 4 additions & 9 deletions lib/deterministicmnlist/SimplifiedMNListEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const {
PUBKEY_ID_SIZE,
PLATFORM_NODE_ID_SIZE,
MASTERNODE_TYPE_HP,
SML_ENTRY_EXT_ADDR_VERSION,
PROTX_EXT_ADDR_VERSION,
} = constants;

/**
Expand Down Expand Up @@ -144,7 +144,7 @@ SimplifiedMNListEntry.fromHexString = function fromHexString(string, network) {
*/
SimplifiedMNListEntry.prototype.toBuffer = function toBuffer() {
this.validate();
const hasExtAddr = this.nVersion >= SML_ENTRY_EXT_ADDR_VERSION;
const hasExtAddr = this.nVersion >= PROTX_EXT_ADDR_VERSION;
const bufferWriter = new BufferWriter();

bufferWriter.write(Buffer.from(this.proRegTxHash, 'hex').reverse());
Expand Down Expand Up @@ -203,7 +203,7 @@ SimplifiedMNListEntry.fromObject = function fromObject(obj) {
// and derives both from `addresses`. ExtAddr entries hash `addresses` instead of
// these fields, so for them always take both from `addresses`.
if (SMLEntry.addresses) {
const hasExtAddr = SMLEntry.nVersion >= SML_ENTRY_EXT_ADDR_VERSION;
const hasExtAddr = SMLEntry.nVersion >= PROTX_EXT_ADDR_VERSION;
const [coreP2P] = SMLEntry.addresses.core_p2p || [];
const [platformHTTPS] = SMLEntry.addresses.platform_https || [];
if (hasExtAddr || SMLEntry.service === undefined) {
Expand All @@ -227,7 +227,7 @@ SimplifiedMNListEntry.fromObject = function fromObject(obj) {
};

SimplifiedMNListEntry.prototype.validate = function validate() {
const hasExtAddr = this.nVersion >= SML_ENTRY_EXT_ADDR_VERSION;
const hasExtAddr = this.nVersion >= PROTX_EXT_ADDR_VERSION;
$.checkArgument(
isSha256(this.proRegTxHash),
'Expected proRegTxHash to be a sha256 hex string'
Expand All @@ -237,11 +237,6 @@ SimplifiedMNListEntry.prototype.validate = function validate() {
'Expected confirmedHash to be a sha256 hex string'
);
if (hasExtAddr) {
$.checkArgument(
_.isPlainObject(this.addresses),
'Expected addresses to be an object'
);
// throws if the addresses can't be serialized
extNetInfoToBuffer(this.addresses);
} else if (!ipUtils.isZeroAddress(this.service)) {
$.checkArgument(
Expand Down
Loading
Loading