Ejemplo n.º 1
0
def create_mnb(mne):
    collat_outpoint = Transaction.COutPoint(serialize.hs2b(mne['txid']), mne['nout'])

    mnp = Masternode.CMasternodePing(collat_outpoint)
    mn_privkey = energi.decode_address(mne['mn_privkey'])
    block_hash = Masternode.get_block_hash(13)
    mnp.sign(block_hash, mn_privkey)

    mnb = Masternode.CMasternodeBroadcast()
    mnb.outpoint = collat_outpoint
    mnb.addr = parse_ipport(mne['ip'])

    mn_private_key = secp256k1.PrivateKey(mn_privkey, raw = True)
    mn_public_key = mn_private_key.pubkey.serialize(compressed = False)

    co_ae = walletdb.get_addr_txid(mne['txid'], mne['nout'])
    if co_ae is None:
        raise RuntimeError('cannot find address for txid: %s' % mne['txid'])
    co_public_key = co_ae['pubkey']

    mnb.pubkey_collateral = energi.compress_public_key(co_public_key)
    mnb.pubkey_masternode = mn_public_key

    mnb.last_ping = mnp

    print('Signing on ledger:')
    mnb.hw_sign(energi.serialize_pathd(co_ae))

    print('MasternodeBroadcast:\n%s' % mnb)
    return mnb
Ejemplo n.º 2
0
 def deserialize(self, m):
     self.masternode_output = Transaction.COutPoint().deserialize(m)
     self.block_hash = serialize.deser_uint256(m)
     self.sig_time = serialize.deser_int64(m)
     self.vchSig = serialize.deser_string(m)
     self.fSentinelIsCurrent = serialize.deser_bool(m)
     self.nSentinelVersion = serialize.deser_uint32(m)
     self.nDaemonVersion = serialize.deser_uint32(m)
     return self
Ejemplo n.º 3
0
 def __init__(self, mn_outpoint=None):
     self.mn_outpoint = mn_outpoint if mn_outpoint is not None else Transaction.COutPoint(
     )
     self.block_hash = b'\x00' * 32
     self.sig_time = -1
     self.vchSig = b''
     self.fSentinelIsCurrent = True
     self.nSentinelVersion = 0x010101
     self.nDaemonVersion = 2020100
Ejemplo n.º 4
0
 def deserialize(self, m):
     self.outpoint = Transaction.COutPoint().deserialize(m)
     self.addr = CService().deserialize(m)
     self.pubkey_collateral = serialize.deser_string(m)
     self.pubkey_masternode = serialize.deser_string(m)
     self.vchSig = serialize.deser_string(m)
     self.sig_time = serialize.deser_int64(m)
     self.n_protocol_version = serialize.deser_int32(m)
     self.last_ping = CMasternodePing().deserialize(m)
     return self
Ejemplo n.º 5
0
 def __init__(self):
     self.n_active_state = 0  # int nActiveState;
     self.n_protocol_version = _PROTOCOL_VERSION  # int nProtocolVersion;
     self.sig_time = 0  # int64_t sigTime; // mnb message time
     self.outpoint = Transaction.COutPoint()  # COutPoint outpoint;
     self.addr = CService()  # CService addr;
     self.pubkey_collateral = b''  # CPubKey pubKeyCollateralAddress; (basically just a serialized pubkey)
     self.pubkey_masternode = b''  # CPubKey pubKeyMasternode;
     self.n_last_dsq = 0  # dsq count from last dsq broadcast     # int64_t nLastDsq;
     self.n_time_last_checked = 0  # int64_t nTimeLastChecked;
     self.n_time_last_paid = 0  # int64_t nTimeLastPaid;
     self.f_info_valid = False  # bool fInfoValid;
Ejemplo n.º 6
0
 def deserialize(self, m):
     self.outpoint = Transaction.COutPoint().deserialize(m)
     self.addr = CService().deserialize(m)
     self.pubkey_collateral = serialize.deser_string(m)
     self.pubkey_masternode = serialize.deser_string(m)
     self.last_ping = CMasternodePing().deserialize(m)
     self.vchSig = serialize.deser_string(m)
     self.sig_time = serialize.deser_int64(m)
     self.n_last_dsq = serialize.deser_int64(m)
     self.n_time_last_checked = serialize.deser_int64(m)
     self.n_last_dsq = serialize.deser_int64(m)
     self.n_active_state = serialize.deser_int32(m)
     self.n_collateral_hash = serialize.deser_uint256(m)
     self.n_block_last_paid = serialize.deser_int32(m)
     self.n_protocol_version = serialize.deser_int32(m)
     self.n_po_se_ban_score = serialize.deser_int32(m)
     self.n_po_se_ban_height = serialize.deser_int32(m)
     self.f_allow_mixing_tx = serialize.deser_bool(m)
     self.f_unit_test = serialize.deser_bool(m)
     self.gov_votes = serialize.deser_map_uint256_int(m)
     return self