• Forum has been upgraded, all links, images, etc are as they were. Please see Official Announcements for more information

Quick and very dirty Multisig UI in python/QT - new unimproved PerVer!

thelonecrouton

Well-known member
Foundation Member
For what it's worth here's my little experiment in what a multisig UI might look like. It's written in python and uses QT, and was more an exercise in helping me understand multisig transactions than anything else.

There are 3 parties (usually) involved, so I gave them a tab each!
2naiooi.png

2lshemg.png

4hz7r9.png


All three push their first button up top, generating a new address/pubkey/privkey!
281anwg.png

2ytpfz4.png

1qook4.png


IRL buyer and seller would have to send their pubkeys to the arbiter, here it just happens by magic!
The arbiter can now push his/her second button and create the multisig address!
fxz51x.png


The buyer now funds the Multisig Address by pushing their second button, (I just stuck a hardcoded amount in there for test purposes), the seller sends the goods, buyer is happy and sends the seller their privkey by pushing their third button! (Other outcomes are possible, obviously, but I'm trying to keep this as brief as possible!)
pq135.png



Seller recieves buyer privkey (or the arbiter privkey, however it happens) and now can access the DRK in the Multisig Address! Seller has what he needs from the other parties and combined with some voodoo on the original txid from the buyer can proceed!

280ljc9.png


But first they need to enter a recieving address!
11uf52s.jpg


Now they push the green button at the bottom! They get the txid of the retreival of the DRK from the MA to their specified address!
(Doesn't quite fit in the box but it's c4498e048dbb9c0599e7344fef85f22f2b13f10b5889baa825a2d87c488cef29)
ebdiqu.png


Anyway, heres a screeny of this one from the explorer, 12.345tDRK sent to mhNgkX28mVKZx88sMQHzFqTf6fGv6DdE4y via txid c4498e048dbb9c0599e7344fef85f22f2b13f10b5889baa825a2d87c488cef29!
rm4to3.png


If nothing else, I now have a handy tool for making supersecure multisig addresses!

From start to finish (or at least where I am now) was about 10 hours work, because this is not exactly my day job, and it is not yet a fully useable real world product but there's no excuse for Darkcoin not to have some kind of useable multisig UI in the official wallet!

:smile:
 
Last edited by a moderator:
If you're thinking this is all terribly complicated, well here's the alternative - this is my debugging terminal output, which includes some but by no means all of the process!

Code:
stu@stu-laptop:~/laptop-backup/python$ python ccmfv02.py
moSqfDmVnoWW3GgXFvVd4x129ECg8d5qJH
"pubkey" : "03d830ac362c8895bc42e538e955d2af66836fba53cf7eefc67325994faefcc7e0",
03d830ac362c8895bc42e538e955d2af66836fba53cf7eefc67325994faefcc7e0
cVR2UWB8UT462V5Efc1uggrM9T95qbG6KRAUBG9NvrwYHRkhSbXv
mhLmvTCVSzvciLoYpvt58rpegECnBAK3Sb
"pubkey" : "030315854da8a231ce1491b73f0e30a7f6b7c95b977577767bbd40d9c94eb42328",
030315854da8a231ce1491b73f0e30a7f6b7c95b977577767bbd40d9c94eb42328
cPL6nBjyn3gUSRnfK8jjB3buTdcE5o7MobXYFSGHqKq6B4y7H8Xx
mwb6NvDJMmxe3FWxjcDsXFVFHUciNNEGko
"pubkey" : "036f1755abbab3ed8a49497c140dae8c6f040dc587d4075ee092ecdc59829b4ef4",
036f1755abbab3ed8a49497c140dae8c6f040dc587d4075ee092ecdc59829b4ef4
cNuaLuohPW4ssVTgt1kotxV3R5xUrWrYS5fbhL6PL8tifDRRCYCz
/home/stu/laptop-backup/downloads/darkcoin-0.10.12.32-linux/bin/64/darkcoind createmultisig 2 '["03d830ac362c8895bc42e538e955d2af66836fba53cf7eefc67325994faefcc7e0", "030315854da8a231ce1491b73f0e30a7f6b7c95b977577767bbd40d9c94eb42328", "036f1755abbab3ed8a49497c140dae8c6f040dc587d4075ee092ecdc59829b4ef4"]'
{
  "address" : "2MxHAAsFPZSxcHKqXf9TtMXSskfnucxW4WL",
  "redeemScript" : "522103d830ac362c8895bc42e538e955d2af66836fba53cf7eefc67325994faefcc7e021030315854da8a231ce1491b73f0e30a7f6b7c95b977577767bbd40d9c94eb4232821036f1755abbab3ed8a49497c140dae8c6f040dc587d4075ee092ecdc59829b4ef453ae"
}

"address" : "2MxHAAsFPZSxcHKqXf9TtMXSskfnucxW4WL",
2MxHAAsFPZSxcHKqXf9TtMXSskfnucxW4WL
"redeemScript" : "522103d830ac362c8895bc42e538e955d2af66836fba53cf7eefc67325994faefcc7e021030315854da8a231ce1491b73f0e30a7f6b7c95b977577767bbd40d9c94eb4232821036f1755abbab3ed8a49497c140dae8c6f040dc587d4075ee092ecdc59829b4ef453ae"
522103d830ac362c8895bc42e538e955d2af66836fba53cf7eefc67325994faefcc7e021030315854da8a231ce1491b73f0e30a7f6b7c95b977577767bbd40d9c94eb4232821036f1755abbab3ed8a49497c140dae8c6f040dc587d4075ee092ecdc59829b4ef453ae
2MxHAAsFPZSxcHKqXf9TtMXSskfnucxW4WL
5512163e9cb20df0d73dde696c032b895b30f975adecb864afea60a69b485f09
/home/stu/laptop-backup/downloads/darkcoin-0.10.12.32-linux/bin/64/darkcoind getrawtransaction 5512163e9cb20df0d73dde696c032b895b30f975adecb864afea60a69b485f09 1
{
  "hex" : "01000000013854a36a66ca423da657a6f336ea9a0edefcd2529fea6ab4616f887eedf4dfda000000006c493046022100870a1fd46761faecf432d81d0d015073cafaf4640145c99661b12dc63b717715022100c7eb7584c23a21d86335b7e914f66e921a65bf0c8dc820b675a7a884ea8c8467012103b5594c367e1a798e4a0a7792e26a2f46d4fe65020201473581a1ccc73dcb921fffffffff02a0f994490000000017a9143736462d43ed495494a0b9e9df766191a8c842e38740415142130000001976a914246c2230918b1d4e6389f5d1aa0a89f72ca710d888ac00000000",
  "txid" : "5512163e9cb20df0d73dde696c032b895b30f975adecb864afea60a69b485f09",
  "version" : 1,
  "locktime" : 0,
  "vin" : [
  {
  "txid" : "dadff4ed7e886f61b46aea9f52d2fcde0e9aea36f3a657a63d42ca666aa35438",
  "vout" : 0,
  "scriptSig" : {
  "asm" : "3046022100870a1fd46761faecf432d81d0d015073cafaf4640145c99661b12dc63b717715022100c7eb7584c23a21d86335b7e914f66e921a65bf0c8dc820b675a7a884ea8c846701 03b5594c367e1a798e4a0a7792e26a2f46d4fe65020201473581a1ccc73dcb921f",
  "hex" : "493046022100870a1fd46761faecf432d81d0d015073cafaf4640145c99661b12dc63b717715022100c7eb7584c23a21d86335b7e914f66e921a65bf0c8dc820b675a7a884ea8c8467012103b5594c367e1a798e4a0a7792e26a2f46d4fe65020201473581a1ccc73dcb921f"
  },
  "sequence" : 4294967295
  }
  ],
  "vout" : [
  {
  "value" : 12.34500000,
  "n" : 0,
  "scriptPubKey" : {
  "asm" : "OP_HASH160 3736462d43ed495494a0b9e9df766191a8c842e3 OP_EQUAL",
  "hex" : "a9143736462d43ed495494a0b9e9df766191a8c842e387",
  "reqSigs" : 1,
  "type" : "scripthash",
  "addresses" : [
  "2MxHAAsFPZSxcHKqXf9TtMXSskfnucxW4WL"
  ]
  }
  },
  {
  "value" : 827.17000000,
  "n" : 1,
  "scriptPubKey" : {
  "asm" : "OP_DUP OP_HASH160 246c2230918b1d4e6389f5d1aa0a89f72ca710d8 OP_EQUALVERIFY OP_CHECKSIG",
  "hex" : "76a914246c2230918b1d4e6389f5d1aa0a89f72ca710d888ac",
  "reqSigs" : 1,
  "type" : "pubkeyhash",
  "addresses" : [
  "miqYADBqqozb7nw8wt96B85VPKjZAq7oxQ"
  ]
  }
  }
  ]
}

<generator object <genexpr> at 0x7fb6e0ca6b40>
26 "2MxHAAsFPZSxcHKqXf9TtMXSskfnucxW4WL"
"hex" : "a9143736462d43ed495494a0b9e9df766191a8c842e387",
a9143736462d43ed495494a0b9e9df766191a8c842e387
"n" : 0,
0
"value" : 12.34500000,
12.34500000
/home/stu/laptop-backup/downloads/darkcoin-0.10.12.32-linux/bin/64/darkcoind createrawtransaction '[{"txid":"5512163e9cb20df0d73dde696c032b895b30f975adecb864afea60a69b485f09","vout":0,"scriptPubKey":"a9143736462d43ed495494a0b9e9df766191a8c842e387","redeemScript":"522103d830ac362c8895bc42e538e955d2af66836fba53cf7eefc67325994faefcc7e021030315854da8a231ce1491b73f0e30a7f6b7c95b977577767bbd40d9c94eb4232821036f1755abbab3ed8a49497c140dae8c6f040dc587d4075ee092ecdc59829b4ef453ae"}]' '{"mhNgkX28mVKZx88sMQHzFqTf6fGv6DdE4y":12.34500000}'
/home/stu/laptop-backup/downloads/darkcoin-0.10.12.32-linux/bin/64/darkcoind signrawtransaction '0100000001095f489ba660eaaf64b8ecad75f9305b892b036c69de3dd7f00db29c3e1612550000000000ffffffff01a0f99449000000001976a914145ff2d97d999fe8b18bb0365e14cc181231530788ac00000000' '[{"txid":"5512163e9cb20df0d73dde696c032b895b30f975adecb864afea60a69b485f09","vout":0,"scriptPubKey":"a9143736462d43ed495494a0b9e9df766191a8c842e387","redeemScript":"522103d830ac362c8895bc42e538e955d2af66836fba53cf7eefc67325994faefcc7e021030315854da8a231ce1491b73f0e30a7f6b7c95b977577767bbd40d9c94eb4232821036f1755abbab3ed8a49497c140dae8c6f040dc587d4075ee092ecdc59829b4ef453ae"}]' '["cNuaLuohPW4ssVTgt1kotxV3R5xUrWrYS5fbhL6PL8tifDRRCYCz"]'
{
  "hex" : "0100000001095f489ba660eaaf64b8ecad75f9305b892b036c69de3dd7f00db29c3e16125500000000b4004730440220121fb035d04d36a4108861388c10cce386a2aa2d1b5b6c876c3441dd1ef0b23102204b2bdffe91b7fedc95b98648bfbe28699deeba42b7aa026bb1b9d9da309a8513014c69522103d830ac362c8895bc42e538e955d2af66836fba53cf7eefc67325994faefcc7e021030315854da8a231ce1491b73f0e30a7f6b7c95b977577767bbd40d9c94eb4232821036f1755abbab3ed8a49497c140dae8c6f040dc587d4075ee092ecdc59829b4ef453aeffffffff01a0f99449000000001976a914145ff2d97d999fe8b18bb0365e14cc181231530788ac00000000",
  "complete" : false
}

0100000001095f489ba660eaaf64b8ecad75f9305b892b036c69de3dd7f00db29c3e16125500000000b4004730440220121fb035d04d36a4108861388c10cce386a2aa2d1b5b6c876c3441dd1ef0b23102204b2bdffe91b7fedc95b98648bfbe28699deeba42b7aa026bb1b9d9da309a8513014c69522103d830ac362c8895bc42e538e955d2af66836fba53cf7eefc67325994faefcc7e021030315854da8a231ce1491b73f0e30a7f6b7c95b977577767bbd40d9c94eb4232821036f1755abbab3ed8a49497c140dae8c6f040dc587d4075ee092ecdc59829b4ef453aeffffffff01a0f99449000000001976a914145ff2d97d999fe8b18bb0365e14cc181231530788ac00000000
/home/stu/laptop-backup/downloads/darkcoin-0.10.12.32-linux/bin/64/darkcoind signrawtransaction '0100000001095f489ba660eaaf64b8ecad75f9305b892b036c69de3dd7f00db29c3e16125500000000b4004730440220121fb035d04d36a4108861388c10cce386a2aa2d1b5b6c876c3441dd1ef0b23102204b2bdffe91b7fedc95b98648bfbe28699deeba42b7aa026bb1b9d9da309a8513014c69522103d830ac362c8895bc42e538e955d2af66836fba53cf7eefc67325994faefcc7e021030315854da8a231ce1491b73f0e30a7f6b7c95b977577767bbd40d9c94eb4232821036f1755abbab3ed8a49497c140dae8c6f040dc587d4075ee092ecdc59829b4ef453aeffffffff01a0f99449000000001976a914145ff2d97d999fe8b18bb0365e14cc181231530788ac00000000' '[{"txid":"5512163e9cb20df0d73dde696c032b895b30f975adecb864afea60a69b485f09","vout":0,"scriptPubKey":"a9143736462d43ed495494a0b9e9df766191a8c842e387","redeemScript":"522103d830ac362c8895bc42e538e955d2af66836fba53cf7eefc67325994faefcc7e021030315854da8a231ce1491b73f0e30a7f6b7c95b977577767bbd40d9c94eb4232821036f1755abbab3ed8a49497c140dae8c6f040dc587d4075ee092ecdc59829b4ef453ae"}]' '["cPL6nBjyn3gUSRnfK8jjB3buTdcE5o7MobXYFSGHqKq6B4y7H8Xx"]'
{
  "hex" : "0100000001095f489ba660eaaf64b8ecad75f9305b892b036c69de3dd7f00db29c3e16125500000000fc00473044022048004f07307e7cfe745980fa85dbbf6bdbce779e8945b4c2b6d511821bbc2bef02203921744ae62d1205b0f86dfdb6c656775534557914fb16936c757385cfa9295f014730440220121fb035d04d36a4108861388c10cce386a2aa2d1b5b6c876c3441dd1ef0b23102204b2bdffe91b7fedc95b98648bfbe28699deeba42b7aa026bb1b9d9da309a8513014c69522103d830ac362c8895bc42e538e955d2af66836fba53cf7eefc67325994faefcc7e021030315854da8a231ce1491b73f0e30a7f6b7c95b977577767bbd40d9c94eb4232821036f1755abbab3ed8a49497c140dae8c6f040dc587d4075ee092ecdc59829b4ef453aeffffffff01a0f99449000000001976a914145ff2d97d999fe8b18bb0365e14cc181231530788ac00000000",
  "complete" : true
}

0100000001095f489ba660eaaf64b8ecad75f9305b892b036c69de3dd7f00db29c3e16125500000000fc00473044022048004f07307e7cfe745980fa85dbbf6bdbce779e8945b4c2b6d511821bbc2bef02203921744ae62d1205b0f86dfdb6c656775534557914fb16936c757385cfa9295f014730440220121fb035d04d36a4108861388c10cce386a2aa2d1b5b6c876c3441dd1ef0b23102204b2bdffe91b7fedc95b98648bfbe28699deeba42b7aa026bb1b9d9da309a8513014c69522103d830ac362c8895bc42e538e955d2af66836fba53cf7eefc67325994faefcc7e021030315854da8a231ce1491b73f0e30a7f6b7c95b977577767bbd40d9c94eb4232821036f1755abbab3ed8a49497c140dae8c6f040dc587d4075ee092ecdc59829b4ef453aeffffffff01a0f99449000000001976a914145ff2d97d999fe8b18bb0365e14cc181231530788ac00000000
c4498e048dbb9c0599e7344fef85f22f2b13f10b5889baa825a2d87c488cef29
 
Good stuff - but by definition private keys should not be shared at all. Each party should only share the signed raw tx, not the key to do the actual signing.
I was going with a completely disposable address/pubkey/privkey for each party for the transaction - but yes it would be safer to do it as you say in case the address ever got re-used,
 
I'll un-hardcode the darkcoind path it uses and the send amount (you can fund the MA from any wallet, doesn't have to be done from this app) and post the script later today if I get time so people can play with it themselves.
 
Rearranged the UI so the process is all on the same page, did as flare rightly suggested, no privkeys are passed just signed txes, you can now enter/load/save your own darkcoind path, and nearly everything that happens is displayed in a console inside the UI so you can follow events.

There is no graceful error handling, you need to push the buttons in the right order - I have helpfully numbered them!

The code is horribly redundant, a lot of the functions are nearly identical but I haven't had time today to address this.

Haven't had time to put it on github either, so you can grab it here: http://s000.tinyupload.com/?file_id=66868132891915967547

No promises about it working on Win or OSX. :eek:

2rz450k.png


Now zipped with drk.ico!
 
Last edited by a moderator:
Make the output region a frame and either reload only that frame or use JavaScript DOM manipulations to update the page without reloading everything.
A frame I can manage, no idea what that other voodoo you mentioned is...

I'm sure I could have this finished in under an hour... if only I knew what I was doing... :confused:
 
If you've never done JavaScript it'll need some time to get used to it.

This site shows what I was talking about: http://referencedesigner.com/tutorials/js/js_41.php
That... doesn't actually look too horrible, thanks! I'd have to have the js call the python function, then pass the output back upchain though, I'm not rewriting the whole lot in js. :grin:

edit: javascript DOM manipulation voodoo implemented. :cool:
 
Last edited by a moderator:
I'm not rewriting the whole lot in js. :grin:

That's actually what JavaScript was designed for: static content in HTML, dynamic content in JavaScript.

Unfortunately today every wannabee-web-developer does almost everything in JavaScript (or uses tools that create tons of JavaScript, which is even worse).
 
Back
Top