/// <summary> /// This works like createrawtransaction, except it automatically selects the transaction inputs from those belonging to from-address, to cover the appropriate amounts. One or more change outputs going back to from-address will also be added to the end of the transaction. /// </summary> /// <param name="fromAddress"></param> /// <param name="toAddresses"></param> /// <param name="data"></param> /// <param name="action"></param> /// <returns></returns> public async Task <CreateRawTransactionResponse> CreateRawSendFromAsync(string fromAddress, IReadOnlyDictionary <string, object> toAddresses, object[] data = null, RawTransactionAction action = RawTransactionAction.Default) { var result = new CreateRawTransactionResponse(); var metadata = data ?? Util.Utility.EmptyArray <string>(); var txAction = action.ToStr(); if ((action & RawTransactionAction.Sign) != 0) { result.SignedTransaction = await _Client.ExecuteAsync <SignedTransactionResponse>("createrawsendfrom", 0, fromAddress, toAddresses, metadata, txAction); } else if ((action & RawTransactionAction.Send) != 0) { result.TxId = await _Client.ExecuteAsync <string>("createrawsendfrom", 0, fromAddress, toAddresses, metadata, txAction); } else { result.TxHex = await _Client.ExecuteAsync <string>("createrawsendfrom", 0, fromAddress, toAddresses, metadata, txAction); } return(result); }
/// <summary> /// This works like createrawtransaction but adds the given inputs and (regular or metadata) outputs to the raw transaction specified in tx-hex, rather than creating a new transaction. It is particularly useful for accepting an offer of exchange using an address whose private key is held outside the node’s wallet. Note that if tx-hex contains more outputs than inputs, the new outputs will be inserted at position n, where n is the number of inputs in tx-hex. (This is important to preserve the viability of certain types of transaction signatures.) /// </summary> /// <param name="txHex"></param> /// <param name="inputs"></param> /// <param name="outputs"></param> /// <param name="data"></param> /// <param name="action"></param> /// <returns></returns> public async Task <CreateRawTransactionResponse> AppendRawTransactionAsync(string txHex, object[] inputs, IReadOnlyDictionary <string, object> outputs, object[] data = null, RawTransactionAction action = RawTransactionAction.Default) { var result = new CreateRawTransactionResponse(); var metadata = data ?? Util.Utility.EmptyArray <string>(); var txAction = action.ToStr(); if ((action & RawTransactionAction.Sign) != 0) { result.SignedTransaction = await _Client.ExecuteAsync <SignedTransactionResponse>("appendrawtransaction", 0, txHex, inputs, outputs, metadata, txAction); } else if ((action & RawTransactionAction.Send) != 0) { result.TxId = await _Client.ExecuteAsync <string>("appendrawtransaction", 0, txHex, inputs, outputs, metadata, txAction); } else { result.TxHex = await _Client.ExecuteAsync <string>("appendrawtransaction", 0, txHex, inputs, outputs, metadata, txAction); } return(result); }