From 475ae0bf9bea6b4dd5025b1af9d678c25b8c4949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ste=CC=81phane=20Depierrepont?= Date: Fri, 23 May 2014 08:05:24 +0200 Subject: [PATCH] add Move MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Depierrepont --- bitcoind.go | 11 +++++++++++ bitcoind_test.go | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/bitcoind.go b/bitcoind.go index 854ad68..475a378 100644 --- a/bitcoind.go +++ b/bitcoind.go @@ -538,6 +538,17 @@ func (b *Bitcoind) LockUnspent(lock bool, outputs []UnspendableOutput) (success return } +// Move from one account in your wallet to another +func (b *Bitcoind) Move(formAccount, toAccount string, amount float64, minconf uint32, comment string) (success bool, err error) { + r, err := b.client.call("move", []interface{}{formAccount, toAccount, amount, minconf, comment}) + if err = handleError(err, &r); err != nil { + return + } + err = json.Unmarshal(r.Result, &success) + return + +} + // SendFrom send amount from fromAccount to toAddress // amount is a real and is rounded to 8 decimal places. // Will send the given amount to the given address, ensuring the account has a valid balance using [minconf] confirmations. diff --git a/bitcoind_test.go b/bitcoind_test.go index eeddfcb..dbf8112 100644 --- a/bitcoind_test.go +++ b/bitcoind_test.go @@ -1778,6 +1778,27 @@ var _ = Describe("Bitcoind", func() { }) }) + Describe("Testing Move", func() { + Context("when success", func() { + handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + fmt.Fprintln(w, `{"result":true,"error":null,"id":1400824961400921439}`) + }) + ts, host, port, err := getNewTestServer(handler) + if err != nil { + log.Fatalln(err) + } + defer ts.Close() + bitcoindClient, _ := New(host, port, "x", "fake", false) + success, err := bitcoindClient.Move("tests1", "test2", 0.0001, 1, "Move test") + It("should not error", func() { + Expect(err).NotTo(HaveOccurred()) + }) + It("should return a boolean true ", func() { + Expect(success).Should(BeTrue()) + }) + }) + }) + Describe("Testing SendFrom", func() { Context("when success", func() { handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {