bitcoin-kit-android icon indicating copy to clipboard operation
bitcoin-kit-android copied to clipboard

Inputs and Outputs are null or ""

Open AndroDevcd opened this issue 2 years ago • 8 comments

When calling the following:

localWallet!!.walletKit!!.transactions(type = null).subscribe { txList: List<TransactionInfo> ->
     _transactions.postValue(txList)
}.let {
    disposables.add(it)
}

The transactions that are returned have the correct data but it is a toss-up on wether or not they have an address within the transaction inputs or outputs. I have noticed that when a transaction message comes through the address field is "" after it is processed. Where in the code and how are we populating the addresses from a given transaction?

AndroDevcd avatar Oct 13 '22 05:10 AndroDevcd

@abdrasulov Would this be an easy fix?

AndroDevcd avatar Oct 13 '22 05:10 AndroDevcd

It also appears that TransactionSerializer.serialize() is not working properly which may lead to the issue stated above. I have tested trying to deserialize transactions using raw hex returned from the network and it did not return a transaction where the txid != transaction.hash, my understanding is that the transaction id from the network should match the generated hash from the received transaction.

I have also tested the Test directory with tests testing the library and deserializing transactions and the expected tx hash was incorrect and failed the test. I think this may be the culprit or at the very least a good starting point.

AndroDevcd avatar Oct 13 '22 06:10 AndroDevcd

Okay nevermind the TransactionSerializer not working i didn't realize the toReversedHex() function was needed to view the human-readable hex value. However the problem still remains of the input and out put addresses being null or ""

AndroDevcd avatar Oct 13 '22 08:10 AndroDevcd

It actually looks like after further digging that fun extract(transaction: FullTransaction) { .. } may be the reason we have weirdness with addresses.

Is there a reason we only assign addresses and update the transaction if it is "Our" transaction? This seems like an easy thing to spot by the user hat incoming transactions will have a blank received from address.

AndroDevcd avatar Oct 13 '22 08:10 AndroDevcd

Hey @AndroDevcd ,

Not all the inputs and outputs may be filled with address field. Sometimes it's impossible. For example, if the input being sent is not in our storage, then we don't try to obtain it from the node. So we try to derive it from the input's signatureScript. For some input/output types like P2PKH or P2WPKHSH it's possible. For others it's not.

The reason why we extract addresses only for isMine transactions is that if it's not isMine, then it means it doesn't have any inputs or outputs concerning my wallet. So we just ignore it.

esen avatar Oct 13 '22 11:10 esen

Ahh okay, so then that basically means there's no way to know where the sender's bitcoin address was? I just wanted to be able to show on my app the address that the inbound sats came from but it sounds like this wouldn't be possible?

AndroDevcd avatar Oct 13 '22 12:10 AndroDevcd

Yes. For some (I’d say the most) inputs it’s impossible

esen avatar Oct 14 '22 09:10 esen

Okay sounds good, also @esen I will be submitting some PR's today for your wallet kit and bitcoin kit libraries that I think adds some nice touches and bug fixes

AndroDevcd avatar Oct 18 '22 18:10 AndroDevcd