示例#1
0
文件: tx.c 项目: sstone/lightning
void sha256_tx_for_sig(struct sha256_double *h, const struct bitcoin_tx *tx,
		       unsigned int input_num,
		       const u8 *witness_script)
{
	size_t i;
	struct sha256_ctx ctx = SHA256_INIT;

	/* Caller should zero-out other scripts for signing! */
	assert(input_num < tal_count(tx->input));
	for (i = 0; i < tal_count(tx->input); i++)
		if (i != input_num)
			assert(!tx->input[i].script);

	if (witness_script) {
		/* BIP143 hashing if OP_CHECKSIG is inside witness. */
		hash_for_segwit(&ctx, tx, input_num, witness_script);
	} else {
		/* Otherwise signature hashing never includes witness. */
		push_tx(tx, push_sha, &ctx, false);
	}

	sha256_le32(&ctx, SIGHASH_ALL);
	sha256_double_done(&ctx, h);
}
示例#2
0
文件: midikbd.c 项目: Ilgrim/MAMEHub
void midi_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
	const int keyboard_notes[24] =
	{
		0x3c,   // C1
		0x3d,   // C1#
		0x3e,   // D1
		0x3f,   // D1#
		0x40,   // E1
		0x41,   // F1
		0x42,   // F1#
		0x43,   // G1
		0x44,   // G1#
		0x45,   // A1
		0x46,   // A1#
		0x47,   // B1
		0x48,   // C2
		0x49,   // C2#
		0x4a,   // D2
		0x4b,   // D2#
		0x4c,   // E2
		0x4d,   // F2
		0x4e,   // F2#
		0x4f,   // G2
		0x50,   // G2#
		0x51,   // A2
		0x52,   // A2#
		0x53,   // B2
	};

	int i;

	UINT32 kbstate = m_keyboard->read();
	if(kbstate != m_keyboard_state)
	{
		for (i=0; i < 24; i++)
		{
			int kbnote = keyboard_notes[i];

			if ((m_keyboard_state & (1 << i)) != 0 && (kbstate & (1 << i)) == 0)
			{
				// key was on, now off -> send Note Off message
				push_tx(0x80);
				push_tx(kbnote);
				push_tx(0x7f);
			}
			else if ((m_keyboard_state & (1 << i)) == 0 && (kbstate & (1 << i)) != 0)
			{
				// key was off, now on -> send Note On message
				push_tx(0x90);
				push_tx(kbnote);
				push_tx(0x7f);
			}
		}
	}
	else
		// no messages, send Active Sense message instead
		push_tx(0xfe);

	m_keyboard_state = kbstate;
	if(is_transmit_register_empty())
		tra_complete();
}
示例#3
0
文件: tx.c 项目: sstone/lightning
u8 *linearize_tx(const tal_t *ctx, const struct bitcoin_tx *tx)
{
	u8 *arr = tal_arr(ctx, u8, 0);
	push_tx(tx, push_linearize, &arr, true);
	return arr;
}