Skip to content

Commit ee0f223

Browse files
author
JK
committed
Added sendfrom command. Updated raw transactions to also consider asset transfer
1 parent fbc028b commit ee0f223

4 files changed

Lines changed: 34 additions & 10 deletions

File tree

src/main/java/multichain/command/IssueCommand.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,10 @@ public static String sendAssetFrom(String fromAddress, String toAddress, String
355355
return executeSendAssetFrom(fromAddress, toAddress, assetName, quantity);
356356
}
357357

358+
public static String sendFrom(String fromAddresss, String toAddress, String quantity) throws MultichainException {
359+
return executeSendFrom(fromAddresss, toAddress, quantity);
360+
}
361+
358362
/**
359363
* Sends assets to address, returning the txid.
360364
*

src/main/java/multichain/command/RAWTransactionCommand.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,7 @@ public static String createRawTransaction(List<TxIdVout> inputs, List<AddressBal
183183
* @return hexidecimal blob as String
184184
* @throws MultichainException
185185
*/
186-
public static String createRawSendFrom(String blockchainAddress, String asset, Map<String, Object> streamItem) throws MultichainException {
187-
if(asset == null || asset.isEmpty()) {
188-
asset = "{}";
189-
}
186+
public static String createRawSendFrom(String blockchainAddress, Map<String, Object> asset, Map<String, Object> streamItem) throws MultichainException {
190187
return executeCreateRawSendFrom(blockchainAddress, asset, streamItem);
191188
}
192189

src/main/java/multichain/command/builders/QueryBuilderIssue.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,26 @@ protected static String executeSendAssetFrom(String fromAddress, String toAddres
389389
throws MultichainException {
390390
MultichainTestParameter.isNotNullOrEmpty("fromAddress", fromAddress);
391391
MultichainTestParameter.isNotNullOrEmpty("toAddress", toAddress);
392-
//MultichainTestParameter.isNotNullOrEmpty("assetName", assetName);
393392
MultichainTestParameter.valueIsPositive("quantity", quantity);
394-
return execute(CommandEnum.SENDASSETFROM, formatJson(fromAddress), formatJson(toAddress), formatJson(assetName), formatJson(quantity));
393+
MultichainTestParameter.isNotNull("assetName", assetName);
394+
if(assetName.isEmpty())
395+
assetName = "\"\"";
396+
return execute(CommandEnum.SENDASSETFROM, fromAddress, toAddress, assetName, formatJson(quantity));
397+
}
398+
399+
/**
400+
* Send native currency to an address from the specified address
401+
* @param fromAddress send from
402+
* @param toAddress send to
403+
* @param quantity how much native currency in decimal format e.g. 0.005
404+
* @return Txid
405+
* @throws MultichainException
406+
*/
407+
protected static String executeSendFrom(String fromAddress, String toAddress, String quantity) throws MultichainException {
408+
MultichainTestParameter.isNotNullOrEmpty("fromAddress", fromAddress);
409+
MultichainTestParameter.isNotNullOrEmpty("toAddress", toAddress);
410+
MultichainTestParameter.isNotNullOrEmpty("quantity", quantity);
411+
return execute(CommandEnum.SENDFROM, fromAddress, toAddress, quantity);
395412
}
396413

397414
/**

src/main/java/multichain/command/builders/QueryBuilderRAWTransaction.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,16 @@ protected static String executeCreateRawTransaction(List<TxIdVout> inputs, List<
196196
* @return hexidecimal blob as String
197197
* @throws MultichainException
198198
*/
199-
protected static String executeCreateRawSendFrom(String blockchainAddress, String asset, Map<String, Object> streamItem) throws MultichainException {
200-
String streamItemAsJson = formatJson(streamItem);
201-
String streamItemAsArray = "[" + streamItemAsJson +"]";
202-
return execute(CommandEnum.CREATERAWSENDFROM, blockchainAddress, asset, streamItemAsArray);
199+
protected static String executeCreateRawSendFrom(String blockchainAddress, Map<String, Object> asset, Map<String, Object> streamItem) throws MultichainException {
200+
if(asset == null || asset.isEmpty()) {
201+
String streamItemAsJson = formatJson(streamItem);
202+
String streamItemAsArray = "[" + streamItemAsJson +"]";
203+
return execute(CommandEnum.CREATERAWSENDFROM, blockchainAddress, "{}", streamItemAsArray);
204+
} else {
205+
String assetItemAsJson = formatJson(asset);
206+
return execute(CommandEnum.CREATERAWSENDFROM, blockchainAddress, assetItemAsJson);
207+
}
208+
203209
}
204210

205211
/**

0 commit comments

Comments
 (0)