Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions blockscipy/blocksci/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from multiprocess import Pool
import dateparser
from dateutil.relativedelta import relativedelta
import numpy as np
import pandas as pd

from ._blocksci import *
Expand Down Expand Up @@ -636,6 +637,15 @@ def setup_range_and_proxy_methods(blocksci_range):
setup_range_and_proxy_methods(cluster.TaggedAddressRange)


# Fix timestamp difference between normal Pybind11 datetime conversion and numpy arrays
def new_time(block: Block):
return np.datetime64(block.timestamp, "s").astype("datetime64[ns]")
Block.time = property(new_time)
def new_tx_time(tx: Tx):
return np.datetime64(tx.block_timestamp, "s").astype("datetime64[ns]")
Tx.block_time = property(new_tx_time)


def txes_including_output_of_type(txes, typ):
return txes.where(lambda tx: tx.outputs.any(lambda o: o.address_type == typ))

Expand Down
3 changes: 3 additions & 0 deletions blockscipy/src/chain/tx/tx_proxy_py.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ struct AddTransactionMethods {
func(property_tag, "block_time", +[](const Transaction &tx) -> std::chrono::system_clock::time_point {
return tx.block().getTime();
}, "The time that the block containing this transaction arrived");
func(property_tag, "block_timestamp", +[](const Transaction &tx) -> int64_t {
return tx.block().timestamp();
}, "Block timestamp");
func(property_tag, "observed_in_mempool", &Transaction::observedInMempool, "Returns whether this transaction was seen in the mempool by the recorder");
func(property_tag, "time_seen", &Transaction::getTimeSeen, "If recorded by the mempool recorder, the time that this transaction was first seen by your node");
func(property_tag, "block", &Transaction::block, "The block that this transaction was in");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Block(tx_count=5, height=113, header_hash=121d93886d8ec313c13465d4cb9421fbf63dee
Block(tx_count=2, height=111, header_hash=7ca20a203a5ba00f52478e578efe069278d664108cabb59cf95a4a3548db2385, version=536870912, timestamp=1535761200, bits=545259519, nonce=3)
5000020000
597
2018-09-01 00:30:00+00:00
2018-09-01T00:30:00.000000000
None
1535761800
597
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Block(tx_count=5, height=113, header_hash=6b967b3001ea5e7e5e5175cd4c98e5c5419b5f
Block(tx_count=2, height=111, header_hash=79a894fe764ef96801a1e01eeb66b495293e856fe3a73223de9570a19c0471d3, version=536870912, timestamp=1535761200, bits=545259519, nonce=0)
5000020000
671
2018-09-01 00:30:00+00:00
2018-09-01T00:30:00.000000000
None
1535761800
671
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Block(tx_count=5, height=113, header_hash=73e77949a7f1289aa18a4bc099db4c377f7f81
Block(tx_count=2, height=111, header_hash=571b48850f70f7ecd76f5e652550553d358a1109211aa007089a5966419d05f3, version=536870912, timestamp=1535761200, bits=545259519, nonce=1)
5000020000
671
2018-09-01 00:30:00+00:00
2018-09-01T00:30:00.000000000
None
1535761800
671
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Block(tx_count=2, height=123, header_hash=18ab42dda7c21ecdbef3bb8af1537b42612efc
Block(tx_count=3, height=121, header_hash=6b4c87d26c48371ebb9a5561e226bb722c9263fc6c9c9f072ef67a8c3d0e5104, version=536870912, timestamp=1535767200, bits=545259519, nonce=0)
5000040000
1116
2018-09-01 02:10:00+00:00
2018-09-01T02:10:00.000000000
None
1535767800
1116
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Block(tx_count=2, height=123, header_hash=65baade5135cc19665148a2cea1ee9f658ea93
Block(tx_count=3, height=121, header_hash=aee604c197849f16df2d4a34db8c952eef11333b805cbe7e4e00967b830b1bd1, version=536870912, timestamp=1535767200, bits=545259519, nonce=3)
5000040000
1116
2018-09-01 02:10:00+00:00
2018-09-01T02:10:00.000000000
None
1535767800
1116
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Block(tx_count=1, height=91, header_hash=67b3b6f61bf2329baaed0f69ace5069d55c7e19
Block(tx_count=1, height=89, header_hash=3c1433c6f2f64e78c3eb4545edcf74d9822c90b5e1e260ce1e639ad6cc245705, version=536870912, timestamp=1535760616, bits=545259519, nonce=0)
5000000000
181
2018-09-01 00:10:16+00:00
2018-09-01T00:10:16.000000000
None
1535760616
181
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Block(tx_count=1, height=91, header_hash=3a6d1c5585aabd0ae5af4727ae07347356ee8d2
Block(tx_count=1, height=89, header_hash=417608d639ec9058168ab5c58aea347e9d65b5d76473ac680f1c0558b580960a, version=536870912, timestamp=1535760616, bits=545259519, nonce=5)
5000000000
253
2018-09-01 00:10:16+00:00
2018-09-01T00:10:16.000000000
None
1535760616
253
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Block(tx_count=1, height=91, header_hash=5b27431d906155fdb0469d2c5415bac6e914805
Block(tx_count=1, height=89, header_hash=c1334fa426b3c10387d73358fe205fab54d25d642b61882c8456797f2f39cd3f, version=536870912, timestamp=1535760616, bits=545259519, nonce=3)
5000000000
253
2018-09-01 00:10:16+00:00
2018-09-01T00:10:16.000000000
None
1535760616
253
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
226
111
2018-09-01 00:20:00+00:00
2018-09-01T00:20:00.000000000
10000
44
89530a3ac8a65f8cab0ad2a038ea1a3a850a0f82167c84b0caa873ea1ffce1a1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
225
111
2018-09-01 00:20:00+00:00
2018-09-01T00:20:00.000000000
10000
44
9a27d8c02ed0ae0f62072963bae34ce845e7ba6b971d9bc76f58e14bec91c3e3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
225
111
2018-09-01 00:20:00+00:00
2018-09-01T00:20:00.000000000
10000
44
9a27d8c02ed0ae0f62072963bae34ce845e7ba6b971d9bc76f58e14bec91c3e3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
224
115
2018-09-01 01:00:00+00:00
2018-09-01T01:00:00.000000000
10000
44
778af7567b200ab75f8e7b74614d6d0e86cfe26a36e6a3d33693c51cbd4bed07
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
224
115
2018-09-01 01:00:00+00:00
2018-09-01T01:00:00.000000000
10000
44
1b448e0add367565e4aa6d3431adf5bf3e5200b5b8cc6c23d0cd5a46f9d086a9
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
224
115
2018-09-01 01:00:00+00:00
2018-09-01T01:00:00.000000000
10000
44
1b448e0add367565e4aa6d3431adf5bf3e5200b5b8cc6c23d0cd5a46f9d086a9
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
222
119
2018-09-01 01:40:00+00:00
2018-09-01T01:40:00.000000000
10000
45
56a552806a9608554c976cd87b0f622b0b0bebfe89f21010efb2298bc0d0483a
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
222
119
2018-09-01 01:40:00+00:00
2018-09-01T01:40:00.000000000
10000
45
56a552806a9608554c976cd87b0f622b0b0bebfe89f21010efb2298bc0d0483a
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
235
121
2018-09-01 02:00:00+00:00
2018-09-01T02:00:00.000000000
10000
42
ce707ce4ef0a3c960d130db272a4c971530fc42e6f0842cf8ac0d71c8ae09cf7
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
235
121
2018-09-01 02:00:00+00:00
2018-09-01T02:00:00.000000000
10000
42
ce707ce4ef0a3c960d130db272a4c971530fc42e6f0842cf8ac0d71c8ae09cf7
Expand Down