-
Notifications
You must be signed in to change notification settings - Fork 84
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
client/dcr: Identify unknown txs #2748
base: master
Are you sure you want to change the base?
Conversation
This diff updates the DCR wallet to identify any unknown transaction and add it to the transaction history. Redeems, refunds, and bond refund transactions are updated to use an external address instead of an internal one. Otherwise, the RPC wallet's listsinceblock command would not return them.
client/asset/dcr/dcr.go
Outdated
accountsToCheck := make([]string, 0, 3) | ||
|
||
if accounts.PrimaryAccount != "" { | ||
accountsToCheck = append(accountsToCheck, accounts.PrimaryAccount) | ||
} | ||
if accounts.TradingAccount != "" { | ||
accountsToCheck = append(accountsToCheck, accounts.TradingAccount) | ||
} | ||
if accounts.UnmixedAccount != "" { | ||
accountsToCheck = append(accountsToCheck, accounts.UnmixedAccount) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this (*ExchangeWallet).allAccounts
?
client/asset/dcr/dcr.go
Outdated
if *tx.TxType == walletjson.LTTTVote { | ||
return &asset.WalletTransaction{ | ||
Type: asset.TicketVote, | ||
ID: tx.TxID, | ||
Amount: totalOut, | ||
Fees: fee, | ||
}, nil | ||
} | ||
if *tx.TxType == walletjson.LTTTRevocation { | ||
return &asset.WalletTransaction{ | ||
Type: asset.TicketRevocation, | ||
ID: tx.TxID, | ||
Amount: totalOut, | ||
Fees: fee, | ||
}, nil | ||
} | ||
if *tx.TxType == walletjson.LTTTTicket { | ||
return &asset.WalletTransaction{ | ||
Type: asset.TicketPurchase, | ||
ID: tx.TxID, | ||
Amount: totalOut, | ||
Fees: fee, | ||
}, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switch *tx.TxType {
case walletjson.LTTTVote:
return &asset.WalletTransaction{
Type: asset.TicketVote,
ID: tx.TxID,
Amount: totalOut,
Fees: fee,
}, nil
case walletjson.LTTTRevocation:
return &asset.WalletTransaction{
Type: asset.TicketRevocation,
ID: tx.TxID,
Amount: totalOut,
Fees: fee,
}, nil
case walletjson.LTTTTicket:
return &asset.WalletTransaction{
Type: asset.TicketPurchase,
ID: tx.TxID,
Amount: totalOut,
Fees: fee,
}, nil
}
|
||
if tx.Send && allOutputsPayUs(msgTx) && len(msgTx.TxIn) == 1 { | ||
return &asset.WalletTransaction{ | ||
Type: asset.Split, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be a SelfSend
I guess, but split is more likely.
client/asset/dcr/dcr.go
Outdated
go func() { | ||
dcr.tipMtx.RLock() | ||
tip := dcr.currentTip | ||
dcr.tipMtx.RUnlock() | ||
dcr.syncTxHistory(ctx, uint64(tip.height)) | ||
}() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need to be asynchronous?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it can only be a longer running function on the initial call in Connect
. After your rescanning PR gets merged though and this can get reset to 0, it could become a longer running function whenever the rescan completes.
client/asset/dcr/dcr.go
Outdated
@@ -6198,7 +6588,7 @@ func (dcr *ExchangeWallet) handleTipChange(ctx context.Context, newTipHash *chai | |||
dcr.cycleMixer() | |||
} | |||
|
|||
go dcr.checkPendingTxs(ctx, uint64(newTipHeight)) | |||
go dcr.syncTxHistory(ctx, uint64(newTipHeight)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now are launching two unmonitored goroutines in handleTipChange
. Maybe we should make handleTipChange
synchronous and use a waitgroup internally.
client/asset/dcr/dcr.go
Outdated
@@ -1084,6 +1087,8 @@ func (dcr *ExchangeWallet) Connect(ctx context.Context) (*sync.WaitGroup, error) | |||
dcr.monitorPeers(ctx) | |||
}() | |||
|
|||
go dcr.syncTxHistory(ctx, uint64(tip.height)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a WaitGroup
. Why not use it?
Same thing in btc I guess.
We don't have access to the counterparty's swap transaction, so we cannot know the fee. I guess we could implement it for full nodes though. |
If we have the redemption or refund transaction isn't the fee in - out? |
Yes, but the SPV wallet does not have access to the counterparty's swap transaction, so how will we get the input? |
I thought we would have the input witness data as part of the raw transaction. Let me make sure... |
I'm pretty sure we can get the tx fee if we have the raw tx of the transaction. I just tried this with a native wallet and it worked:
|
This diff updates the DCR wallet to identify any unknown transaction and add it to the transaction history. Redeems, refunds, and bond refund transactions are updated to use an external address instead of an internal one. Otherwise, the RPC wallet's listsinceblock command would not return them.
Closes #2744