From 01186c52c83bccffad17dde5a24712b86dc3e68e Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 7 Jun 2015 11:53:32 -0400 Subject: Move `sendMoney` func to `purchase` package Create a new package for sending money. Take API keys as args which obviously is not a good idea but it's a hackathon. * Add functions in main.go to initiate hard-coded transactions for house buyer and seller * Move from "com.teddywing" to "github.com/teddywing" --- purchase/purchase.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 purchase/purchase.go (limited to 'purchase/purchase.go') diff --git a/purchase/purchase.go b/purchase/purchase.go new file mode 100644 index 0000000..0bce2a4 --- /dev/null +++ b/purchase/purchase.go @@ -0,0 +1,22 @@ +package purchase + +import ( + "github.com/teddywing/new-house-on-the-block/vendor/_nuts/github.com/fabioberger/coinbase-go" +) + +func SendMoney(from_key string, from_secret string, to string, amount string) (transaction_id string, err error) { + c := coinbase.ApiKeyClientSandbox(from_key, from_secret) + + params := &coinbase.TransactionParams{ + To: to, + Amount: amount, + Notes: "You just bought a house", + } + + confirmation, err := c.SendMoney(params) + if err != nil { + return "", err + } else { + return confirmation.Transaction.Id, nil + } +} -- cgit v1.2.3