Skip to content

Commit

Permalink
Merge pull request #23 from oezdemir/master
Browse files Browse the repository at this point in the history
Add createmultisig, createrawtransaction, decoderawtransaction, importpr...
  • Loading branch information
sinisterchipmunk committed May 25, 2014
2 parents 7e24a2e + 1e1b4fe commit afe844c
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions lib/bitcoin/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@ def backupwallet(destination)
@api.request 'backupwallet', destination
end

# Creates a multi-signature address and returns a json object
def createmultisig(nrequired, keys)
@api.request 'createmultisig', nrequired, keys
end

# nCreate a transaction spending given inputs
# (array of objects containing transaction id and output number), sending to given address(es)
def createrawtransaction(transactionid = nil, address_amount)
@api.request 'createrawtransaction', transactionid, address_amount
end

# Return a JSON object representing the serialized, hex-encoded transaction.
def decoderawtransaction(hexstring)
@api.request 'decoderawtransaction', hexstring
end

# Returns the account associated with the given address.
def getaccount(bitcoinaddress)
@api.request 'getaccount', bitcoinaddress
Expand Down Expand Up @@ -142,6 +158,11 @@ def getwork(data = nil)
def help(command = nil)
@api.request 'help', command
end

# Adds a private key (as returned by dumpprivkey) to your wallet.
def importprivkey(bitcoinprivkey, label = nil, rescan = true)
@api.request 'importprivkey', bitcoinprivkey, label, rescan
end

# Returns Object that has account names as keys, account balances as values.
def listaccounts(minconf = 1)
Expand Down Expand Up @@ -185,6 +206,10 @@ def sendfrom(fromaccount, tobitcoinaddress, amount, minconf = 1, comment = nil,
@api.request 'sendfrom', fromaccount, tobitcoinaddress, amount, minconf, comment, comment_to
end

# Submits raw transaction (serialized, hex-encoded) to local node and network.
def sendrawtransaction(hexstring)
@api.request 'sendrawtransaction', hexstring
end
# +amount+ is a real and is rounded to 8 decimal places
def sendtoaddress(bitcoinaddress, amount, comment = nil, comment_to = nil)
@api.request 'sendtoaddress', bitcoinaddress, amount, comment, comment_to
Expand All @@ -205,6 +230,11 @@ def setgenerate(generate, genproclimit = -1)
@api.request 'setgenerate', generate, genproclimit
end

# Sign inputs for raw transaction (serialized, hex-encoded).
def signrawtransaction(hexstring, transaction = nil, privatekey =nil, sighashtype = "ALL")
@api.request 'signrawtransaction', hexstring, transaction, privatekey, sighashtype
end

# Stop bitcoin server.
def stop
@api.request 'stop'
Expand Down

0 comments on commit afe844c

Please sign in to comment.