diff options
| author | Teddy Wing | 2015-06-06 21:20:22 -0400 |
|---|---|---|
| committer | Teddy Wing | 2015-06-06 21:20:22 -0400 |
| commit | 7e57f147312fb9858e5071e6211e6e26b0092c17 (patch) | |
| tree | 137f5c98f22eb5acb37008885ddf1ad2ecac79cc | |
| parent | cb49a3cee091f7eb2455bd9d0b13dc67313c5ec9 (diff) | |
| download | New-House-on-the-Block-7e57f147312fb9858e5071e6211e6e26b0092c17.tar.bz2 | |
main.go: Send money from our primary account to another
Send 0.0001 BTC to the hard-coded Bitcoin address of my test seller
account. Confirms that we can send money in a transaction.
| -rw-r--r-- | main.go | 27 |
1 files changed, 23 insertions, 4 deletions
@@ -7,12 +7,31 @@ import ( "os" ) -func main() { +func sendMoney(from string, to string, amount string) (transaction_id string, err error) { c := coinbase.ApiKeyClientSandbox(os.Getenv("COINBASE_KEY"), os.Getenv("COINBASE_SECRET")) - balance, err := c.GetBalance() + params := &coinbase.TransactionParams{ + To: to, + Amount: amount, + Notes: "You just bought a house", + } + + confirmation, err := c.SendMoney(params) + if err != nil { + return "", err + } else { + fmt.Println(confirmation.Transaction.Status) + fmt.Println(confirmation.Transaction.Id) + + return confirmation.Transaction.Id, nil + } +} + +func main() { + transaction_id, err := sendMoney("TODO", "n2Qd6da1jiFgij5SSncFKh7MoFN74GdUxv", "0.0001") if err != nil { - log.Print(err) + log.Println(err) + } else { + fmt.Println(transaction_id) } - fmt.Printf("Balance is %f BTC\n", balance) } |
