Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueTransferKind::Sent turns into ValueTransferKind::SendToSelf after ReOrg #622

Open
pacu opened this issue Oct 24, 2023 · 0 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@pacu
Copy link
Collaborator

pacu commented Oct 24, 2023

this is actually kind of weird and can be reproduced consistenly when running the test on this PR: #619

When the test wallet sends a transaction a TX ID is returned SENT TX ID: "8a88d3706fce0702a5cfc7691ee4c312a1b9800d3af7e69440fe01eadefb185c"

the this is the dump of do_list_txsummaries

[ValueTransfer { block_height: BlockHeight(203), datetime: 1, kind: Received { pool: Orchard, amount: 100000000 }, memos: [], price: None, txid: TxId("8698b158c0746e868615611ad9ca106465b51032a7c5c45a1963f5a193f5cce1") }, ValueTransfer { block_height: BlockHeight(205), datetime: 1698185187, kind: Sent { amount: 100000, to_address: ZcashAddress { net: Regtest, kind: Unified(Address([P2pkh([194, 233, 133, 149, 15, 205, 125, 169, 93, 133, 49, 242, 127, 97, 240, 45, 186, 96, 1, 45]), Sapling([85, 56, 108, 149, 244, 208, 77, 10, 114, 22, 236, 103, 220, 254, 110, 55, 215, 13, 12, 101, 127, 190, 95, 98, 191, 226, 249, 105, 161, 0, 248, 79, 70, 73, 206, 64, 206, 2, 229, 226, 181, 177, 183]), Orchard([202, 101, 1, 126, 115, 154, 198, 112, 65, 23, 144, 213, 80, 49, 5, 41, 212, 132, 38, 87, 245, 237, 89, 140, 206, 126, 190, 166, 107, 199, 153, 7, 235, 13, 152, 24, 56, 245, 151, 188, 214, 97, 147])])) } }, memos: [], price: None, txid: TxId("0f5f0c56994ff79504e000c56af8a9bbd30973e88744b6efca26e14f0ce10778") }, ValueTransfer { block_height: BlockHeight(205), datetime: 1698185187, kind: Fee { amount: 10000 }, memos: [], price:
```

The information makes sense, except for the TX IDs. This is related to the problem reported here: https://github.com/zingolabs/zingolib/issues/621


This is the TX that originates the funds that are used to send

```
ValueTransfer { block_height: BlockHeight(203), datetime: 1, kind: Received { pool: Orchard, amount: 100000000 }, memos: [], price: None, txid: TxId("8698b158c0746e868615611ad9ca106465b51032a7c5c45a1963f5a193f5cce1") }
```

And these are the two value transfers that are originated from the transaction sent to another wallet

```
ValueTransfer { block_height: BlockHeight(205), datetime: 1698185187, kind: Sent { amount: 100000, to_address: ZcashAddress { net: Regtest, kind: Unified(Address([P2pkh([194, 233, 133, 149, 15, 205, 125, 169, 93, 133, 49, 242, 127, 97, 240, 45, 186, 96, 1, 45]), Sapling([85, 56, 108, 149, 244, 208, 77, 10, 114, 22, 236, 103, 220, 254, 110, 55, 215, 13, 12, 101, 127, 190, 95, 98, 191, 226, 249, 105, 161, 0, 248, 79, 70, 73, 206, 64, 206, 2, 229, 226, 181, 177, 183]), Orchard([202, 101, 1, 126, 115, 154, 198, 112, 65, 23, 144, 213, 80, 49, 5, 41, 212, 132, 38, 87, 245, 237, 89, 140, 206, 126, 190, 166, 107, 199, 153, 7, 235, 13, 152, 24, 56, 245, 151, 188, 214, 97, 147])])) } }, memos: [], price: None, txid: TxId("0f5f0c56994ff79504e000c56af8a9bbd30973e88744b6efca26e14f0ce10778") }, ValueTransfer { block_height: BlockHeight(205), datetime: 1698185187, kind: Fee { amount: 10000 }, memos: [], price:
```

We have two kinds:  `Sent` and `Fee`. Which are correct.


Then the reorg happens:

and this is what `do_list_txsummaries` returns

```
[ValueTransfer { block_height: BlockHeight(203), datetime: 1, kind: Received { pool: Orchard, amount: 100000000 }, memos: [], price: None, txid: TxId("8698b158c0746e868615611ad9ca106465b51032a7c5c45a1963f5a193f5cce1") }, ValueTransfer { block_height: BlockHeight(210), datetime: 1, kind: SendToSelf, memos: [], price: None, txid: TxId("8a88d3706fce0702a5cfc7691ee4c312a1b9800d3af7e69440fe01eadefb185c") }, ValueTransfer { block_height: BlockHeight(210), datetime: 1, kind: Fee { amount: 100000000 }, memos: [], price: None, txid: TxId("8a88d3706fce0702a5cfc7691ee4c312a1b9800d3af7e69440fe01eadefb185c") }]
```


The value transfer that is the funding TX. ✅
```
ValueTransfer { block_height: BlockHeight(203), datetime: 1, kind: Received { pool: Orchard, amount: 100000000 }
```

Then the `ValueTransfer`s from the sent transaction that is involved in the ReOrg

```
alueTransfer { block_height: BlockHeight(210), datetime: 1, kind: SendToSelf, memos: [], price: None, txid: TxId("8a88d3706fce0702a5cfc7691ee4c312a1b9800d3af7e69440fe01eadefb185c") }, ValueTransfer { block_height: BlockHeight(210), datetime: 1, kind: Fee { amount: 100000000 }, memos: [], price: None, txid: TxId("8a88d3706fce0702a5cfc7691ee4c312a1b9800d3af7e69440fe01eadefb185c") }
```

The kind is actually wrong because it's no transaction sent to self `kind: SendToSelf` but a `Sent` one.

**But there's an interesting change here!** ---> THE TX ID matches the one originally reported by `do_send` which **did not** match the transaction created and submitted to the network!



@zancas zancas self-assigned this Oct 25, 2023
@zancas zancas added the bug Something isn't working label Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants