diff --git a/routes/exchange.go b/routes/exchange.go index 6fc4f6ed..e6ea883a 100644 --- a/routes/exchange.go +++ b/routes/exchange.go @@ -774,7 +774,7 @@ func (fes *APIServer) APITransferDeSo(ww http.ResponseWriter, rr *http.Request) if transferDeSoRequest.AmountNanos < 0 { // Create a MAX transaction txnn, totalInputt, spendAmountt, feeNanoss, err = fes.blockchain.CreateMaxSpend( - senderPublicKeyBytes, recipientPub.SerializeCompressed(), + senderPublicKeyBytes, recipientPub.SerializeCompressed(), nil, uint64(minFeeRateNanosPerKB), fes.backendServer.GetMempool(), additionalOutputs) if err != nil { diff --git a/routes/transaction.go b/routes/transaction.go index b77c9000..66571e32 100644 --- a/routes/transaction.go +++ b/routes/transaction.go @@ -993,10 +993,11 @@ func (fes *APIServer) ExceedsDeSoBalance(nanosPurchased uint64, seed string) (bo // SendDeSoRequest ... type SendDeSoRequest struct { - SenderPublicKeyBase58Check string `safeForLogging:"true"` - RecipientPublicKeyOrUsername string `safeForLogging:"true"` - AmountNanos int64 `safeForLogging:"true"` - MinFeeRateNanosPerKB uint64 `safeForLogging:"true"` + SenderPublicKeyBase58Check string `safeForLogging:"true"` + RecipientPublicKeyOrUsername string `safeForLogging:"true"` + AmountNanos int64 `safeForLogging:"true"` + MinFeeRateNanosPerKB uint64 `safeForLogging:"true"` + ExtraData map[string]string `safeForLogging:"true"` // No need to specify ProfileEntryResponse in each TransactionFee TransactionFees []TransactionFee `safeForLogging:"true"` @@ -1074,6 +1075,12 @@ func (fes *APIServer) SendDeSo(ww http.ResponseWriter, req *http.Request) { return } + extraData, err := EncodeExtraDataMap(requestData.ExtraData) + if err != nil { + _AddBadRequestError(ww, fmt.Sprintf("SendDeSo: Problem encoding ExtraData: %v", err)) + return + } + // If the AmountNanos is less than zero then we have a special case where we create // a transaction with the maximum spend. var txnn *lib.MsgDeSoTxn @@ -1084,7 +1091,7 @@ func (fes *APIServer) SendDeSo(ww http.ResponseWriter, req *http.Request) { if requestData.AmountNanos < 0 { // Create a MAX transaction txnn, totalInputt, spendAmountt, feeNanoss, err = fes.blockchain.CreateMaxSpend( - senderPkBytes, recipientPkBytes, requestData.MinFeeRateNanosPerKB, + senderPkBytes, recipientPkBytes, extraData, requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("SendDeSo: Error processing MAX transaction: %v", err)) @@ -1115,6 +1122,10 @@ func (fes *APIServer) SendDeSo(ww http.ResponseWriter, req *http.Request) { // inputs and change. } + if len(extraData) > 0 { + txnn.ExtraData = extraData + } + // Add inputs to the transaction and do signing, validation, and broadcast // depending on what the user requested. totalInputt, spendAmountt, changeAmountt, feeNanoss, err = @@ -2116,6 +2127,8 @@ type SendDiamondsRequest struct { MinFeeRateNanosPerKB uint64 `safeForLogging:"true"` + ExtraData map[string]string `safeForLogging:"true"` + // No need to specify ProfileEntryResponse in each TransactionFee TransactionFees []TransactionFee `safeForLogging:"true"` @@ -2191,6 +2204,12 @@ func (fes *APIServer) SendDiamonds(ww http.ResponseWriter, req *http.Request) { return } + extraData, err := EncodeExtraDataMap(requestData.ExtraData) + if err != nil { + _AddBadRequestError(ww, fmt.Sprintf("SendDiamonds: Problem encoding extra data: %v", err)) + return + } + // Try and create the transfer with diamonds for the user. // We give diamonds in DESO if we're past the corresponding block height. blockHeight := fes.blockchain.BlockTip().Height + 1 @@ -2210,6 +2229,7 @@ func (fes *APIServer) SendDiamonds(ww http.ResponseWriter, req *http.Request) { senderPublicKeyBytes, diamondPostHash, requestData.DiamondLevel, + extraData, // Standard transaction fields requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) if err != nil {