revault / revaultd

The "wallet" daemon for participants under the Revault architecture
BSD 3-Clause "New" or "Revised" License
48 stars 21 forks source link

Manual CPFP #413

Open Zshan0 opened 2 years ago

Zshan0 commented 2 years ago

This PR is to maintain code corresponding to the RFC that is being discussed for the addition of manual CPFP command as a JSONRPC API in revaultd. RFC is present here. #411 is the corresponding milestone tracker

Zshan0 commented 2 years ago

A simple test for cpfp has been written, I'm not sure what other kinds of tests are required. Please let me know

Zshan0 commented 2 years ago

I am unable to figure out a simple way of testing CPFPing multiple SpendTransactions, if there is a simpler scheme that I can follow please let me know.

The Current CPFP is able to terminate invalid txid with an RpcError but it fails to terminate for txid that is valid but is unknown, rather than relying on direct database functions to fetch the given txid and then throw an error if it is unable to find, is there a function that is specifically designed to check if a txid exists in the database that I can use for sanity checking before passing it further?

darosior commented 2 years ago

Is this ready for review?

darosior commented 2 years ago

Untested, but i think you can use this to externally fund the CPFP wallet:

diff --git a/tests/test_framework/revault_network.py b/tests/test_framework/revault_network.py
index 0a840f8..8dfa68e 100644
--- a/tests/test_framework/revault_network.py
+++ b/tests/test_framework/revault_network.py
@@ -3,6 +3,7 @@ import logging
 import os
 import random

+from bip380.descriptors import Descriptor
 from ephemeral_port_reserve import reserve
 from nacl.public import PrivateKey as Curve25519Private
 from test_framework import serializations
@@ -541,6 +542,13 @@ class RevaultNetwork:

         return created_vaults

+    def fund_cpfp(self, amount):
+        """Send a coin worth this value to the CPFP descriptor"""
+        der_desc = Descriptor.from_str(str(self.cpfp_desc))
+        der_desc.derive(0)
+        decoded = self.bitcoind.rpc.decodescript(der_desc.script_pubkey.hex())
+        self.bitcoind.rpc.sendtoaddress(decoded["address"], amount)
+
     def secure_vault(self, vault):
         """Make all stakeholders share signatures for all revocation txs"""
         deposit = f"{vault['txid']}:{vault['vout']}"
darosior commented 2 years ago

This should fix the unit tests CI, and also fixes the configuration of the functional tests CI (thanks for reporting it!): https://github.com/revault/revaultd/pull/423.