Bitcoin Forum
March 28, 2024, 08:43:37 PM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Signing multisig transactions for electrum wallets  (Read 2357 times)
fbueller (OP)
Sr. Member
****
Offline Offline

Activity: 412
Merit: 265


View Profile
May 16, 2014, 05:14:40 PM
 #1

I've posted this in Project Development, but figured I may as well mention it here too.

I've written a PHP CLI script for signing multisig transactions, where the private keys are in an electrum wallet. Essentially the program prompts for a redeem script, raw transaction, JSON inputs if not supplied with the raw transaction (will offer to download them if you're online), and the electrum seed.

It then generates the first 30 public keys, checks if they were in the redeemscript, and generates any private keys if that's the case. It'll prompt if you want to try load the next 30, in case you're using more from this wallet. Then it just signs wherever it can and spits the result out.

I expect plenty of reasonable suspicion around a program which asks for seeds. Any concerns, the code's on github, and I'd love any feedback have about it. Hopefully someone finds this as useful as I do.

Code:
git clone https://github.com/Bit-Wasp/bitcoin-lib-php.git
cd bitcoin-lib-php/examples
php electrum_sign_multisig.php

The following is output from a transaction I just broadcast, I'm using this tool to sign transactions as an administrator on Bitwasp, since it derives keys from electrum for orders.
The raw transaction I pasted was partially signed using Bitcoin Core.
Code:
afk@jalapeno:~/git/bitcoin-lib-php/examples$ php electrum_sign_multisig.php
Enter redeem script: 522103793882c7025f32d2bbdd07f145fbf16fea83df6352ef42e38d4137f5a24975cc2102e67b93adc52dfdfa181311610244d98811ecd0a26be65a10b720f417cb8997904104492368cd25892f3a6a618ce750e28f4f1c3c9fec4abd67287cb6450356abc0cfef3358cd39b5390c7ea7e053358c97463741d22d1e9cd2c2d3a528d137fb6bf553ae
Learned about 2 of 3 address: 33XfrAfvrihcpatpn2yw8A8mw2ARjhe3Ea

Enter a raw transaction to sign: 01000000011aa43825f69cf30167be512b03cf7a7e2c30e51e87202eb7157a658a2d8f77e000000000d40047304402201791527e0c93c0386d362f0bbf5223ffe993fbb820f8750541305a54622b4347022001f8df8c13ab07be2885f152a7425efefaf0ea3ef368d95936bac41af3a88c1e014c89522103793882c7025f32d2bbdd07f145fbf16fea83df6352ef42e38d4137f5a24975cc2102e67b93adc52dfdfa181311610244d98811ecd0a26be65a10b720f417cb8997904104492368cd25892f3a6a618ce750e28f4f1c3c9fec4abd67287cb6450356abc0cfef3358cd39b5390c7ea7e053358c97463741d22d1e9cd2c2d3a528d137fb6bf553aeffffffff02d8270000000000001976a914264cfe558e3cd797bdf83dfe72e03484f4e10a2288ac584d0000000000001976a914313513a1d8c37c0b19f9474bce59ed8c2c14839088ac00000000

Enter input data as JSON string (or 'x' to load this from webbtc.com): x

Enter electrum seed or mnemonic: ask cheat plain escape trouble moon grasp carve brown plant heart thought
Seed accepted.

Trying keys 0 to 30
Have 1 private keys we can sign with. Look for more? (y/n) y
Trying keys 30 to 60
Have 1 private keys we can sign with. Look for more? (y/n) n
Array
(
    [hex] => 01000000011aa43825f69cf30167be512b03cf7a7e2c30e51e87202eb7157a658a2d8f77e000000000fd1d010047304402201791527e0c93c0386d362f0bbf5223ffe993fbb820f8750541305a54622b4347022001f8df8c13ab07be2885f152a7425efefaf0ea3ef368d95936bac41af3a88c1e014830450221008206c3e8b5c53510c2716e78b6b1d36d882f6189752d51e6cdc722b1dacffb60022023954fe8620a798277fbef463d773ff9a8c317857ce5cb7af15647193f67cd97014c89522103793882c7025f32d2bbdd07f145fbf16fea83df6352ef42e38d4137f5a24975cc2102e67b93adc52dfdfa181311610244d98811ecd0a26be65a10b720f417cb8997904104492368cd25892f3a6a618ce750e28f4f1c3c9fec4abd67287cb6450356abc0cfef3358cd39b5390c7ea7e053358c97463741d22d1e9cd2c2d3a528d137fb6bf553aeffffffff02d8270000000000001976a914264cfe558e3cd797bdf83dfe72e03484f4e10a2288ac584d0000000000001976a914313513a1d8c37c0b19f9474bce59ed8c2c14839088ac00000000
    [complete] => true
)

afk@jalapeno:~/git/bitcoin-lib-php/examples$ bitcoind sendrawtransaction 01000000011aa43825f69cf30167be512b03cf7a7e2c30e51e87202eb7157a658a2d8f77e000000000fd1d010047304402201791527e0c93c0386d362f0bbf5223ffe993fbb820f8750541305a54622b4347022001f8df8c13ab07be2885f152a7425efefaf0ea3ef368d95936bac41af3a88c1e014830450221008206c3e8b5c53510c2716e78b6b1d36d882f6189752d51e6cdc722b1dacffb60022023954fe8620a798277fbef463d773ff9a8c317857ce5cb7af15647193f67cd97014c89522103793882c7025f32d2bbdd07f145fbf16fea83df6352ef42e38d4137f5a24975cc2102e67b93adc52dfdfa181311610244d98811ecd0a26be65a10b720f417cb8997904104492368cd25892f3a6a618ce750e28f4f1c3c9fec4abd67287cb6450356abc0cfef3358cd39b5390c7ea7e053358c97463741d22d1e9cd2c2d3a528d137fb6bf553aeffffffff02d8270000000000001976a914264cfe558e3cd797bdf83dfe72e03484f4e10a2288ac584d0000000000001976a914313513a1d8c37c0b19f9474bce59ed8c2c14839088ac00000000
98af6ce3abafbfe4fac55cdde6a7482945038af0f3b4ca67e6fe9973fc08f697


Bitwasp Developer.
1711658617
Hero Member
*
Offline Offline

Posts: 1711658617

View Profile Personal Message (Offline)

Ignore
1711658617
Reply with quote  #2

1711658617
Report to moderator
Bitcoin addresses contain a checksum, so it is very unlikely that mistyping an address will cause you to lose money.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
jonald_fyookball
Legendary
*
Offline Offline

Activity: 1302
Merit: 1004


Core dev leaves me neg feedback #abuse #political


View Profile
May 18, 2014, 01:38:37 AM
 #2

What multisig functionality does electrum currently have?

fbueller (OP)
Sr. Member
****
Offline Offline

Activity: 412
Merit: 265


View Profile
May 18, 2014, 08:53:38 AM
 #3

None really, it supports sending funds to script hash addresses, but can't sign redeeming transactions. That's why I needed a script to do it.

Bitwasp Developer.
ViperGeek
Newbie
*
Offline Offline

Activity: 9
Merit: 0



View Profile
July 28, 2014, 10:59:23 PM
 #4

Interesting.  I may have to give it a whirl.

I was trying to use the Electrum console (from the GUI) to follow these instructions:

https://gist.github.com/atweiden/7272732

but got bogged down around about Step 3 (signing and withdrawing).

- Dave
mktx
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
December 14, 2014, 01:20:51 AM
 #5

Anything ever come of this? I'm currently running into the same issue. Around Step 3 it all falls apart. I just can't seem to get the syntax correct or something.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!