spesmilo/electrum-server — pull request #62 by bitcartel (2014-06-14 02:39:46+00:00)
Title: Added two new commands, gettxidbyteoffset() and gettxidfrombyteoffset()

Added two new commands which are useful for third-party plug-ins if they want to find the byte offset within a block of a transaction's raw data.

Assume we are interested in examining Block #266156 which has 297 transactions, of which the first two are listed below:
fcb8173d83bfd70475c8d9af1690308a3d8754d33dcd3ce5db3d9508a5c2fb62
72c8da513e3d3b2ed11e10977c0da6c30531c349d44eb3dfef62ac3f573575b1

Here is some example usage in the console. You can verify the results by examining blk0089.dat.

```
Welcome to Electrum!
>> gettxidbyteoffset('fcb8173d83bfd70475c8d9af1690308a3d8754d33dcd3ce5db3d9508a5c2fb62', 266156)
[
83
]

>> gettxidbyteoffset('72c8da513e3d3b2ed11e10977c0da6c30531c349d44eb3dfef62ac3f573575b1', 266156)
[
206
]

>> gettxidbyteoffset('72c8da513e3d3b2ed11e10977c0da6c30531c349d44eb3dfef62ac3f573575b1', 266157)
gettxidbyteoffset() returns:
[
null
]

>> gettxidfrombyteoffset(83, 266156)
[
"fcb8173d83bfd70475c8d9af1690308a3d8754d33dcd3ce5db3d9508a5c2fb62"
]

>> gettxidfrombyteoffset(83, 266157)
[
null
]

>> gettxidfrombyteoffset(206, 266156)
[
"72c8da513e3d3b2ed11e10977c0da6c30531c349d44eb3dfef62ac3f573575b1"
]

```