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

coordinator: get_spend_transaction #31

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

edouardparis
Copy link
Member

@edouardparis edouardparis commented Jun 2, 2022

This PR introduce:

A new module coordinator that fetch spend transaction for each vault unvaulting.
The coordinator configuration is made optional. In case of no configuration, the watchtower does not fetch the spend transaction for each spending attempt.

A spend transaction fetched from the coordinator is checked agains libbitcoinconsensus. It prevents the managers colliding to sign an "evil" spend and sign it with cosigners and share a "legit" spend with no signatures to watchtowers to bypass spending policies.

A new plugin: whitelist, that revault vaults which candidate spend transaction contains recipient script pubkey not present in the authorized list. Beware that the change address and the cpfp address of the spend must be part of the whitelist too in order for the spend to go through (This behavior maybe changed in the future)

Fixes #23.

@edouardparis edouardparis force-pushed the get-spend-transaction branch 6 times, most recently from 46314d6 to 5173723 Compare June 15, 2022 16:12
@edouardparis edouardparis force-pushed the get-spend-transaction branch from 6f081b8 to 253b3e8 Compare June 17, 2022 13:44
@edouardparis edouardparis marked this pull request as ready for review June 17, 2022 14:01
@edouardparis edouardparis requested a review from darosior June 20, 2022 15:28
Copy link
Member

@darosior darosior left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still need to review the tests, but i already have a number of comments so i'll push that. A small meta point: you put a lot of thoughts into this PR so it would have been nice to convey that to its reviewers (or future archeologists) by giving some insights/rationale in the OP or the commit messages. :)

I think we should definitely experiment more on the plugin side. The current interface has the advantage of being simple. But it puts the burden on the plugin to handle the de-duplication. Is it ok? I don't know, off-hand i'd say yes but we should try before committing to it.
I think having a test with a whitelist plugin and a many-Unvaults Spend with the Unvaults in different blocks would be good to have.

src/coordinator.rs Outdated Show resolved Hide resolved
src/coordinator.rs Outdated Show resolved Hide resolved
src/coordinator.rs Outdated Show resolved Hide resolved
src/poller.rs Outdated Show resolved Hide resolved
src/coordinator.rs Outdated Show resolved Hide resolved
@@ -114,7 +116,40 @@ def bitcoind(directory):


@pytest.fixture
def miradord(request, bitcoind, directory):
def noise_keys():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, neat!

tests/test_framework/miradord.py Show resolved Hide resolved
tests/test_framework/utils.py Outdated Show resolved Hide resolved
Comment on lines +63 to +68
/// Get Spend transaction spending the vault with the given deposit outpoint.
/// Beware that the spend transaction may be invalid and needs to be verified against
/// libbitcoinconsensus.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of checking the Spend transaction against libbitcoinconsensus?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may have misunderstood libbitcoinconsensus usage, but it was to check that the sigs and the tx are valid and can pass the btc contensus and that the coordinator did not trick us with a fake spend that will never pass the mempool

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libbitcoinconsensus defines part of the consensus (and even more so of the standard Bitcoin Core relay policy). It can only do context-less checks. For instance, it would not be able to detect if the inputs of the Spend don't exist.

But if they committed to an invalid Spend.. It's their problem? It will be unspendable through the manager path so no harm can be done (assuming cosigning servers aren't compromised, which Spend things always do). They will have to Cancel all the Unvaults.

src/poller.rs Outdated Show resolved Hide resolved
@edouardparis edouardparis force-pushed the get-spend-transaction branch from 253b3e8 to cc23359 Compare June 28, 2022 14:00
@edouardparis edouardparis force-pushed the get-spend-transaction branch from fc9442a to 2898996 Compare June 30, 2022 14:43
| `value` | integer | Value of the vault in satoshis |
| `deposit_outpoint` | string | Deposit outpoint of the vault |
| `unvault_tx` | string | Psbt of the unvault transaction of the vault |
| `candidate_tx` | string or null | Hex encoded transaction spending the vault, null if the watchtower did not retrieve it from coordinator |
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or base64 ?

@edouardparis edouardparis force-pushed the get-spend-transaction branch from 669a235 to 75d7793 Compare July 7, 2022 11:03
@edouardparis edouardparis force-pushed the get-spend-transaction branch from 75d7793 to e819759 Compare July 7, 2022 12:08
@edouardparis edouardparis requested a review from darosior July 7, 2022 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fetch the Spend transaction from the Coordinator, apply Spend policies
2 participants