How to generate a 2-3 multisig Anoncoin address

To generate a new 2-3 multisig address

  • At first, the three clients make each a new address pair, keep for themselves their private key and give the pubkey to the two other persons.

In the ANC-qt debug console type the following (an example is shown):

getnewaddress
→ Aa8TraYPKPwGCaS8ftxayWNe8GtfPvN1j8
validateaddress AexjXQLZkPzYk29gANfSmCNzCegw4czX3m

→ {
    “isvalid” : true,
    “address” : “AexjXQLZkPzYk29gANfSmCNzCegw4czX3m”,
    “ismine” : true,
    “iswatchonly” : false,
    “isscript” : false,
    “pubkey” : “0334e8a5998704b0371233e97a2fbf0f3cd0b66894b6644b2eadf466e27959f274”,
    “iscompressed” : true,
    “account” : ""
}
dumpprivkey AexjXQLZkPzYk29gANfSmCNzCegw4czX3m

→ PR*******privatekeyofthefirstuserkeepsecure!*******Cm

The same is done by the two other persons who want to sign the multisig address.

Each keep securely their privatekey

Each give to the other two persons their pubkey

  • The 2-3 multisig is then generated by each user with the three corresponding pubkey, 2 are necessary to spend in this case:
createmultisig 2 '[“029cd9c7df6ba11f173f3d0b9db8f6d228c64ad9c76effb4a334f6ad401fff6324”,“0334e8a5998704b0371233e97a2fbf0f3cd0b66894b6644b2eadf466e27959f274”,“026e4494155b7706ba1fdbc999c8124c03bc8b06e7c9c2f31efc60d2d205990dea”]'

→ 
{
    “address” : “3Q29ysL3DNsnyybhy8ErfeqfPTDhvgUN62”,
    **“redeemScript” : “5221029cd9c7df6ba11f173f3d0b9db8f6d228c64ad9c76effb4a334f6ad401fff6324210334e8a5998704b0371233e97a2fbf0f3cd0b66894b6644b2eadf466e27959f27421026e4494155b7706ba1fdbc999c8124c03bc8b06e7c9c2f31efc60d2d205990dea53ae”**
}

The redeemScript is very important and shall be kept by all participants, without it funds cannot be recovered from the multisig address!

NB: the order of the pubkeys is important! (There is obtained another address and redeemscript if the pubkeys are permuted)

Send some coins to the multisig address

  • Easiest way is to send the coins using the wallet and get the Transaction ID by right clicking on the transaction to show the transaction details and then copy the TXID.
  • Otherwise it can be done by using the debug console:

In the ANC-qt debug console type the following:

sendtoaddress “3Q29ysL3DNsnyybhy8ErfeqfPTDhvgUN62” 2.5

→ 6181daa32d44a1e1bfb3206a3f5726e0dbb045d1fbd32ec4eaf0684b391d9ae4

It reply the TXID. If needed, this can be recovered later using listtransactions. The TXID is very important and shall be kept.

listtransactions * 1 0

→ 
[
    {
        “account” : "",
        “address” : “3Q29ysL3DNsnyybhy8ErfeqfPTDhvgUN62”,
        “category” : “send”,
        “amount” : -2.50000000,
        “fee” : 0.00000000,
        “confirmations” : 0,
        “txid” : “6181daa32d44a1e1bfb3206a3f5726e0dbb045d1fbd32ec4eaf0684b391d9ae4”,
        “walletconflicts” : [
        ],
        “time” : 1423172987,
        “timereceived” : 1423172987
    }
]

To spend all coins from the multisig address to a new address

  • If you have the TXID, using the console :

Put txindex=1 in anoncoin.conf, launch anoncoin-qt –reindex once to reindex then type in the console

getrawtransaction 6181daa32d44a1e1bfb3206a3f5726e0dbb045d1fbd32ec4eaf0684b391d9ae4

→ 01000000018a5e64909e1142aee737b8d64f57b1f0985572079c1d10881098fba0f5d9cd9d000000004847304402205c6ef4bb061789f4ea9b393272853948a558f1811d549c62b3667361201b8422022028ca09ea0403801b6794a0d2b69f836e352774a7c28c2208ae98613eff85bcc901ffffffff0180b2e60e0000000017a914f4f1657c98e44837486c97857fa12afc7daefc888700000000
decoderawtransaction 01000000018a5e64909e1142aee737b8d64f57b1f0985572079c1d10881098fba0f5d9cd9d000000004847304402205c6ef4bb061789f4ea9b393272853948a558f1811d549c62b3667361201b8422022028ca09ea0403801b6794a0d2b69f836e352774a7c28c2208ae98613eff85bcc901ffffffff0180b2e60e0000000017a914f4f1657c98e44837486c97857fa12afc7daefc888700000000

→ 
{
    **“txid” : “6181daa32d44a1e1bfb3206a3f5726e0dbb045d1fbd32ec4eaf0684b391d9ae4”,**
    “version” : 1,
    “locktime” : 0,
    “vin” : [
        {
            “txid” : “9dcdd9f5a0fb981088101d9c07725598f0b1574fd6b837e7ae42119e90645e8a”,
            “vout” : 0,
            “scriptSig” : {
                “asm” : “304402205c6ef4bb061789f4ea9b393272853948a558f1811d549c62b3667361201b8422022028ca09ea0403801b6794a0d2b69f836e352774a7c28c2208ae98613eff85bcc901”,
                “hex” : “47304402205c6ef4bb061789f4ea9b393272853948a558f1811d549c62b3667361201b8422022028ca09ea0403801b6794a0d2b69f836e352774a7c28c2208ae98613eff85bcc901”
                },
            “sequence” : 4294967295
            }
        ],
        “vout” : [
            {
            **“value” : 2.50000000,**
            **“n” : 0,**
            “scriptPubKey” : {
            “asm” : “OP_HASH160 f4f1657c98e44837486c97857fa12afc7daefc88 OP_EQUAL”,
            **“hex” : “a914f4f1657c98e44837486c97857fa12afc7daefc8887”,**
            “reqSigs” : 1,
            “type” : “scripthash”,
            “addresses” : [
            “3Q29ysL3DNsnyybhy8ErfeqfPTDhvgUN62”
            ]
        }
        }
    ]
}
  • Alternatively, if you only know the address 3Q29ysL3DNsnyybhy8ErfeqfPTDhvgUN62 and you need the TXID:

Using the ANC coin explorer, search for the address `3Q29ysL3DNsnyybhy8ErfeqfPTDhvgUN62, open the incoming transaction and get the TXID, the N and the scriptpubkey of its output:

Coinplorer (https://coinplorer.com/ANC/Transactions/6181daa32d44a1e1bfb3206a3f5726e0dbb045d1fbd32ec4eaf0684b391d9ae4)

**TXID 6181daa32d44a1e1bfb3206a3f5726e0dbb045d1fbd32ec4eaf0684b391d9ae4**
*Outputs*
**2.5 ANC** 3Q29ysL3DNsnyybhy8ErfeqfPTDhvgUN62
**N: 0**
Required sigs: 1
Type: scripthash
Script pub key (ASM): OP_HASH160 f4f1657c98e44837486c97857fa12afc7daefc88 OP_EQUAL
**Script pub key (hex): a914f4f1657c98e44837486c97857fa12afc7daefc8887**

So to spend the 2-3 multisig transaction we need as minimal data the TXID to the multisig address + redeemscript + 2 private keys out of 3.

Now that we have those data, we can generate a new ANC address that will receive the funds and proceed to the actual transaction.

  • Generate a new receiving ANC address:
Getnewaddress

→ AdevgrKr8CnxqywbwTCC2So4WgKwb9jNEE
  • Using redeemscript and the new receiving ANC address, create the unsigned raw transaction, vout must be equal to N above and for simplicity the value shall be equal to the value put in the transaction:
createrawtransaction '[{“txid”:“6181daa32d44a1e1bfb3206a3f5726e0dbb045d1fbd32ec4eaf0684b391d9ae4”,“vout”:0,“scriptPubKey”:“a914f4f1657c98e44837486c97857fa12afc7daefc8887”,“redeemScript”:“5221029cd9c7df6ba11f173f3d0b9db8f6d228c64ad9c76effb4a334f6ad401fff6324210334e8a5998704b0371233e97a2fbf0f3cd0b66894b6644b2eadf466e27959f27421026e4494155b7706ba1fdbc999c8124c03bc8b06e7c9c2f31efc60d2d205990dea53ae”}]' '{“AdevgrKr8CnxqywbwTCC2So4WgKwb9jNEE”:2.5}'

→ 0100000001e49a1d394b68f0eac42ed3fbd145b0dbe026573f6a20b3bfe1a1442da3da81610000000000ffffffff0180b2e60e000000001976a914f00264c627281ab0ef36a669ff9deeaf28f0143888ac00000000
  • Two participants can then sign the raw transaction with 2 private keys out of the 3 possible:

Participant one sign the raw transaction:

signrawtransaction “0100000001e49a1d394b68f0eac42ed3fbd145b0dbe026573f6a20b3bfe1a1442da3da81610000000000ffffffff0180b2e60e000000001976a914f00264c627281ab0ef36a669ff9deeaf28f0143888ac00000000” '[{“txid”:“6181daa32d44a1e1bfb3206a3f5726e0dbb045d1fbd32ec4eaf0684b391d9ae4”,“vout”:0,“scriptPubKey”:“a914f4f1657c98e44837486c97857fa12afc7daefc8887”,“redeemScript”:“5221029cd9c7df6ba11f173f3d0b9db8f6d228c64ad9c76effb4a334f6ad401fff6324210334e8a5998704b0371233e97a2fbf0f3cd0b66894b6644b2eadf466e27959f27421026e4494155b7706ba1fdbc999c8124c03bc8b06e7c9c2f31efc60d2d205990dea53ae”}]' '[“PR*******privatekeyofthefirstuserkeepsecure!*******Cm”]'

→ {
    “hex” :  “0100000001e49a1d394b68f0eac42ed3fbd145b0dbe026573f6a20b3bfe1a1442da3da816100000000b40047304402207b57bfe7c99fce1cc29a957f106f9e5cf389a4f1b18bf5695822e4c8f02a99f802206af8b8ffd2f2aebdb0b704837259833341beff894b17c264461d679717bc5d86014c695221029cd9c7df6ba11f173f3d0b9db8f6d228c64ad9c76effb4a334f6ad401fff6324210334e8a5998704b0371233e97a2fbf0f3cd0b66894b6644b2eadf466e27959f27421026e4494155b7706ba1fdbc999c8124c03bc8b06e7c9c2f31efc60d2d205990dea53aeffffffff0180b2e60e000000001976a914f00264c627281ab0ef36a669ff9deeaf28f0143888ac00000000”,
    “complete” : false
}

The second private key can now be used to finish to sign the resulting rawtransaction:

signrawtransaction “0100000001e49a1d394b68f0eac42ed3fbd145b0dbe026573f6a20b3bfe1a1442da3da816100000000b40047304402207b57bfe7c99fce1cc29a957f106f9e5cf389a4f1b18bf5695822e4c8f02a99f802206af8b8ffd2f2aebdb0b704837259833341beff894b17c264461d679717bc5d86014c695221029cd9c7df6ba11f173f3d0b9db8f6d228c64ad9c76effb4a334f6ad401fff6324210334e8a5998704b0371233e97a2fbf0f3cd0b66894b6644b2eadf466e27959f27421026e4494155b7706ba1fdbc999c8124c03bc8b06e7c9c2f31efc60d2d205990dea53aeffffffff0180b2e60e000000001976a914f00264c627281ab0ef36a669ff9deeaf28f0143888ac00000000” '[{“txid”:“6181daa32d44a1e1bfb3206a3f5726e0dbb045d1fbd32ec4eaf0684b391d9ae4”,“vout”:0,“scriptPubKey”:“a914f4f1657c98e44837486c97857fa12afc7daefc8887”,“redeemScript”:“5221029cd9c7df6ba11f173f3d0b9db8f6d228c64ad9c76effb4a334f6ad401fff6324210334e8a5998704b0371233e97a2fbf0f3cd0b66894b6644b2eadf466e27959f27421026e4494155b7706ba1fdbc999c8124c03bc8b06e7c9c2f31efc60d2d205990dea53ae”}]' '[“PA*******privatekeyoftheseconduserkeepsecure!*******Dh”]'

→ {
    “hex” : 
    “0100000001e49a1d394b68f0eac42ed3fbd145b0dbe026573f6a20b3bfe1a1442da3da816100000000fdfd0000483045022100a500d25270c9c8729fa215413476094b079faa01241f2a3a26f0e9d4b53d73870220725b930ae1de55cb40dae229e2f3f446e60c94da3afc907c03a4f831b6bd82e40147304402207b57bfe7c99fce1cc29a957f106f9e5cf389a4f1b18bf5695822e4c8f02a99f802206af8b8ffd2f2aebdb0b704837259833341beff894b17c264461d679717bc5d86014c695221029cd9c7df6ba11f173f3d0b9db8f6d228c64ad9c76effb4a334f6ad401fff6324210334e8a5998704b0371233e97a2fbf0f3cd0b66894b6644b2eadf466e27959f27421026e4494155b7706ba1fdbc999c8124c03bc8b06e7c9c2f31efc60d2d205990dea53aeffffffff0180b2e60e000000001976a914f00264c627281ab0ef36a669ff9deeaf28f0143888ac00000000”
    “complete” : true
}

The status would be “complete” : false if the private keys entered are less than the private keys required.

  • Send and broadcast the raw transaction (must be connected to the network)
sendrawtransaction 0100000001e49a1d394b68f0eac42ed3fbd145b0dbe026573f6a20b3bfe1a1442da3da816100000000fdfd0000483045022100a500d25270c9c8729fa215413476094b079faa01241f2a3a26f0e9d4b53d73870220725b930ae1de55cb40dae229e2f3f446e60c94da3afc907c03a4f831b6bd82e40147304402207b57bfe7c99fce1cc29a957f106f9e5cf389a4f1b18bf5695822e4c8f02a99f802206af8b8ffd2f2aebdb0b704837259833341beff894b17c264461d679717bc5d86014c695221029cd9c7df6ba11f173f3d0b9db8f6d228c64ad9c76effb4a334f6ad401fff6324210334e8a5998704b0371233e97a2fbf0f3cd0b66894b6644b2eadf466e27959f27421026e4494155b7706ba1fdbc999c8124c03bc8b06e7c9c2f31efc60d2d205990dea53aeffffffff0180b2e60e000000001976a914f00264c627281ab0ef36a669ff9deeaf28f0143888ac00000000

→ c5e2bcf354d29616869284615806e0e0efa5f1b6e80cc8ce943161f46dd6df09

This is the TXID of the spent transaction from the address 3Q29ysL3DNsnyybhy8ErfeqfPTDhvgUN62. The user owning AdevgrKr8CnxqywbwTCC2So4WgKwb9jNEE will receive 2.5 ANC.

WARNING: Using this method, always spend all the fund from the multisig address in one transaction only, otherwise the excess fund will be donated back to the miners!