# I made a script to automate protect coins procedure

**URL:** <https://forum.zcashcommunity.com/t/i-made-a-script-to-automate-protect-coins-procedure/501>\
**Category:** Technical Support\
**Created:** [April 11, 2016, 7:33am UTC](https://forum.zcashcommunity.com/t/i-made-a-script-to-automate-protect-coins-procedure/501 "2016-04-11T07:33:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![danda](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@danda](https://forum.zcashcommunity.com/u/danda)\
**Post date:** [April 11, 2016, 7:33am UTC](https://forum.zcashcommunity.com/t/i-made-a-script-to-automate-protect-coins-procedure/501/1 "2016-04-11T07:33:11Z")

</div>

FIrst time zcash user here. I was following the [Public Alpha Guide](https://github.com/zcash/zcash/wiki/Public-Alpha-Guide) and there were a lot of steps so I made a little script to automate things. maybe it can be useful for someone.

This script does the protect your coins portion of the guide, but not (yet) the sending.

It can protect either: first, last, or all utxo. or a comma seperated list of txid.

By default it shows all commands executed and also all json results.

# Usage:

$ ./protect\_coins.php

```
protect_coins.php --unspent=<arg>

This script makes public funds (utxo) into private funds.

Required:

--unspent=<arg> all|first|last|<txlist>
                       all = convert all unspent outputs
                       first = convert first unspent output
                       last = convert last unspent output
                       txlist = one or more txid, comma separated.

Optional:

--zcash-cli=<path> path to zcash-cli. default = './src/zcash-cli'

--verbosity=<level> silent|results|full|debug default = full

--help display usage information

```

# Example run

```
$ ./protect_coins.php --unspent=first

-- Listing Unspent Coins --

executing: ./src/zcash-cli listunspent 

Result:
[
    {
        "txid": "2019...a6f1",
        "vout": 0,
        "address": "mxFMkDZu19QECvqoCn67FQgvYi2Dbsp71Y",
        "scriptPubKey": "2102...32ac",
        "amount": 50,
        "confirmations": 258,
        "spendable": true
    }
]

-- Unspent Coins Chosen --
  User's choice: first

Result:
[
    {
        "txid": "2019...a6f1",
        "vout": 0,
        "address": "mxFMkDZu19QECvqoCn67FQgvYi2Dbsp71Y",
        "scriptPubKey": "2102...32ac",
        "amount": 50,
        "confirmations": 258,
        "spendable": true
    }
]

-- Generating Address --

executing: ./src/zcash-cli zcrawkeygen 

Result:
{
    "zcaddress": "20ad....1070",
    "zcsecretkey": "20e5...cc92"
}

-- Creating Raw Tx --

executing: ./src/zcash-cli createrawtransaction '[{"txid":"2019...a6f1","vout":0}]' '{}' 

Result:
"0100...0000"

-- Calling zcrawpour --

executing: ./src/zcash-cli zcrawpour '0100...1070":49.9}' '50' '0.1' 

Result:
{
    "encryptedbucket1": "04f7...c275",
    "encryptedbucket2": "04e5f...d2c4",
    "rawtxn": "..."
}

-- Signing Tx --

executing: ./src/zcash-cli signrawtransaction '...' 

Result:
{
    "hex": "...",
    "complete": true
}

-- Sending the Tx to ourself --

executing: ./src/zcash-cli sendrawtransaction '0200...330a' 

Result:
"9ae8...230b"

-- Decrypting the received Tx --

executing: ./src/zcash-cli zcrawreceive '20e5...c92' '04f7...c275' 

Result:
{
    "amount": 49.9,
    "bucket": "805b...4c68",
    "exists": false
}

-- Done! --
```

I was going to upload it here, but it wouldn’t allow any non image uploads, so I made a little github repo for it at [[GitHub - dan-da/zcash-util: zcash utiltiies](https://github.com/dan-da/zcash-util)].

---

<div class="post-metadata">

**Author:** ![Haejin](https://avatars.discourse-cdn.com/v4/letter/h/a698b9/32.png) [@Haejin](https://forum.zcashcommunity.com/u/Haejin)\
**Post date:** [November 4, 2016, 1:47am UTC](https://forum.zcashcommunity.com/t/i-made-a-script-to-automate-protect-coins-procedure/501/2 "2016-11-04T01:47:26Z")

</div>

Hello, i received (not mined) zec from genesis mining to my t address. I tried sending that to my poloniex t address but keep getting non-coinbase UTXO not available and no spendable.

please help.

---

<div class="post-metadata">

**Author:** ![5a1t](https://avatars.discourse-cdn.com/v4/letter/5/b487fb/32.png) [@5a1t](https://forum.zcashcommunity.com/u/5a1t)\
**Post date:** [November 4, 2016, 1:51am UTC](https://forum.zcashcommunity.com/t/i-made-a-script-to-automate-protect-coins-procedure/501/3 "2016-11-04T01:51:14Z")

</div>

This script is old and uses the soon-to-be deprecated zc\* RPC calls.

I’d be happy to try to help you. Can you PM me ‘zcash-cli listtransactions’ output, and the command you are trying to use to send to Poloniex, exactly.

---

<div class="post-metadata">

**Author:** ![Haejin](https://avatars.discourse-cdn.com/v4/letter/h/a698b9/32.png) [@Haejin](https://forum.zcashcommunity.com/u/Haejin)\
**Post date:** [November 4, 2016, 2:50am UTC](https://forum.zcashcommunity.com/t/i-made-a-script-to-automate-protect-coins-procedure/501/4 "2016-11-04T02:50:31Z")

</div>

can you send me your email to me at [haegon@yahoo.com](mailto:haegon@yahoo.com)? thx
