Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[resolves #41] Signing raw transaction should work with TxInput #42

Merged
merged 1 commit into from
Jun 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ public String getAccount(String address) throws GenericRpcException {
}

@Override
public String getAccountAddress(String address) throws GenericRpcException {
return (String) query("getaccountaddress", address);
public String getAccountAddress(String account) throws GenericRpcException {
return (String) query("getaccountaddress", account);
}

@Override
Expand Down Expand Up @@ -1313,7 +1313,7 @@ public Date blocktime() {

}

public class DecodedScriptImpl extends MapWrapper implements DecodedScript, Serializable {
private class DecodedScriptImpl extends MapWrapper implements DecodedScript, Serializable {

public DecodedScriptImpl(Map m) {
super(m);
Expand Down Expand Up @@ -1599,47 +1599,59 @@ public UnspentListWrapper(List<Map> list) {

@Override
protected Unspent wrap(final Map m) {
return new Unspent() {
return new UnspentWrapper(m);
}
}

@Override
public String txid() {
return mapStr(m, "txid");
}
private class UnspentWrapper implements Unspent {

final Map m;

UnspentWrapper(Map m) {
this.m = m;
}

@Override
public int vout() {
return mapInt(m, "vout");
}
@Override
public String txid() {
return mapStr(m, "txid");
}

@Override
public String address() {
return mapStr(m, "address");
}
@Override
public int vout() {
return mapInt(m, "vout");
}

@Override
public String scriptPubKey() {
return mapStr(m, "scriptPubKey");
}
@Override
public String address() {
return mapStr(m, "address");
}

@Override
public String account() {
return mapStr(m, "account");
}
@Override
public String scriptPubKey() {
return mapStr(m, "scriptPubKey");
}

@Override
public double amount() {
return MapWrapper.mapDouble(m, "amount");
}
@Override
public String account() {
return mapStr(m, "account");
}

@Override
public int confirmations() {
return mapInt(m, "confirmations");
}
@Override
public double amount() {
return MapWrapper.mapDouble(m, "amount");
}

};
@Override
public int confirmations() {
return mapInt(m, "confirmations");
}
}

@Override
public String toString() {
return m.toString();
}
}

@Override
public List<Unspent> listUnspent() throws GenericRpcException {
return new UnspentListWrapper((List) query("listunspent"));
Expand All @@ -1661,43 +1673,43 @@ public List<Unspent> listUnspent(int minConf, int maxConf, String... addresses)
}

@Override
public boolean move(String fromAccount, String toBitcoinAddress, double amount) throws GenericRpcException {
return (boolean) query("move", fromAccount, toBitcoinAddress, amount);
public boolean move(String fromAccount, String toAddress, double amount) throws GenericRpcException {
return (boolean) query("move", fromAccount, toAddress, amount);
}

@Override
public boolean move(String fromAccount, String toBitcoinAddress, double amount, String comment) throws GenericRpcException {
return (boolean) query("move", fromAccount, toBitcoinAddress, amount, 0, comment);
public boolean move(String fromAccount, String toAddress, double amount, String comment) throws GenericRpcException {
return (boolean) query("move", fromAccount, toAddress, amount, 0, comment);
}

@Override
public boolean move(String fromAccount, String toBitcoinAddress, double amount, int minConf) throws GenericRpcException {
return (boolean) query("move", fromAccount, toBitcoinAddress, amount, minConf);
public boolean move(String fromAccount, String toAddress, double amount, int minConf) throws GenericRpcException {
return (boolean) query("move", fromAccount, toAddress, amount, minConf);
}

@Override
public boolean move(String fromAccount, String toBitcoinAddress, double amount, int minConf, String comment) throws GenericRpcException {
return (boolean) query("move", fromAccount, toBitcoinAddress, amount, minConf, comment);
public boolean move(String fromAccount, String toAddress, double amount, int minConf, String comment) throws GenericRpcException {
return (boolean) query("move", fromAccount, toAddress, amount, minConf, comment);
}

@Override
public String sendFrom(String fromAccount, String toBitcoinAddress, double amount) throws GenericRpcException {
return (String) query("sendfrom", fromAccount, toBitcoinAddress, amount);
public String sendFrom(String fromAccount, String toAddress, double amount) throws GenericRpcException {
return (String) query("sendfrom", fromAccount, toAddress, amount);
}

@Override
public String sendFrom(String fromAccount, String toBitcoinAddress, double amount, int minConf) throws GenericRpcException {
return (String) query("sendfrom", fromAccount, toBitcoinAddress, amount, minConf);
public String sendFrom(String fromAccount, String toAddress, double amount, int minConf) throws GenericRpcException {
return (String) query("sendfrom", fromAccount, toAddress, amount, minConf);
}

@Override
public String sendFrom(String fromAccount, String toBitcoinAddress, double amount, int minConf, String comment) throws GenericRpcException {
return (String) query("sendfrom", fromAccount, toBitcoinAddress, amount, minConf, comment);
public String sendFrom(String fromAccount, String toAddress, double amount, int minConf, String comment) throws GenericRpcException {
return (String) query("sendfrom", fromAccount, toAddress, amount, minConf, comment);
}

@Override
public String sendFrom(String fromAccount, String toBitcoinAddress, double amount, int minConf, String comment, String commentTo) throws GenericRpcException {
return (String) query("sendfrom", fromAccount, toBitcoinAddress, amount, minConf, comment, commentTo);
public String sendFrom(String fromAccount, String toAddress, double amount, int minConf, String comment, String commentTo) throws GenericRpcException {
return (String) query("sendfrom", fromAccount, toAddress, amount, minConf, comment, commentTo);
}

@Override
Expand Down Expand Up @@ -1725,23 +1737,26 @@ public String signRawTransaction(String hex) throws GenericRpcException {
}

@Override
public String signRawTransaction(String hex, List<ExtendedTxInput> inputs, List<String> privateKeys) throws GenericRpcException {
public String signRawTransaction(String hex, List<? extends TxInput> inputs, List<String> privateKeys) throws GenericRpcException {
return signRawTransaction(hex, inputs, privateKeys, "ALL");
}

public String signRawTransaction(String hex, List<ExtendedTxInput> inputs, List<String> privateKeys, String sigHashType) {
public String signRawTransaction(String hex, List<? extends TxInput> inputs, List<String> privateKeys, String sigHashType) {
List<Map> pInputs = null;

if (inputs != null) {
pInputs = new ArrayList<>();
for (final ExtendedTxInput txInput : inputs) {
for (final TxInput txInput : inputs) {
pInputs.add(new LinkedHashMap() {
{
put("txid", txInput.txid());
put("vout", txInput.vout());
put("scriptPubKey", txInput.scriptPubKey());
put("redeemScript", txInput.redeemScript());
put("amount", txInput.amount());
if (txInput instanceof ExtendedTxInput) {
ExtendedTxInput extin = (ExtendedTxInput) txInput;
put("redeemScript", extin.redeemScript());
put("amount", extin.amount());
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import java.util.List;
import java.util.Map;

import wf.bitcoin.javabitcoindrpcclient.BitcoindRpcClient.TxInput;

/**
*
* @author Mikhail Yevchenko m.ṥῥẚɱ.ѓѐḿởύḙ@azazar.com Small modifications by
Expand Down Expand Up @@ -1212,7 +1214,7 @@ interface Unspent extends TxInput, TxOutput, Serializable {
*
* @see <a href="https://bitcoin.org/en/developer-reference#signrawtransaction">signrawtransaction</a>
*/
String signRawTransaction(String hex, List<ExtendedTxInput> inputs, List<String> privateKeys) throws GenericRpcException;
String signRawTransaction(String hex, List<? extends TxInput> inputs, List<String> privateKeys) throws GenericRpcException;

static interface AddressValidationResult extends Serializable {

Expand Down