I made a script to automate protecting coins


#1

First time user here. I was following the Public Alpha Guide and there are a lot of steps so I made a script to automate things. Maybe it can be useful for someone.

The script is here:
https://github.com/dan-da/zcash-util

Example output

$ ./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! --

#2

Dear Danda,
How are you,
We have some accounts that requires automation.
Please kindly get back to us,So that you can help us.
I await your reply


#3

@b3aorg I'm not sure what you mean. explain?


#5

Hey, this is really cool! Thanks for playing around with Zcash. :slight_smile:

We need something like this for casual users to interact with the scheme until we have a higher-level payment API. @str4d wrote one in Bash, but I think we would prefer it in Python.


#6

Ok, I made a version in python. Feel free to put it in contrib or use however you like.

here you go:


#7

Really cool! Thanks! I'll show the team. :slight_smile:


#8

I added a --fee param. defaults to 0.

Before it was hard-coded to 0.1, as in the alpha guide.