Skip to content
This repository has been archived by the owner on Apr 3, 2022. It is now read-only.

Commit

Permalink
2.1.6-1.alpha.atlantis+07032019. Minor fixes in rpc api for exchange,…
Browse files Browse the repository at this point in the history
…remote node option added in wallet.
  • Loading branch information
Captain Dero committed Mar 7, 2019
1 parent e1b677d commit 9ab209d
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 20 deletions.
10 changes: 10 additions & 0 deletions build_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ echo mkdir -p $OUTPUT_DIR
CMD="GOOS=${GOOS} GOARCH=${GOARCH} go build -o $OUTPUT_DIR/${BIN_FILENAME} $package"
echo "${CMD}"
eval $CMD || FAILURES="${FAILURES} ${PLATFORM}"

# build docker image for linux amd64 competely static
if [[ "${GOOS}" == "linux" && "${GOARCH}" == "amd64" && "${OUTPUT}" != "explorer" ]]; then
BIN_FILENAME="docker-${OUTPUT}-${GOOS}-${GOARCH}"
CMD="GOOS=${GOOS} GOARCH=${GOARCH} CGO_ENABLED=0 go build -o $OUTPUT_DIR/${BIN_FILENAME} $package"
echo "${CMD}"
eval $CMD || FAILURES="${FAILURES} ${PLATFORM}"
fi


done

# ARM64 builds only for linux
Expand Down
6 changes: 4 additions & 2 deletions cmd/dero-wallet-cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ Usage:
--restore-deterministic-wallet Restore wallet from previously saved recovery seed
--electrum-seed=<recovery-seed> Seed to use while restoring wallet
--socks-proxy=<socks_ip:port> Use a proxy to connect to Daemon.
--daemon-address=<host:port> Use daemon instance at <host>:<port>
--remote use hard coded remote daemon https://rwallet.dero.live
--daemon-address=<host:port> Use daemon instance at <host>:<port> or https://domain
--rpc-server Run rpc server, so wallet is accessible using api
--rpc-bind=<127.0.0.1:20209> Wallet binds on this ip address and port
--rpc-login=<username:password> RPC server will grant access based on these credentials
Expand Down Expand Up @@ -315,7 +316,8 @@ func main() {
continue
}
} else if err == io.EOF {
break
// break
time.Sleep(time.Second)
}

// pass command to suitable handler
Expand Down
17 changes: 16 additions & 1 deletion cmd/derod/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import "strings"
import "strconv"
import "runtime"
import "math/big"
import "os/signal"

//import "crypto/sha1"
import "encoding/hex"
Expand Down Expand Up @@ -324,6 +325,19 @@ func main() {
})
l.Refresh() // refresh the prompt

go func (){
var gracefulStop = make(chan os.Signal)
signal.Notify(gracefulStop,os.Interrupt) // listen to all signals
for {
sig := <-gracefulStop
fmt.Printf("received signal %s\n", sig)

if sig.String() == "interrupt" {
close(Exit_In_Progress)
}
}
}()

for {
line, err := l.Readline()
if err == readline.ErrInterrupt {
Expand All @@ -335,7 +349,8 @@ func main() {
continue
}
} else if err == io.EOF {
break
<-Exit_In_Progress
break
}

line = strings.TrimSpace(line)
Expand Down
4 changes: 4 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,7 @@ var Testnet = CHAIN_CONFIG{Name: "testnet", // testnet will always have last 3 b
// these are still here for previous emission functions, they are not used directly for atlantis
const DYNAMIC_FEE_PER_KB_BASE_FEE_V5 = uint64((2000000000 * 60000) / 300000)
const DYNAMIC_FEE_PER_KB_BASE_BLOCK_REWARD = uint64(1000000000000) // 1 * pow(10,12)


// mainnet has a remote daemon node, which can be used be default, if user provides a --remote flag
const REMOTE_DAEMON = "https://rwallet.dero.live"
2 changes: 1 addition & 1 deletion config/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ import "github.com/blang/semver"

// right now it has to be manually changed
// do we need to include git commitsha??
var Version = semver.MustParse("2.1.5-1.alpha.atlantis+03112018")
var Version = semver.MustParse("2.1.6-1.alpha.atlantis+07032019")
2 changes: 1 addition & 1 deletion structures/wallet_rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ type (
Amount uint64 `json:"amount"`
Fees uint64 `json:"fee,omitempty"`
Unlock_time uint64 `json:"unlock_time"`
//Destination_list
Destinations []Destination `json:"destinations"`
Note string `json:"note,omitempty"`
Type string `json:"type,omitempty"`
}
Expand Down
4 changes: 4 additions & 0 deletions walletapi/daemon_communication.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ func buildurl(endpoint string) string {
// this will tell whether the wallet can connection successfully to daemon or not
func (w *Wallet) IsDaemonOnline() (err error) {

if globals.Arguments["--remote"] == true && globals.IsMainnet() {
w.Daemon_Endpoint = config.REMOTE_DAEMON
}

// if user provided endpoint has error, use default
if w.Daemon_Endpoint == "" {
w.Daemon_Endpoint = "127.0.0.1:" + fmt.Sprintf("%d", config.Mainnet.RPC_Default_Port)
Expand Down
29 changes: 24 additions & 5 deletions walletapi/rpc_get_transfer_by_txid.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,33 @@ func (h Get_Transfer_By_TXID_Handler) ServeJSONRPC(c context.Context, params *fa
Height: entry.Height,
Amount: entry.Amount,
Unlock_time: entry.Unlock_Time,

}
if entry.Height == 0 {
return nil, &jsonrpc.Error{Code: -8, Message: fmt.Sprintf("Transaction not found. TXID %s", p.TXID)}
}

// setup in/out
if entry.Amount > 0 { // if we have an amount
for i := range entry.Details.Daddress {
result.Transfer.Destinations = append(result.Transfer.Destinations,
structures.Destination{
Address: entry.Details.Daddress[i],
Amount: entry.Details.Amount[i],
})
}

if len(entry.Details.PaymentID) >= 1 {
result.Transfer.Payment_ID = entry.Details.PaymentID
}

if entry.Status == 0 { // if we have an amount
result.Transfer.Type = "in"
if h.r.w.GetTXKey(entry.TXID) != "" {
result.Transfer.Type = "out"
}
// send the result
return result, nil

}
// setup in/out
if entry.Status == 1 { // if we have an amount
result.Transfer.Type = "out"
// send the result
return result, nil

Expand Down
37 changes: 27 additions & 10 deletions walletapi/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,10 +440,12 @@ func (w *Wallet) Add_Transaction_Record_Funds(txdata *globals.TX_Output_Data) (a
err = msgpack.Unmarshal(value_bytes, &tx_wallet_temp)
if err == nil {
if tx_wallet_temp.TXdata.TXID != txdata.TXID { // transaction mismatch
rlog.Warnf("KICD %s,%s, \n%+v \n%+v",txdata.TXID, tx_wallet_temp.TXdata.TXID, txdata,tx_wallet_temp);
return 0, false
}

if tx_wallet_temp.TXdata.Index_within_tx != txdata.Index_within_tx { // index within tx mismatch
rlog.Warnf("KICD2 %s,%s, \n%+v \n%+v",txdata.TXID, tx_wallet_temp.TXdata.TXID, txdata,tx_wallet_temp);
return 0, false
}
}
Expand Down Expand Up @@ -706,17 +708,20 @@ func (w *Wallet) Add_Possible_Ring_Member(txdata *globals.TX_Output_Data) {
}

type Entry struct {
Index_Global uint64
Height uint64
TopoHeight int64
TXID crypto.Hash
Amount uint64
PaymentID []byte
Status byte
Unlock_Time uint64
Time time.Time
Index_Global uint64 `json:"index_global"`
Height uint64 `json:"height"`
TopoHeight int64 `json:"topoheight"`
TXID crypto.Hash `json:"txid"`
Amount uint64 `json:"amount"`
PaymentID []byte `json:"payment_id"`
Status byte `json:"status"`
Unlock_Time uint64 `json:"unlock_time"`
Time time.Time `json:"time"`
Secret_TX_Key string `json:"secret_tx_key"` // can be used to prove if available
Details structures.Outgoing_Transfer_Details `json:"details"` // actual details if available
}


// finds all inputs which have been received/spent etc
// TODO this code can be easily parallelised and need to be parallelised
// if only the availble is requested, then the wallet is very fast
Expand Down Expand Up @@ -840,6 +845,10 @@ func (w *Wallet) Show_Transfers(available bool, in bool, out bool, pool bool, fa
duration, _ := time.ParseDuration(fmt.Sprintf("%ds", int64(180*entry.Height)))
entry.Time = dero_first_block_time.Add(duration)
}

// fill tx secret_key
entry.Secret_TX_Key = w.GetTXKey(tx.TXdata.TXID)
entry.Details = w.GetTXOutDetails(tx.TXdata.TXID)

entry.Status = 1
entries = append(entries, entry) // spend entry
Expand Down Expand Up @@ -880,6 +889,10 @@ func (w *Wallet) Get_Payments_Payment_ID(payid []byte, min_height uint64) (entri
entry.PaymentID = tx.WPaymentID
entry.Status = 0
entry.Unlock_Time = tx.TXdata.Unlock_Height

// fill tx secret_key
entry.Secret_TX_Key = w.GetTXKey(tx.TXdata.TXID)
entry.Details = w.GetTXOutDetails(tx.TXdata.TXID)
entries = append(entries, entry)
}
}
Expand Down Expand Up @@ -913,6 +926,10 @@ func (w *Wallet) Get_Payments_TXID(txid []byte) (entry Entry) {
entry.PaymentID = tx.WPaymentID
entry.Status = 0
entry.Unlock_Time = tx.TXdata.Unlock_Height

// fill tx secret_key
entry.Secret_TX_Key = w.GetTXKey(tx.TXdata.TXID)
entry.Details = w.GetTXOutDetails(tx.TXdata.TXID)
}
}

Expand Down Expand Up @@ -965,7 +982,7 @@ func (w *Wallet) Clean() {
w.delete_bucket(BLOCKCHAIN_UNIVERSE, []byte(FUNDS_SPENT_WHERE))
w.delete_bucket(BLOCKCHAIN_UNIVERSE, []byte(FUNDS_BUCKET_OUTGOING))

// w.delete_bucket(BLOCKCHAIN_UNIVERSE, []byte(RING_BUCKET)) //Improves wallet rescan performance.
w.delete_bucket(BLOCKCHAIN_UNIVERSE, []byte(RING_BUCKET)) //Improves wallet rescan performance.
w.delete_bucket(BLOCKCHAIN_UNIVERSE, []byte(KEYIMAGE_BUCKET))
w.delete_bucket(BLOCKCHAIN_UNIVERSE, []byte(HEIGHT_TO_BLOCK_BUCKET))

Expand Down

0 comments on commit 9ab209d

Please sign in to comment.