コード例 #1
0
bool CBasicKeyStore::AddWatchOnly(const CTxDestination &dest)
{
    LOCK(cs_KeyStore);
    CKeyID keyID;
    CBitcoinAddress(dest).GetKeyID(keyID);

    if (HaveKey(keyID))
        return false;

    setWatchOnly.insert(dest);
    return true;
}
コード例 #2
0
bool CBasicKeyStore::AddWatchOnly(const CScript &dest)
{
    LOCK(cs_KeyStore);

    CTxDestination address;
    if (ExtractDestination(dest, address)) {
        CKeyID keyID;
        CBitcoinAddress(address).GetKeyID(keyID);
        if (HaveKey(keyID))
            return false;
    }

    setWatchOnly.insert(dest);
    return true;
}
コード例 #3
0
ファイル: keystore.cpp プロジェクト: Chovanec/bitcoin
void CBasicKeyStore::ImplicitlyLearnRelatedKeyScripts(const CPubKey& pubkey)
{
    AssertLockHeld(cs_KeyStore);
    CKeyID key_id = pubkey.GetID();
    // We must actually know about this key already.
    assert(HaveKey(key_id) || mapWatchKeys.count(key_id));
    // This adds the redeemscripts necessary to detect P2WPKH and P2SH-P2WPKH
    // outputs. Technically P2WPKH outputs don't have a redeemscript to be
    // spent. However, our current IsMine logic requires the corresponding
    // P2SH-P2WPKH redeemscript to be present in the wallet in order to accept
    // payment even to P2WPKH outputs.
    // Also note that having superfluous scripts in the keystore never hurts.
    // They're only used to guide recursion in signing and IsMine logic - if
    // a script is present but we can't do anything with it, it has no effect.
    // "Implicitly" refers to fact that scripts are derived automatically from
    // existing keys, and are present in memory, even without being explicitly
    // loaded (e.g. from a file).
    if (pubkey.IsCompressed()) {
        CScript script = GetScriptForDestination(WitnessV0KeyHash(key_id));
        // This does not use AddCScript, as it may be overridden.
        CScriptID id(script);
        mapScripts[id] = std::move(script);
    }
}
コード例 #4
0
ファイル: input.cpp プロジェクト: paud/d2x-xl
void ControlsDoKeyboard (int *bSlideOn, int *bBankOn, fix *pitchTimeP, fix *headingTimeP, int *nCruiseSpeed, int bGetSlideBank)
{
	int	i, v, pitchScale = (!(gameStates.app.bNostalgia || COMPETITION) && 
									 (FASTPITCH == 1)) ? 2 * PH_SCALE : 1;
	int	speedFactor = gameStates.app.cheats.bTurboMode ? 2 : 1;
	static int key_signs [8] = {1,1,-1,-1,-1,-1,1,1};

if (bGetSlideBank == 0) {
	for (i = 0; i < 2; i++) {
		if ((v = HaveKey (kcKeyboard, 8 + i)) < 255) {
			if (gameStates.input.keys.pressed [v])
				*bSlideOn |= gameStates.input.keys.pressed [v];
			}
		if ((v = HaveKey (kcKeyboard, 18 + i)) < 255) 
			if (gameStates.input.keys.pressed [v])
				*bBankOn |= gameStates.input.keys.pressed [v];
		}
	return;
	}

if (bGetSlideBank == 2) {
	for (i = 0; i < 2; i++) {
		if ((v = HaveKey (kcKeyboard, 24 + i)) < 255) {
			Controls [0].firePrimaryState |= gameStates.input.keys.pressed [v];
			Controls [0].firePrimaryDownCount += KeyDownCount (v);
			}
		if ((v = HaveKey (kcKeyboard, 26 + i)) < 255) {
			Controls [0].fireSecondaryState |= gameStates.input.keys.pressed [v];
			Controls [0].fireSecondaryDownCount += KeyDownCount (v);
			}
		if ((v = HaveKey (kcKeyboard, 28 + i)) < 255) 
			Controls [0].fireFlareDownCount += KeyDownCount (v);
		}

	for (i = 0; i < 2; i++) {
		Controls [0].sidewaysThrustTime -= DELTACTRL (10 + i, 2);
		Controls [0].sidewaysThrustTime += DELTACTRL (12 + i, 2);
		Controls [0].verticalThrustTime += DELTACTRL (14 + i, 2);
		Controls [0].verticalThrustTime -= DELTACTRL (16 + i, 2);
		Controls [1].bankTime += DELTACTRL (20 + i, 1);
		Controls [1].bankTime -= DELTACTRL (22 + i, 1);
		Controls [0].forwardThrustTime += DELTACTRL (30 + i, 0);
		Controls [0].forwardThrustTime -= DELTACTRL (32 + i, 0);
		if ((v = HaveKey (kcKeyboard, 46 + i)) < 255) 
			Controls [0].afterburnerState |= gameStates.input.keys.pressed [v];
		// count bomb drops
		if ((v = HaveKey (kcKeyboard, 34 + i)) < 255) 
			Controls [0].dropBombDownCount += KeyDownCount (v);
		// charge chield
		if (LOCALPLAYER.flags & PLAYER_FLAGS_CONVERTER) {
			if (gameStates.input.keys.pressed [v = HaveKey (kcKeyboard, 56 + i)])
				TransferEnergyToShield (KeyDownTime (v));
			}
		// rear view
		if ((v = HaveKey (kcKeyboard, 36 + i)) < 255) {
			Controls [0].rearViewDownCount += KeyDownCount (v);
			Controls [0].rearViewDownState |= gameStates.input.keys.pressed [v];
			}
		// automap
		if ((v = HaveKey (kcKeyboard, 44 + i)) < 255) {
			Controls [0].automapDownCount += KeyDownCount (v);
			Controls [0].automapState |= gameStates.input.keys.pressed [v];
			}
	}
	// headlight and weapon cycling
	if ((v = HaveKey (kcKeyboard, 54)) < 255)
		Controls [0].headlightCount = KeyDownCount (v);
	Controls [0].headlightCount += HaveKeyCount (kcKeyboard, 55);
	Controls [0].cyclePrimaryCount = HaveKeyCount (kcKeyboard, 48);
	Controls [0].cyclePrimaryCount += HaveKeyCount (kcKeyboard, 49);
	Controls [0].cycleSecondaryCount += HaveKeyCount (kcKeyboard, 50);
	Controls [0].cycleSecondaryCount += HaveKeyCount (kcKeyboard, 51);
	Controls [0].zoomDownCount += HaveKeyCount (kcKeyboard, 52);
	Controls [0].zoomDownCount += HaveKeyCount (kcKeyboard, 53);
	Controls [0].toggleIconsCount += HaveKeyCount (kcKeyboard, 59);
	Controls [0].useCloakDownCount += HaveKeyCount (kcKeyboard, 60);
	Controls [0].useCloakDownCount += HaveKeyCount (kcKeyboard, 61);
	Controls [0].useInvulDownCount += HaveKeyCount (kcKeyboard, 62);
	Controls [0].useInvulDownCount += HaveKeyCount (kcKeyboard, 63);
	Controls [0].slowMotionCount += HaveKeyCount (kcKeyboard, 64);
	Controls [0].bulletTimeCount += HaveKeyCount (kcKeyboard, 65);

	// toggle bomb
	if (((v = HaveKey (kcKeyboard, 58)) < 255) && KeyDownCount (v))
		ToggleBomb ();

	// cruise speed
	for (i = 0; i < 4; i++)
		if ((v = HaveKey (kcKeyboard, 38 + i)) < 255) 
			*nCruiseSpeed += key_signs [i] * FixDiv (speedFactor * KeyDownTime (v) * 5, gameStates.input.kcPollTime);
	for (i = 0; i < 2; i++)
		if (((v = HaveKey (kcKeyboard, 
 + i)) < 255) && KeyDownCount (v))
			*nCruiseSpeed = 0;
	}

// special slide & bank toggle handling
if (*bSlideOn) {
	if (bGetSlideBank == 2) {
		for (i = 0; i < 2; i++) {
			Controls [0].verticalThrustTime += DELTACTRL (i, 2);
			Controls [0].verticalThrustTime -= DELTACTRL (2 + i, 2);
			Controls [0].sidewaysThrustTime -= DELTACTRL (4 + i, 2);
			Controls [0].sidewaysThrustTime += DELTACTRL (6 + i, 2);
			}
		}
	}
else if (bGetSlideBank == 1) {
	for (i = 0; i < 4; i++)
		Controls [1].pitchTime += key_signs [i] * DELTACTRL (i, 1) / pitchScale;
	if (!*bBankOn)
		for (i = 4; i < 8; i++)
			Controls [1].headingTime += key_signs [i] * DELTACTRL (i, 1) / PH_SCALE;
	}
if (*bBankOn) {
	if (bGetSlideBank == 2) {
		for (i = 4; i < 6; i++)
			Controls [1].bankTime += DELTACTRL (i, 1);
		for (i = 6; i < 8; i++)
			Controls [1].bankTime -= DELTACTRL (i, 1);
		}
	}
if (bGetSlideBank == 2)
	ControlsLimitTurnRate (0);
//KCCLAMP (pitchTime, nMaxTurnRate / FASTPITCH);
*pitchTimeP = Controls [1].pitchTime;
*headingTimeP = Controls [1].headingTime;
}