Esempio n. 1
0
 def block_header(self, ec, blk_head, statement_line, info):
     info["timestamp"] = blk_head.timestamp
     info["block_hash"] = str(bitcoin.hash_block_header(blk_head))
     tx_hash = bitcoin.hash_digest(info["tx_hash"])
     self.chain.fetch_transaction(tx_hash,
         bitcoin.bind(self.load_tx, bitcoin._1, bitcoin._2,
             statement_line, info))
Esempio n. 2
0
 def block_header(self, ec, blk_head, entry, info):
     if self.stop_on_error(ec):
         return
     info["timestamp"] = blk_head.timestamp
     info["block_hash"] = str(bitcoin.hash_block_header(blk_head))
     tx_hash = bitcoin.hash_digest(info["tx_hash"])
     # Now load the actual main transaction for this input or output
     self.chain.fetch_transaction(tx_hash, bind(self.load_chain_tx, _1, _2, entry, info))
Esempio n. 3
0
 def block_header(self, ec, blk_head, statement_line, info):
     info["timestamp"] = blk_head.timestamp
     info["block_hash"] = str(bitcoin.hash_block_header(blk_head))
     tx_hash = bitcoin.hash_digest(info["tx_hash"])
     self.chain.fetch_transaction(
         tx_hash,
         bitcoin.bind(self.load_tx, bitcoin._1, bitcoin._2, statement_line,
                      info))
Esempio n. 4
0
 def block_header(self, ec, blk_head, entry, info):
     if self.stop_on_error(ec):
         return
     info["timestamp"] = blk_head.timestamp
     info["block_hash"] = str(bitcoin.hash_block_header(blk_head))
     tx_hash = bitcoin.hash_digest(info["tx_hash"])
     # Now load the actual main transaction for this input or output
     self.chain.fetch_transaction(
         tx_hash, bind(self.load_chain_tx, _1, _2, entry, info))
Esempio n. 5
0
 def start_loading(self, membuf_result, output_points):
     if len(membuf_result) == 0 and len(output_points) == 0:
         self.handle_finish([])
         self.stopped()
     # Create a bunch of entry lines which are outputs and
     # then their corresponding input (if it exists)
     for outpoint in output_points:
         entry = PaymentEntry(outpoint)
         with self.lock:
             self.statement.append(entry)
         # Attempt to fetch the spend of this output
         self.chain.fetch_spend(outpoint, bind(self.load_spend, _1, _2, entry))
         self.load_tx_info(outpoint, entry, False)
     # Load memory pool transactions
     with self.lock:
         self.membuf_result = membuf_result
     for info in self.membuf_result:
         self.txpool.fetch(bitcoin.hash_digest(info["tx_hash"]), bind(self.load_pool_tx, _1, _2, info))
Esempio n. 6
0
 def start_loading(self, membuf_result, output_points):
     if len(membuf_result) == 0 and len(output_points) == 0:
         self.handle_finish([])
         self.stopped()
     # Create a bunch of entry lines which are outputs and
     # then their corresponding input (if it exists)
     for outpoint in output_points:
         entry = PaymentEntry(outpoint)
         with self.lock:
             self.statement.append(entry)
         # Attempt to fetch the spend of this output
         self.chain.fetch_spend(outpoint,
                                bind(self.load_spend, _1, _2, entry))
         self.load_tx_info(outpoint, entry, False)
     # Load memory pool transactions
     with self.lock:
         self.membuf_result = membuf_result
     for info in self.membuf_result:
         self.txpool.fetch(bitcoin.hash_digest(info["tx_hash"]),
                           bind(self.load_pool_tx, _1, _2, info))
Esempio n. 7
0
import bitcoin, trace_tx

def blockchain_started(ec, chain):
    print "Blockchain initialisation:", ec
def handle_tx(ec, tx):
    if ec:
        print ec
    trace_tx.trace_tx(service.internal_ptr, chain.internal_ptr, tx, finish)

def finish(ec, result):
    print ec
    print result

service = bitcoin.async_service(1)
chain = bitcoin.bdb_blockchain(service, "/home/genjix/libbitcoin/database",
                               blockchain_started)
chain.fetch_transaction(
    bitcoin.hash_digest("16e3e3bfbaa072e33e6a9be1df7a13ecde5ad46a8d4d4893dbecaf0c0aeeb842"),
    handle_tx)

raw_input()

Esempio n. 8
0
import bitcoin

import trace_tx


def blockchain_started(ec, chain):
    print "Blockchain initialisation:", ec


def handle_tx(ec, tx):
    if ec:
        print ec
    trace_tx.trace_tx(service.internal_ptr, chain.internal_ptr, tx, finish)


def finish(ec, result):
    print ec
    print result


if __name__ == '__main__':
    service = bitcoin.async_service(1)
    chain = bitcoin.bdb_blockchain(service, "/home/genjix/libbitcoin/database",
                                   blockchain_started)
    chain.fetch_transaction(
        bitcoin.hash_digest(
            "16e3e3bfbaa072e33e6a9be1df7a13ecde5ad46a8d4d4893dbecaf0c0aeeb842"
        ), handle_tx)

    raw_input()
import bitcoin

ec = bitcoin.elliptic_curve_key()
print ec.new_key_pair()
privdat = ec.private_key()
print privdat

ec1 = bitcoin.elliptic_curve_key()
ec1.set_private_key(privdat)
assert str(ec1.private_key()) == str(privdat)

h = bitcoin.hash_digest("f003f0c1193019db2497a675fd05d9f2edddf9b67c59e677c48d3dbd4ed5f00b")
print h
sig = ec1.sign(h)
print ec.verify(h, sig)

    vers.address_you.services = 1
    vers.address_you.ip = \
        [0, 0, 0, 0, 0, 0, 0, 0, 
         0, 0, 255, 255, 127, 0, 0, 1]
    vers.address_you.port = 8333
    vers.user_agent = "/libbitcoin:0.4/example:1/";
    vers.start_height = 0
    vers.nonce = 42
    channel.send_version(vers, handle_send)
    chan = channel
    channel.subscribe_version(read_version_reply)
    print 'connect'

d = bitcoin.data_chunk("001212")
print d
h = bitcoin.hash_digest("000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f")
print h
if h == "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f":
    print 'Yes'
print len(h)

tx = bitcoin.transaction()
print bitcoin.hash_transaction(tx)

netaddr = bitcoin.network_address()
print netaddr.ip

s = bitcoin.script()
o = bitcoin.operation()
o.code = bitcoin.opcode.special
s.push_operation(o)