BirthdayResearch / jellyfishsdk

DeFiChain Jellyfish SDK & Ecosystem for building modern lite DeFi Applications at scale.
https://jellyfishsdk.com
MIT License
104 stars 36 forks source link

Efficiently get addressFrom from the transaction list #1765

Open sandrich opened 2 years ago

sandrich commented 2 years ago

Hi

I was wondering what an efficient way is to get the fromAddress from the transaction list?

ie. from endpoint https://ocean.defichain.com/v0/testnet/address/tf1q74jn0ddazjlw6nmra4a40fcquqhrqhlf92egd8/transactions

As of now I have to go through each transaction and load the vin? Then from there translate the address from script hex? Seems very inefficient if I have to do that for lots of transactions.

I see here that hid is a hashed verison that contains addressFrom. But not sure this can be extracted.

https://github.com/JellyfishSDK/jellyfish/blob/c6a5a4fc1020f4032b06f8a6c785a1f9f704f85b/apps/whale-api/src/module.api/address.controller.ts#L214

Any help is appreciated

jellyfishsdk-bot commented 2 years ago

@sandrich: Thanks for opening an issue, it is currently awaiting triage.

The triage/accepted label can be added by foundation members by writing /triage accepted in a comment.

Details I am a bot created to help the [JellyfishSDK](https://github.com/JellyfishSDK) developers manage community feedback and contributions. You can check out my [manifest file](https://github.com/JellyfishSDK/jellyfish/blob/main/.github/governance.yml) to understand my behavior and what I can do. If you want to use this for your project, you can check out the [BirthdayResearch/oss-governance-bot](https://github.com/BirthdayResearch/oss-governance-bot) repository.
jellyfishsdk-bot commented 2 years ago

@sandrich: There are no 'area' labels on this issue. Adding an appropriate label will greatly expedite the process for us. You can add as many area as you see fit. If you are unsure what to do you can ignore this!

You can add area labels by leaving a /area comment.

Details I am a bot created to help the [JellyfishSDK](https://github.com/JellyfishSDK) developers manage community feedback and contributions. You can check out my [manifest file](https://github.com/JellyfishSDK/jellyfish/blob/main/.github/governance.yml) to understand my behavior and what I can do. If you want to use this for your project, you can check out the [BirthdayResearch/oss-governance-bot](https://github.com/BirthdayResearch/oss-governance-bot) repository.
fuxingloh commented 2 years ago

/area packages

Hey, I'm assuming the data type is encoded as Script Hex?

You can use this package to parse and decode/encode them https://github.com/JellyfishSDK/jellyfish/tree/main/packages/jellyfish-address

sandrich commented 2 years ago

Thanks this I know. The problem is that v0/testnet/address/xxx/transactions does not include the sender address which means I have to do a second request to v0/testnet/transaction/xxx/vins and I was wondering if I can prevent that and capture a utxo transaction including its sender address in one API call?

arnaudom commented 1 year ago

Thanks this I know. The problem is that v0/testnet/address/xxx/transactions does not include the sender address which means I have to do a second request to v0/testnet/transaction/xxx/vins and I was wondering if I can prevent that and capture a utxo transaction including its sender address in one API call?

I am exploring the API and not very familiar with it. But I think your idea is good as it compile more useful data in 1 request. However, I can't figure out how you get address from v0/testnet/transaction/xxx/vins. I try also v0/testnet/transactions/tttt/vouts but not geting address either. Any suggestion ?