CC = g++ -fPIC -Wall -ansi `pkg-config --cflags libbitcoin` -I/usr/include/python2.7
+trace_tx:
+ $(CC) -c trace_tx.cpp -o trace_tx.o
+ $(CC) -shared -Wl,-soname,trace_tx.so trace_tx.o -lpython2.7 -lboost_python `pkg-config --libs libbitcoin` -lboost_thread -o trace_tx.so
+
membuf:
$(CC) -c membuf.cpp -o membuf.o
$(CC) -shared -Wl,-soname,membuf.so membuf.o -lpython2.7 -lboost_python `pkg-config --libs libbitcoin` -lboost_thread -o membuf.so
self.cache.clear(affected_addrs)
self.notify(affected_addrs)
- def tx_confirmed(self, tx_desc):
+ def tx_confirmed(self, tx):
tx_hash, previous_outputs, addrs = self.unpack(tx)
with self.lock:
affected_addrs = self.affected[tx_hash]
del self.monitor_output[prevout]
def notify(self, affected_addrs):
- templ_response = {"id": None,
- "method": "blockchain.address.subscribe",
- "params": []}
service = self.backend.mempool_service
chain = self.backend.blockchain
txpool = self.backend.transaction_pool
memory_buff = self.backend.memory_buffer
for address in affected_addrs:
- response = templ_response.copy()
- response["params"].append(address)
+ response = {"id": None,
+ "method": "blockchain.address.subscribe",
+ "params": [str(address)]}
history.payment_history(service, chain, txpool, memory_buff,
address, bind(self.send_notify, _1, _2, response))
if ec:
print "Error: Monitor.send_notify()", ec
return
+ assert len(response["params"]) == 1
response["params"].append(self.mempool_n(result))
self.processor.push_response(response)
self.broadcast_transaction(request)
def broadcast_transaction(self, request):
- raw_tx = bitcoin.data_chunk(str(request["params"]))
+ raw_tx = bitcoin.data_chunk(str(request["params"][0]))
exporter = bitcoin.satoshi_exporter()
try:
tx = exporter.load_transaction(raw_tx)
mbuff = membuf.memory_buffer(a.internal_ptr, chain.internal_ptr,
txpool.internal_ptr)
mbuff.receive(tx, stored)
-address = "1GULoCDnGjhfSWzHs6zDzBxbKt9DR7uRbt"
+address = "1AA6mgxqSrvJTxRrYrikSnLaAGupVzvx4f"
raw_input()
history.payment_history(a, chain, txpool, mbuff, address, finish)
raw_input()
write_info(json, entry->loaded_input);
}
}
- for (info_unit_ptr info: membuf_result)
- {
+ // A bit of super glue
+ if (!statement.empty() && !membuf_result.empty())
json += ",";
- write_info(json, info);
+ for (auto it = membuf_result.begin(); it != membuf_result.end(); ++it)
+ {
+ if (it != membuf_result.begin())
+ json += ",";
+ write_info(json, *it);
}
json += "]";
pyfunction<const std::error_code&, const std::string&> f(handle_finish);
import json
def wrap_finish(handle_finish, ec, result_json):
- handle_finish(ec, json.loads(result_json))
+ try:
+ result = json.loads(result_json)
+ except ValueError:
+ print result_json
+ raise
+ else:
+ handle_finish(ec, result)
def payment_history(service, chain, txpool, membuf, address, finish):
_history.payment_history(service.internal_ptr, chain.internal_ptr,
txpool.internal_ptr, membuf.internal_ptr,
- address, bind(wrap_finish, finish, _1, _2))
+ str(address), bind(wrap_finish, finish, _1, _2))