citp / BlockSci

A high-performance tool for blockchain science and exploration
https://citp.github.io/BlockSci/
GNU General Public License v3.0
1.34k stars 259 forks source link

Is there a way to get the string for nonstandard and multis addresses #452

Open Kindhearted57 opened 3 years ago

Kindhearted57 commented 3 years ago

System Information (if applicable)

Using AMI: no BlockSci version: 0.7.0 Blockchain: Bitcoin Parser: Disk

I want to iterate through the blockchain and get the inputs and outputs of each transaction. However, as for nonstandard and multisig type, I can not find out a way to get the address string.

The below code shows how to get the address string for other types of address. But there seems no way to get the address string for the two aforementioned type?

for block in chain:
    for tx in block:
        inputs = tx.inputs.address.to_list()
        outputs = tx.outputs.address.to_list()
        for i in inputs:
            print(i.address_string)
jiagengliu commented 3 years ago

These don't have a representative address string, I think. Alternatively, you can record the transaction hash.

Kindhearted57 commented 3 years ago

These don't have a representative address string, I think. Alternatively, you can record the transaction hash.

Do you mean record the transaction hash then find the address string from other source like btc explorer? My problem is that I have a large amount of addresses to deal with... So other methods like crawler might not be effective.

jiagengliu commented 3 years ago

These don't have a representative address string, I think. Alternatively, you can record the transaction hash.

Do you mean record the transaction hash then find the address string from other source like btc explorer? My problem is that I have a large amount of addresses to deal with... So other methods like crawler might not be effective.

Yes. Alternatively, you can keep a record of the address index and address type. These do not change from machine to machine.

alex-btc commented 7 months ago

Hi @jiagengliu, I'm wondering if we can still utilize all BlockSci functionalities for Taproot addresses (beginning with bc1p), despite BlockSci not being updated since the Taproot upgrade.

In my testing, all transaction details, including inputs, outputs, and values, are accurate. The only issue is with the address_string, which cannot be obtained for Taproot addresses. However, Taproot addresses do have a valid unique address_num and are categorized as address_type.witness_unknown, WitnessUnknownScript(), with a raw_type equals to 9.

Is my understanding correct?

If @maltemoeser is still active here, I would like also to hear his opinion on this.

jiagengliu commented 7 months ago

@alex-btc Yes I agree with you. After all, Taproot addresses should be somewhat backward compatible with older node versions. However, it's unclear whether clustering algorithms still work as expected.