예제 #1
0
파일: util.c 프로젝트: MrBitKoin/picocoin
static void test_btc_decimal(int64_t v, const char *s)
{
	char valstr[128];

	btc_decimal(valstr, sizeof(valstr), v);

	if (strcmp(valstr, s)) {
		fprintf(stderr, "util: conv(%lld) yielded %s, expected %s\n",
			(long long) v,
			valstr,
			s);
		
		assert(!strcmp(valstr, s));
	}
}
예제 #2
0
static void output_json_txout(json_t *arr, const struct bp_txout *txout,
				unsigned int n_idx)
{
	json_t *obj = json_object();
	assert(obj != NULL);

	char raw_valstr[VALSTR_SZ];
	btc_decimal(raw_valstr, VALSTR_SZ, txout->nValue);

	double raw_val = strtod(raw_valstr, NULL);
	json_t *val = json_real(raw_val);
	assert(val != NULL);

	int rc = json_object_set_new(obj, "value_FIXME", val);
	assert(rc == 0);

	bp_json_set_new_int(obj, "n", n_idx);
	bp_json_set_new_script(obj, "scriptPubKey", txout->scriptPubKey);

	json_array_append_new(arr, obj);
}