-
Notifications
You must be signed in to change notification settings - Fork 21
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
fix: check recipient against blocklist client in withdrawals #1428
base: main
Are you sure you want to change the base?
Conversation
signer/src/error.rs
Outdated
@@ -607,11 +607,20 @@ pub enum Error { | |||
/// Bitcoin error when attempting to construct an address from a | |||
/// scriptPubKey. | |||
#[error("bitcoin address parse error: {0}; txid {txid}, vout: {vout}", txid = .1.txid, vout = .1.vout)] | |||
BitcoinAddressFromScript( | |||
BitcoinAddressFromScriptWithOutpoint( |
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'm not really happy with this naming but I don't really see which outpoint we can attach to withdrawals, thus it is okish I think
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.
For deposits it's not necessarily the "outpoint" itself that we're interested in, it's just that the outpoint is the unique identifier of the deposit request; for withdrawals, it's the request_id
(+ its block_hash
to identify it across forks). I might opt to name these WithdrawalBitcoinAddress
and DepositBitcoinAddress
or something along those lines, and have the withdrawal version accept its request id and block hash.
Btw, about issue itself. I can see why we checking recipient is more important then sender: But if my intuition is correct why we do not check recipient in deposits? Because we mint coins for them and not directly transfer? And very final question: why don't we want to check both sender and recipient agains blocklist? pinging @djordon as author of issue |
The sender/recipient is always a stacks/bitcoin address pair and I'm not sure that there are any sanctions for Stacks addresses (at least in OFAC or the EU sanctions list). Nor am I sure if Chainalysis does any specific forensic/clustering analysis on the Stacks blockchain that would enable their screening service to properly screen Stacks addresses? However, the blocklist client is intended to be able to be swapped out for a custom implementation, which may include a signer's own risk analysis/database supporting STX addresses, so I do think that we should eventually be sending the request for both and that our implementation simply filters out Stacks addresses for now. But in practice, all of the signers are using Chainalysis at the moment, so there's no direct demand for supporting STX addresses. |
let receiver_address = bitcoin::Address::from_script(&receiver_pubkey, network.params()) | ||
.map_err(|err| Error::BitcoinAddressFromScript(err, receiver_pubkey.into()))?; | ||
|
||
let can_accept = client |
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 know we don't have them today or for deposits either, but I wouldn't be sad if a test or two popped up ensuring that this error is actually returned if the receiver pubkey is bad/network mismatch/etc.
Until our canonical blocklist implementation returns ok on addresses it don't know I think nothing stops us to test both stacks and bitcoin addresses now. However, delaying it can lead to forgetting, thus I'd suggest to implement it now |
Hey, @cylewitruk, I added some test for both deposits and withdrawals. It is not isolating only this |
assert_eq!(decisions.len(), 1); | ||
assert_eq!(decisions.last().unwrap().is_accepted, !is_blocked); | ||
assert!(!votes.is_empty()); | ||
assert!(votes.iter().any(|vote| { |
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.
Tbh a bit annoying that get_withdrawal_request_signer_votes
and get_deposit_signer_decisions
are different =)
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.
There is get_deposit_request_signer_votes()
, is that maybe what you meant to use?
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.
Originally it was test for deposits which I rebranded to both deposits and withdrawals. It was using get_deposit_signer_decisions
, and get_deposit_signers
. I keep them and tried to find the closest signer analogues, but get_withdrawal_signer_decisions
doesn't exist. But anyway I think that this functions are fine and we extract what we want in both deposits and withdrawals
What Cyle wrote in #1428 (comment) is spot on. We don't check the Stacks side because we do not think that the signers need to. If that changed then we may have to change the code here. |
Description
Closes: #1415
Changes
Testing Information
Checklist: