This is an interesting project.
From what I understand, you require the following:
- The ability to receive bitcoins to a certain address.
- Once the bitcoins are received and confirmed, they
should be split into predetermined percentages and
then distributed to the involved parties.
Further, I understand you have:
- Access to a host where you could run a server of your chosing.
- The desire to run it on your own hosted setup.
Since you are security conscious,
this might be relevant. (TL;DR: is "Don't use virtual servers where you share the same metal with other customers.")
In that regard, using exclusive hw (dedicated server in a data-center), or your own hw at your own physical location might be the best. However, the practical danger of such an attack being successful, I assume is very low, so it might be an acceptable risk.
Anyhow, on a more technical level, this is how the issues could be solved:
- A server running a linux OS with at least bitcoin core running, using mysql would be a good addition.
- Incoming bitcoin transactions are detected, and relevant info is written to a database. (walletnotify and blocknotify events are used)
- Once the transaction is confirmed, it's ready to be paid out to the parties involved, this could be done with a cronjob or a daemon process.
- The configuration could be done manually over ssh on the server in text-files, or in a database, or an admin-interface could've been made to facilitate this to avoid having to deal with the config-files directly.
A plain text config file could look something like this:
[SPLITPAY]
RECEIVEADDRESS = 16Do2HCJXDDoSQnjkqB7Kh2MkPsjnCugf5
USER1 =
[email protected]PAYADR_USER1 = 1AFZZqP3zHYuuc7ULvd7uy15RziFNYRdgu
SHARE_USER1 = 40
USER2 =
[email protected]PAYADR_USER2 = 1BFZZqP3zHYuuc7ULvd7uy15RziFNYRdgu
SHARE_USER2 = 40
USER3 =
[email protected]PAYADR_USER3 = 1CFZZqP3zHYuuc7ULvd7uy15RziFNYRdgu
SHARE_USER3 = 20
Once coins are received at 16Do2HCJXDDoSQnjkqB7Kh2MkPsjnCugf5, the amount will be split into the shares, 40,40,20 respectively. Addresses for users 1,2 and 3 would receive their coins once incoming transactions to RECEIVEADDRESS is confirmed (usually 1 confirmation is required in bitcoin core, before funds could be forwarded)
The users would probably be interested in some easy access to stats about the transactions, so a webpage displaying said stats could be a good idea - this would be locked down to only be displayable to the relevant parties. It would also be possible to have simple settings pages for each user, and an administrative interface.
Once a solution like this is up and running, the maintenance is very low. Security upgrades for the OS, and the occasional update of the bitcoin core software could be a good idea.
The benefit of running it on a system you control yourself is increased security, as the risk of the operator running the 3rd party service you depend on, or hackers attacking that service and gaining access will now be eliminated. If you run a hardened system, the chance of any security breach is rather low. It would be possible to for example only connect to one or a few trusted nodes, to minimize the networks knowledge of your node. If you also opted to close down all irrelevant services and close all irrelevant ports, it would not be easy to pinpoint your running system for a random attacker and it would also be very hard to compromise it. Ssh-access could further be limited to admins with the correct ssh-keys.
I'm working with stuff like this every day, so in the event you'd like me to help out, get in touch and we'd discuss the issues further. It should not take long to get a working version of this deployed. Naturally a working demo using bitcoin testnet would be provided as soon as possible to demonstrate that the functionality actually works as promised, also written elaborate instructions as to how to use the system would be possible to provide. Since security is an issue, I propose that source code be provided with good documentation, so the code could be reviewed by cr1776 or any other interested party and even compiled directly on the relevant server. Hence, there would be no need to put any unreasonable trust in a 3rd party, not even in a developer like me. As this is not very sophisticated software, with good documentation, even a non-coder should be able to understand it and check the validity of the system. In addition, bitcoin core used should be verified against downloaded sha256-signatures signed by core dev. This cr1776 could do himself to verify the process is accurate and legit.
Usage could be as simple as this:
1. Edit the config file as shown earlier in this post.
2. Start daemon and read default config file:
./paydist start
3. Show daemon status:
(This could show for instance the active config loaded, and other stats - running time and/or other stats for example)
./paydist status
4. Shut down daemon
./paydist stop
By saving relevant data to a database table or logfile it would be easy later on to use that data to provide various stats and reports if so desired.
./paydist stop
Note: Since running a webserver on the same server as a bitcoin core daemon could be a security risk, it would be fully possible to only provide admin access over ssh, and then provide the stats-pages on a separate web-server that gets info directly from the blockchain.
I would also be available in the future, if additions to the system would be requested.