Browse Source

2.1.6-1.alpha.atlantis+07032019. Minor fixes in rpc api for exchange,remote node option added in wallet.

webwallet
Captain Dero 3 years ago
parent
commit
9ab209ded6
9 changed files with 91 additions and 20 deletions
  1. +10
    -0
      build_package.sh
  2. +4
    -2
      cmd/dero-wallet-cli/main.go
  3. +16
    -1
      cmd/derod/main.go
  4. +4
    -0
      config/config.go
  5. +1
    -1
      config/version.go
  6. +1
    -1
      structures/wallet_rpc.go
  7. +4
    -0
      walletapi/daemon_communication.go
  8. +24
    -5
      walletapi/rpc_get_transfer_by_txid.go
  9. +27
    -10
      walletapi/wallet.go

+ 10
- 0
build_package.sh View File

@@ -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


+ 4
- 2
cmd/dero-wallet-cli/main.go View File

@@ -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
@@ -315,7 +316,8 @@ func main() {
continue
}
} else if err == io.EOF {
break
// break
time.Sleep(time.Second)
}

// pass command to suitable handler


+ 16
- 1
cmd/derod/main.go View File

@@ -26,6 +26,7 @@ import "strings"
import "strconv"
import "runtime"
import "math/big"
import "os/signal"

//import "crypto/sha1"
import "encoding/hex"
@@ -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 {
@@ -335,7 +349,8 @@ func main() {
continue
}
} else if err == io.EOF {
break
<-Exit_In_Progress
break
}

line = strings.TrimSpace(line)


+ 4
- 0
config/config.go View File

@@ -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"

+ 1
- 1
config/version.go View File

@@ -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")

+ 1
- 1
structures/wallet_rpc.go View File

@@ -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"`
}


+ 4
- 0
walletapi/daemon_communication.go View File

@@ -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)


+ 24
- 5
walletapi/rpc_get_transfer_by_txid.go View File

@@ -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



+ 27
- 10
walletapi/wallet.go View File

@@ -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
}
}
@@ -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
@@ -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
@@ -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)
}
}
@@ -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)
}
}

@@ -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))



Loading…
Cancel
Save