Skip to content

Commit

Permalink
add Move
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Depierrepont <[email protected]>
  • Loading branch information
toorop committed May 23, 2014
1 parent bca5f19 commit 475ae0b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bitcoind.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 21 additions & 0 deletions bitcoind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 475ae0b

Please sign in to comment.