DERO-HE STARGATE Testnet Release23
This commit is contained in:
parent
809cea2b90
commit
0b401ef251
@ -64,6 +64,7 @@ type Blockchain struct {
|
|||||||
|
|
||||||
mining_blocks_cache *lru.Cache // used to cache blocks which have been supplied to mining
|
mining_blocks_cache *lru.Cache // used to cache blocks which have been supplied to mining
|
||||||
cache_IsMiniblockPowValid *lru.Cache // used to cache mini blocks pow test result
|
cache_IsMiniblockPowValid *lru.Cache // used to cache mini blocks pow test result
|
||||||
|
cache_IsNonceValidTips *lru.Cache // used to cache nonce tests on specific tips
|
||||||
cache_IsAddressHashValid *lru.Cache // used to cache some outputs
|
cache_IsAddressHashValid *lru.Cache // used to cache some outputs
|
||||||
cache_Get_Difficulty_At_Tips *lru.Cache // used to cache some outputs
|
cache_Get_Difficulty_At_Tips *lru.Cache // used to cache some outputs
|
||||||
|
|
||||||
@ -136,6 +137,10 @@ func Blockchain_Start(params map[string]interface{}) (*Blockchain, error) {
|
|||||||
if chain.cache_Get_Difficulty_At_Tips, err = lru.New(8192); err != nil { // temporary cache for difficulty
|
if chain.cache_Get_Difficulty_At_Tips, err = lru.New(8192); err != nil { // temporary cache for difficulty
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if chain.cache_IsNonceValidTips, err = lru.New(100 * 1024); err != nil { // temporary cache for nonce checks
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
if chain.cache_IsAddressHashValid, err = lru.New(100 * 1024); err != nil { // temporary cache for valid address
|
if chain.cache_IsAddressHashValid, err = lru.New(100 * 1024); err != nil { // temporary cache for valid address
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -1227,12 +1232,7 @@ func (chain *Blockchain) IS_TX_Valid(txhash crypto.Hash) (valid_blid crypto.Hash
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var blids_list []crypto.Hash
|
blids_list := chain.Find_Blocks_Height_Range(int64(tx.Height+1), int64(tx.Height+1)+2*TX_VALIDITY_HEIGHT)
|
||||||
|
|
||||||
for i := uint64(1); i < 2*TX_VALIDITY_HEIGHT; i++ {
|
|
||||||
blids, _ := chain.Store.Topo_store.binarySearchHeight(int64(tx.Height + i))
|
|
||||||
blids_list = append(blids_list, blids...)
|
|
||||||
}
|
|
||||||
|
|
||||||
var exist_list []crypto.Hash
|
var exist_list []crypto.Hash
|
||||||
|
|
||||||
@ -1245,7 +1245,7 @@ func (chain *Blockchain) IS_TX_Valid(txhash crypto.Hash) (valid_blid crypto.Hash
|
|||||||
for _, bltxhash := range bl.Tx_hashes {
|
for _, bltxhash := range bl.Tx_hashes {
|
||||||
if bltxhash == txhash {
|
if bltxhash == txhash {
|
||||||
exist_list = append(exist_list, blid)
|
exist_list = append(exist_list, blid)
|
||||||
break
|
//break , this is removed so as this case can be tested well
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,6 +168,16 @@ func (chain *Blockchain) Create_new_miner_block(miner_address rpc.Address) (cbl
|
|||||||
|
|
||||||
height := chain.Calculate_Height_At_Tips(bl.Tips) // we are 1 higher than previous highest tip
|
height := chain.Calculate_Height_At_Tips(bl.Tips) // we are 1 higher than previous highest tip
|
||||||
|
|
||||||
|
history := map[crypto.Hash]bool{}
|
||||||
|
|
||||||
|
var history_array []crypto.Hash
|
||||||
|
for i := range bl.Tips {
|
||||||
|
history_array = append(history_array, chain.get_ordered_past(bl.Tips[i], 26)...)
|
||||||
|
}
|
||||||
|
for _, h := range history_array {
|
||||||
|
history[h] = true
|
||||||
|
}
|
||||||
|
|
||||||
var tx_hash_list_included []crypto.Hash // these tx will be included ( due to block size limit )
|
var tx_hash_list_included []crypto.Hash // these tx will be included ( due to block size limit )
|
||||||
|
|
||||||
sizeoftxs := uint64(0) // size of all non coinbase tx included within this block
|
sizeoftxs := uint64(0) // size of all non coinbase tx included within this block
|
||||||
@ -222,7 +232,10 @@ func (chain *Blockchain) Create_new_miner_block(miner_address rpc.Address) (cbl
|
|||||||
tx := chain.Mempool.Mempool_Get_TX(tx_hash_list_sorted[i].Hash)
|
tx := chain.Mempool.Mempool_Get_TX(tx_hash_list_sorted[i].Hash)
|
||||||
if tx != nil {
|
if tx != nil {
|
||||||
if int64(tx.Height) < height {
|
if int64(tx.Height) < height {
|
||||||
// fmt.Printf("sanity back %d(%d) nonce check %s\n", height - int64(tx.Height), TX_VALIDITY_HEIGHT, chain.Verify_Transaction_NonCoinbase_CheckNonce_Tips(hf_version,tx,bl.Tips) )
|
if history[tx.BLID] != true {
|
||||||
|
logger.V(8).Info("not selecting tx since the reference with which it was made is not in history", "txid", tx_hash_list_sorted[i].Hash)
|
||||||
|
continue
|
||||||
|
}
|
||||||
if height-int64(tx.Height) < TX_VALIDITY_HEIGHT {
|
if height-int64(tx.Height) < TX_VALIDITY_HEIGHT {
|
||||||
if nil == chain.Verify_Transaction_NonCoinbase_CheckNonce_Tips(hf_version, tx, bl.Tips) {
|
if nil == chain.Verify_Transaction_NonCoinbase_CheckNonce_Tips(hf_version, tx, bl.Tips) {
|
||||||
if nil == pre_check.check(tx, false) {
|
if nil == pre_check.check(tx, false) {
|
||||||
@ -269,6 +282,10 @@ func (chain *Blockchain) Create_new_miner_block(miner_address rpc.Address) (cbl
|
|||||||
if tx != nil {
|
if tx != nil {
|
||||||
if int64(tx.Height) < height {
|
if int64(tx.Height) < height {
|
||||||
if height-int64(tx.Height) < TX_VALIDITY_HEIGHT {
|
if height-int64(tx.Height) < TX_VALIDITY_HEIGHT {
|
||||||
|
if history[tx.BLID] != true {
|
||||||
|
logger.V(8).Info("not selecting tx since the reference with which it was made is not in history", "txid", tx_hash_list_sorted[i].Hash)
|
||||||
|
continue
|
||||||
|
}
|
||||||
if nil == chain.Verify_Transaction_NonCoinbase_CheckNonce_Tips(hf_version, tx, bl.Tips) {
|
if nil == chain.Verify_Transaction_NonCoinbase_CheckNonce_Tips(hf_version, tx, bl.Tips) {
|
||||||
|
|
||||||
if nil == pre_check.check(tx, false) {
|
if nil == pre_check.check(tx, false) {
|
||||||
|
@ -267,3 +267,26 @@ func (chain *Blockchain) Load_Block_Topological_order(blid crypto.Hash) int64 {
|
|||||||
}
|
}
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this function is not used in core
|
||||||
|
func (chain *Blockchain) Find_Blocks_Height_Range(startheight, stopheight int64) (blids []crypto.Hash) {
|
||||||
|
_, topos_start := chain.Store.Topo_store.binarySearchHeight(startheight)
|
||||||
|
|
||||||
|
if stopheight > chain.Get_Height() {
|
||||||
|
stopheight = chain.Get_Height()
|
||||||
|
}
|
||||||
|
_, topos_end := chain.Store.Topo_store.binarySearchHeight(stopheight)
|
||||||
|
|
||||||
|
blid_map := map[crypto.Hash]bool{}
|
||||||
|
for i := topos_start[0]; i < topos_end[0]; i++ {
|
||||||
|
if toporecord, err := chain.Store.Topo_store.Read(i); err != nil {
|
||||||
|
panic(err)
|
||||||
|
} else {
|
||||||
|
blid_map[toporecord.BLOCK_ID] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for k := range blid_map {
|
||||||
|
blids = append(blids, k)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -129,8 +129,15 @@ func (chain *Blockchain) Verify_Transaction_NonCoinbase_CheckNonce_Tips(hf_versi
|
|||||||
return fmt.Errorf("no tips provided, cannot verify")
|
return fmt.Errorf("no tips provided, cannot verify")
|
||||||
}
|
}
|
||||||
|
|
||||||
// transaction needs to be expanded. this expansion needs balance state
|
tips_string := tx_hash.String()
|
||||||
|
for _, tip := range tips {
|
||||||
|
tips_string += fmt.Sprintf("%s", tip.String())
|
||||||
|
}
|
||||||
|
if _, found := chain.cache_IsNonceValidTips.Get(tips_string); found {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// transaction needs to be expanded. this expansion needs balance state
|
||||||
version, err := chain.ReadBlockSnapshotVersion(tx.BLID)
|
version, err := chain.ReadBlockSnapshotVersion(tx.BLID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -222,6 +229,7 @@ func (chain *Blockchain) Verify_Transaction_NonCoinbase_CheckNonce_Tips(hf_versi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chain.cache_IsNonceValidTips.Add(tips_string, true) // set in cache
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ func handle_easymenu_post_open_command(l *readline.Instance, line string) (proce
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
a, err := ReadAddress(l)
|
a, err := ReadAddress(l, wallet)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error(err, "error reading address")
|
logger.Error(err, "error reading address")
|
||||||
break
|
break
|
||||||
@ -200,7 +200,7 @@ func handle_easymenu_post_open_command(l *readline.Instance, line string) (proce
|
|||||||
}
|
}
|
||||||
|
|
||||||
// a , amount_to_transfer, err := collect_transfer_info(l,wallet)
|
// a , amount_to_transfer, err := collect_transfer_info(l,wallet)
|
||||||
a, err := ReadAddress(l)
|
a, err := ReadAddress(l, wallet)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error(err, "error reading address")
|
logger.Error(err, "error reading address")
|
||||||
break
|
break
|
||||||
|
@ -384,13 +384,15 @@ func handle_set_command(l *readline.Instance, line string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// read an address with all goodies such as color encoding and other things in prompt
|
// read an address with all goodies such as color encoding and other things in prompt
|
||||||
func ReadAddress(l *readline.Instance) (a *rpc.Address, err error) {
|
func ReadAddress(l *readline.Instance, wallet *walletapi.Wallet_Disk) (a *rpc.Address, err error) {
|
||||||
setPasswordCfg := l.GenPasswordConfig()
|
setPasswordCfg := l.GenPasswordConfig()
|
||||||
setPasswordCfg.EnableMask = false
|
setPasswordCfg.EnableMask = false
|
||||||
|
|
||||||
prompt_mutex.Lock()
|
prompt_mutex.Lock()
|
||||||
defer prompt_mutex.Unlock()
|
defer prompt_mutex.Unlock()
|
||||||
|
|
||||||
|
var linestr string
|
||||||
|
|
||||||
setPasswordCfg.SetListener(func(line []rune, pos int, key rune) (newLine []rune, newPos int, ok bool) {
|
setPasswordCfg.SetListener(func(line []rune, pos int, key rune) (newLine []rune, newPos int, ok bool) {
|
||||||
error_message := ""
|
error_message := ""
|
||||||
color := color_green
|
color := color_green
|
||||||
@ -398,7 +400,11 @@ func ReadAddress(l *readline.Instance) (a *rpc.Address, err error) {
|
|||||||
if len(line) >= 1 {
|
if len(line) >= 1 {
|
||||||
_, err := globals.ParseValidateAddress(string(line))
|
_, err := globals.ParseValidateAddress(string(line))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
error_message = " " //err.Error()
|
if linestr, err = wallet.NameToAddress(string(strings.TrimSpace(string(line)))); err != nil {
|
||||||
|
error_message = " " //err.Error()
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,7 +413,6 @@ func ReadAddress(l *readline.Instance) (a *rpc.Address, err error) {
|
|||||||
l.SetPrompt(fmt.Sprintf("%sEnter Destination Address: ", color))
|
l.SetPrompt(fmt.Sprintf("%sEnter Destination Address: ", color))
|
||||||
} else {
|
} else {
|
||||||
l.SetPrompt(fmt.Sprintf("%sEnter Destination Address: ", color))
|
l.SetPrompt(fmt.Sprintf("%sEnter Destination Address: ", color))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
l.Refresh()
|
l.Refresh()
|
||||||
@ -418,7 +423,12 @@ func ReadAddress(l *readline.Instance) (a *rpc.Address, err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
a, err = globals.ParseValidateAddress(string(line))
|
if linestr == "" {
|
||||||
|
a, err = globals.ParseValidateAddress(string(line))
|
||||||
|
} else {
|
||||||
|
a, err = globals.ParseValidateAddress(string(linestr))
|
||||||
|
}
|
||||||
|
|
||||||
l.SetPrompt(prompt)
|
l.SetPrompt(prompt)
|
||||||
l.Refresh()
|
l.Refresh()
|
||||||
return
|
return
|
||||||
|
@ -330,7 +330,11 @@ func main() {
|
|||||||
func readline_loop(l *readline.Instance, chain *blockchain.Blockchain, logger logr.Logger) (err error) {
|
func readline_loop(l *readline.Instance, chain *blockchain.Blockchain, logger logr.Logger) (err error) {
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
err = globals.Recover(0)
|
if r := recover(); r != nil {
|
||||||
|
logger.V(0).Error(nil, "Recovered ", "error", r)
|
||||||
|
err = fmt.Errorf("crashed")
|
||||||
|
}
|
||||||
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
restart_loop:
|
restart_loop:
|
||||||
|
@ -120,7 +120,7 @@ func GetEncryptedBalance(ctx context.Context, p rpc.GetEncryptedBalance_Params)
|
|||||||
Bits: bits, // no. of bbits required
|
Bits: bits, // no. of bbits required
|
||||||
Height: toporecord.Height,
|
Height: toporecord.Height,
|
||||||
Topoheight: topoheight,
|
Topoheight: topoheight,
|
||||||
BlockHash: fmt.Sprintf("%x", toporecord.BLOCK_ID),
|
BlockHash: toporecord.BLOCK_ID,
|
||||||
Merkle_Balance_TreeHash: fmt.Sprintf("%x", merkle_hash[:]),
|
Merkle_Balance_TreeHash: fmt.Sprintf("%x", merkle_hash[:]),
|
||||||
DHeight: chain.Get_Height(),
|
DHeight: chain.Get_Height(),
|
||||||
DTopoheight: chain.Load_TOPO_HEIGHT(),
|
DTopoheight: chain.Load_TOPO_HEIGHT(),
|
||||||
|
@ -367,8 +367,8 @@ func Test_Creation_TX(t *testing.T) {
|
|||||||
t.Logf("dst pre %d post %d", pre_transfer_dst_balance, post_transfer_dst_balance)
|
t.Logf("dst pre %d post %d", pre_transfer_dst_balance, post_transfer_dst_balance)
|
||||||
// we sent 1+1 from src
|
// we sent 1+1 from src
|
||||||
// we sent 1 from dst to src
|
// we sent 1 from dst to src
|
||||||
if pre_transfer_src_balance-post_transfer_src_balance != 1 {
|
if pre_transfer_src_balance-post_transfer_src_balance != 1+dtx.Fees()+reverse_dtx.Fees() {
|
||||||
t.Fatalf("transfer failed.Invalid balance expected %d actual %d", 1, pre_transfer_src_balance-post_transfer_src_balance)
|
t.Fatalf("transfer failed.Invalid balance expected %d actual %d", 1, pre_transfer_src_balance-(post_transfer_src_balance+dtx.Fees()+reverse_dtx.Fees()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// fmt.Printf("balance src %v\n", wsrc.account.Balance_Mature)
|
// fmt.Printf("balance src %v\n", wsrc.account.Balance_Mature)
|
||||||
|
@ -20,4 +20,4 @@ import "github.com/blang/semver/v4"
|
|||||||
|
|
||||||
// right now it has to be manually changed
|
// right now it has to be manually changed
|
||||||
// do we need to include git commitsha??
|
// do we need to include git commitsha??
|
||||||
var Version = semver.MustParse("3.4.63-1.DEROHE.STARGATE+12112021")
|
var Version = semver.MustParse("3.4.65-1.DEROHE.STARGATE+13112021")
|
||||||
|
@ -807,7 +807,6 @@ func trigger_sync() {
|
|||||||
|
|
||||||
for _, value := range unique_map {
|
for _, value := range unique_map {
|
||||||
clist = append(clist, value)
|
clist = append(clist, value)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort the list random
|
// sort the list random
|
||||||
|
@ -21,15 +21,15 @@ import "testing"
|
|||||||
// this function will prove detect and decode output amount for the tx
|
// this function will prove detect and decode output amount for the tx
|
||||||
func Test_Prove(t *testing.T) {
|
func Test_Prove(t *testing.T) {
|
||||||
|
|
||||||
var proof = "deroproof1qy24csrhmq90tdh7cr4njrykph9ymuqqkrly42s22n3eh3xdzkklvqdzvfyyskpqjrh5tp9gdasplscd4yegt9zctlt6e02cj8ftpa967v6md5v2ctyky4j4rgqqrdkevc4nyr"
|
var proof = "deroproof1qyzlkv8x5cp7tgh3eeqjuu6nenaf0vfjcpm3fl784tkaa6tqpz2jsqdzvfyyskpq0kjaju7h2lw6h48g7fjsmgamxex0szh65f59tk7k82g3f39yt46ky4j4rgqqrp4q0wqa3c"
|
||||||
var ring_address = [][]string{{
|
var ring_address = [][]string{{
|
||||||
"deto1qyre7td6x9r88y4cavdgpv6k7lvx6j39lfsx420hpvh3ydpcrtxrxqg8v8e3z",
|
|
||||||
"deto1qy35yu06tu4uyakeqxen6nh2g3ltgwwstrk5unh573hwq6w7sz3pcqqxfmhzz",
|
|
||||||
"deto1qywaj56ew38wjrpsq4wwrjj6nlsngu8ytluadhekyhr6s7fh2dmjuqg75x2nm",
|
|
||||||
"deto1qyx7qyvrtrhvaszeej487k2g689fav7h38ay37fja9qf40ycgl0m2qg8ap2y9",
|
"deto1qyx7qyvrtrhvaszeej487k2g689fav7h38ay37fja9qf40ycgl0m2qg8ap2y9",
|
||||||
|
"deto1qyre7td6x9r88y4cavdgpv6k7lvx6j39lfsx420hpvh3ydpcrtxrxqg8v8e3z",
|
||||||
|
"deto1qysmp3ws28pkvas04cenrgmcjth8cavhd4z0x3xf0x0sl4033vlm6qgwhjz05",
|
||||||
|
"deto1qypytjjcdzuqq05flnnlvcvja87672g0444rywvqvfq7szyv63ly7qgrkv0xg",
|
||||||
}}
|
}}
|
||||||
|
|
||||||
var tx_hex = "01000003030100000000000000000000000000000000000000000000000000000000000000000000c5d59d096efe0624f776e5e81bfa6d38f19aeefff57d999fb76883392ee4d6a55cb04d7f74c6ddf3a5ec55bcb848b8e46283468af1513ffb581daaa8b7879abe5be5963c65b4918818954d2397be09a7b1c10fce1692c7fa32bb2d06f2cc2ded949bc18335ed32fd92ef703d9f55282e50fffe18103440647577b31297f891144e970e2a6b7e034fd926dc380d304b0b6e02030012f8012f6cddc1850a6fb2766d585bcf285a086b78f7bfc4f25e0cc40aac8cfa00a12fda5e3799e9246044ead00ff1f19fca461d7e255a7af87f2909bbad036196018e7cea50686107e6c625d20003bd194ae43426600e745c0d253a2d679dd93fb79a7f3c4b071a62d5f84e6232012f920ed92f2ddb2efbacb27e4bad256233ba0227d20b1f6753448b80787c467d000c9d77a2a93e516fc8d445b92fb87138616ccab9425a8b03dba1b452243c82f601bf091517d58e1620cf31b1b44ce68ea4cd2a0eb89342cd400ba09a015a8cc2693044e7b42d37879ff60609bb3bf65587bfd2811bc052ddbb164397164091fe8201132ca6567a44b63a8ab79e6f6bb6b783a23cccefc60b19caeae407a1bde6ba29012599faeed73f71639cd8cad6ae349b88d327d1b28d5dee6fbceb31e06238804e01209a5bbea37113654461558a84dac6c1b9d908998ab7df7745611c45bbc69073002787aa2f8fbe2c96adec3b22dcbc3288f9a19813ee26389a9dc7112e634d854a001c786445883d4a9ff64ab67ac238ec805601909f029cff18a2bd9dd43d5dd08f011096f90ec4528085dd60ce7b9b40e7a13c4c6b682fb37b0f65f3625edc5a6fd90011ad2d65c97b025068f0220bb49d6e8473e2927b045fcac360e7d7925e51592f000fbea3321a3e61da67e82e8fb85fa278dbb35ae96da7195c0d9a5207915b9d02002a7a2eda627caa376051379d7e160a147b2ff20d7956741df1bd3e8bb702a7160016e5b5ea07306beff5ebee45c866298be2efefd277b883f8e717a8aad0794a5e0018a8e9fc2af18cf23fe26fdd84bc501f52a64f67a1b8839b61453afc681e02f3012eff2daca0d8857b529625cecffab7816f364636e9ad9ea4949286d76a5528740006a55b12300cbc5d279e3c6278b48cd45b9fa4ebf8f32301ab0e34c39bcb01f3001c3221b95842774c6d4782cf7bf0bdbee47a390ee507593aeb060fc22b562118002149ca7f5682d4383affa31f9b5fe91663671fbf6e0c86a2681150de8e371d8f011ec67465b20d6516a476258801ed75898a4ac21b1c66f661ccc78a4ee57f94b7001d3599550f322a85a28763dbd6aa440ef1c484602535aa120490e3c403c10567011d944754272ed2637fa8458d825dc4318ef4f4691ec5426620542f77d341655f01089816eb3f43825508cfa31a89a93c626911dfef0d1aa1365300bb90e3bdefee0115d135a01a05c0c13c989c10227e354ccdba6bba820fd6ba15aad825a5088b2c00000000000000000000000000000000000000000000000000000000000000000025e9e7b994c9e4f495ae4e208cacd44078efed3e3b96c455af8966cedbadac8303aff8687c6e5eee2e5587dd01d830b8f5b314b1dd7a2662bfbbe91b547d1679160a0f59543e6877088b138d1c02b7c626f2a42f3bb50d38d4369805d4674962255f8a0cbf09d3f14c3c1f3b386a414cd18cd56bdac89fc35896a7db045044c41893024f3cec7bd74c99f2ae029c56750b598b4958d17666ee3cd06a36dc3b000013e11d8b0b17205d32b47b097a11e616dc352a1f4223da945f7c741de0834a0b01169422af606adef80e00559470b4e71c84c03da141bf6bb619feeb91d55bcae40481e14e67c0ae1489f7f01843845bf26482e1f2d72fa4bbde1386a4e74fd5a3191edd62e81be2bc1b47ca8711e98199334b27a0bdd3ea03f041bc342a3ea6b32c92c5b5d2b7c3196335fdf58fe5293ea21b465d081bc9fb10e55bce480bd07019ee788c080839f5da2dc3a43774de76b27c9c6391b91255d89731cd03ee546400d64e8b28eb1cbcaaadb8fa75ca0cee438a9ef8f32465ab148b0354973dc1c70e1b0a5629156b64fb3fb213c9971cd35d32b1e1c4d5bf8a9a14d8da092f0a961cbacca34c22b4e4ec35f68d0827b538b2604c9f9566fb4a478beb1a77de07c2104ba1f6c184586263473a1ef8081bc0c126376f72589d86bfbbb57dd3897ff616a81723f93c52199594327d775296a175d29691dc715820a6e60b63417a1f37010da1c0b870d0aeb44845f8a190021fd15e5b02c8c23e2c662e90b69e490b597c0015e0c97936ee5fd8f76e0b8c531eb97be6f44020836eeb09f7651fdfe395db3b0000f20bab4dc90e1b58c794e84e8322c692116d60b44480182a5d02f1ad6e2089012febbc7375180949d38774ebc4a29a8a66b1ce117d7886ec4e9e69d90463a387011c6bc2f8977fd7da0aff7e76a79e273ea82773ae0a028cdaea53936b47f050d5010512cd6f442f22cb5456643df0924821e3943a9f156f6bfc55ff47ee7d24b12b000d638109aa8e4321d11945296fe1d0a3ed590d896ae710e6372f8471ae25d10e002296b6e4f9e598031f317e95184f030e8906533974b40013fb82aa3cf2b14edd01147cf372588499147eb6954aeb27aed1a3893b229ce94801fce5f295207123a2001642efb349312fe6b67eb52508968ea17e0b98a94aa5b2ad4f1424c90338871d010c782f8548719218fda4ea9bf7967cf2683f72a15cd1b1d3250cc842c54756ff012b76046c131e90c0b177cbd859c9236cfc62a2e1c090d5cac38a924a5dcfa1170007720f6d0254dd7f7f9976f58e484da2da0aea1dad7e4dd4c3724363717f1ef400"
|
var tx_hex = "01000003519b9e874a9dd7fcbfb7802268123dcf970c336891101a3a0705855b72b9eb08c80100000000000000000000000000000000000000000000000000000000000000000000f394d06566a81b024fd8624b4c8592f8b9344e58f227261eb08d821bd190b4ac9c7df0660038ddcf881602a14fe5ad8eebff83d3ce3541a1f232fe61acf71109e417160936863e8c0597c798b73ef08e76b8eeebcaf20260ba91fcdef5f626361f824dc6197b02c599d4511c624a933226d8fccc125611ec80d8ad5acea4baf2f1c77e4c5525d9859b40f43daaf3d4e4450203d80419dcb026b9adbd7d6912284ee9ce20f3721076947f16e1faefd9b8c35116f4cf0044ead0a12fda3f3bcf2ed91627b922c02c10d112df9e782d3750cda151f6ba2ebe6495065141f32800894566011198c4055458005a31d3e285037446ba14bac54420bcab87cbebeaccab1f158b011e90132b7310e6c866e348cab68d21bad1d9f811b4d667a1e40bdef1a19259d3000b972ae06da958658b12ca4a45c2c6ea50d305be86f7e979fc962c687eb012f401a2c4bf0beb6c713343b94d65ee6d937660480daf670ab5b0ed421a9103e8a25119c836dd799600e67e4ec66ef680833398a99b16956aed2ee5bd9e6c8e68009a01145636e5e448d6c8ab902db394aa9c5aeee92dd150e1150d5b8f6674f330c279010912df27232ae126525a130ed8a9b4dee62eb57ce1d8a42ae9bcef867b10ce94012f94aa78846fcdda504243f83f3122aee5dc38dd32fa2a90224b3a40b4cf79c301129028709e39591c55e6e477a36cc26dc2efd7183fb59f51635dbd114dfed9d5010d66f31b781fa181c2114600ee1f03d55439355265700fb9d35ac684a19db398001e12558cc17e59fb85fb825481dee6fef3612c043bb38ca4833183da5381364600077a99d4d2df2f06067359f178a40f98a3e0943309c5ce3ce5398b9909174254012aa49cfc78ebec51c00e7824db0d8d41ef43fbb0396824d2c31b7db64124cc61000a8b51bd6c94a502f7aea3e5001f00d76b165ad580e48f8aa72813da8240286e00055f3480aa7cdb68a20d4b1e567d42389b44cf4e345da9e5a5655a80418695bc012c8f1e1ef8af646b4fb08afaeb3febde17c4c0d04b30dfd22d96a32ced9c9439010c40484e1547d307ad56b79bb7450e4eaaed7ed79bd5392dffd7449043f8783a0015104264f8d80356176ca6fdf4777e4ebc8edcbab50f8b6c366ac75ebd6bb5c701078d55053d2d41f21f51d5e617f282ba9dfa2576f0231048dd73998ceaa699fd0105821b61addd6935c7d80e65c706f0f2aa2d73ad22c5548c9c8b92cd82689dc40115f576c413a37014b9ee5377b121c69ad6e0f00f2b4f6c99d1f68b00a5d923370119b29fe6e9cf35f1344e24d52ee1fdb6521de3176f3d2b2a2b9327ae6e6cfbb10017198369a6ff180253700361c40e7f378c8e7ead6e04f01dbf5b4c47e7e1e4ff001abaf84628764eccbc5d0f66dc0a99505bb0e598362c45312470526afad11caf00242c6a902c564b3b363eb4ae08f643f18571779428358bfbdaf9856b0ebf229f0100000000000000000000000000000000000000000000000000000000000000001b7a78b6f573d4ac5d3a8d7d10dafac0dbc92604474417b29d40448d9fbc821d0fe3f73da41b27752d5db0658fcc0bff7da21112417ac719e491fdd43c8e5d0b07bcca22c27367a276e6a4e0cfb1bfbc772842898356ad4723101d4ada5137f409bb3b290d7519da3af15feb09e183e2be809690099551f1cb984deb1295b7611dd0cfd9000482314a388512d278fc22b2f6e3fc6e95023b4bd228e22626b7440119fa2c6f45a33b008ef5b23a5522ebbf0bf5f26d8263613a7f9b5ad9a192357600107a023453f7f79f413756dfba0096ae5d13158bbbb147089a020e819ef6640728acf01c811b967d1a14d767ac20088c5ca1613aa5d94ebe7fe2840b6431d8d002137dae183071d12cd9fb14c4b4738ef750ff514ce26257d1245eaedfea625516bfcb075a33a8910dc4e40742bfaa70d95591711e9db33d0db0be06cc819817072c22a9c81f4369f68bb1ef71c7f7458671d647caef18b30cca91da4f1b201d082a03306b4a07d1f0e1a8cc8844038fc524201a6c3a346a971203fd45458d292987d44049eecdac25c5622465a8d683a43621612d2fb283724b17a7bfa3bad2266a6fb1cf669eef21c90e24e85d6ab48e8b237355e964407dde00d65fb442dd210ce0378349f533c0e8ab65293de5319e246a044ed22b1e6db28add1508dd6f0da22954eea8a431b211a8b54147e32fec6593f9fb731389f62f94d5047e0f3301216576c71a79629bc3879325280e216d59cf7e6ff2d6a0babe418f8f2ed603ce010e16785f8c855043221ed5a603d4ed4e8e90059669543738ceb2a04dc996079c01264e9beaf4bb82e1b8f47bb0c239167064001e306eeef2b5495ec42754806b65012357f738543b13594ff081a070dbc0575645ac5ce8e0f89d3afdeb3d49e9ddae012a17d5095b9cef08f6eee2ce733dbf2cfcdb8c23e39410ed973e68cf8505266d00280c52b45752dd12ba84499618898111a8f9b19f2b76c06917e57eef221f3387011cc3360b478d144118a82a3c4391814f34aac2fb0f2d043394304bed179689e501292ca5631820f5f465242b4cc517f06c153c176a43f77daca463b7e2d3e2d7ba001aa0b2c90c3172cd2556137d78748f47924432449210d8b2f5e27adb6210bc77012c92a12526a5b0b1ef60994eb4d08e9bb5a3ea330d417838a52ad8636d37fa9e00131153c9affeefd6b98ecb6a80f5e6ea97417376030325182c064e12dd353c32011f4e25c49eea09adaa46d56642e2ea0afced2d75036acd3839435863f1ec3bf1002e19fe8456a7236c8fb77a15f87164debaad865e85c3468152a5deaffde3da6a01"
|
||||||
|
|
||||||
mainnet := true
|
mainnet := true
|
||||||
receivers, amounts, payload_raw, payload_decoded, err := Prove(proof, tx_hex, ring_address, mainnet)
|
receivers, amounts, payload_raw, payload_decoded, err := Prove(proof, tx_hex, ring_address, mainnet)
|
||||||
@ -45,8 +45,8 @@ func Test_Prove(t *testing.T) {
|
|||||||
t.Fatalf("Proving transaction failed expected 1,1 actual %d,%d", len(receivers), len(amounts))
|
t.Fatalf("Proving transaction failed expected 1,1 actual %d,%d", len(receivers), len(amounts))
|
||||||
}
|
}
|
||||||
|
|
||||||
if amounts[0] != 112345 {
|
if amounts[0] != 100000 {
|
||||||
t.Fatalf("Proving transaction failed expected 112345, actual %d", amounts[0])
|
t.Fatalf("Proving transaction failed expected 100000, actual %d", amounts[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ type (
|
|||||||
type (
|
type (
|
||||||
NameToAddress_Params struct {
|
NameToAddress_Params struct {
|
||||||
Name string `json:"name"` // Name for look up
|
Name string `json:"name"` // Name for look up
|
||||||
TopoHeight uint64 `json:"topoheight,omitempty"` // lookup in reference to this topo height
|
TopoHeight int64 `json:"topoheight,omitempty"` // lookup in reference to this topo height
|
||||||
} // no params
|
} // no params
|
||||||
NameToAddress_Result struct {
|
NameToAddress_Result struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
@ -155,7 +155,7 @@ type (
|
|||||||
Bits int `json:"bits"` // no. of bits required to access the public key from the chain
|
Bits int `json:"bits"` // no. of bits required to access the public key from the chain
|
||||||
Height int64 `json:"height"` // at what height is this balance
|
Height int64 `json:"height"` // at what height is this balance
|
||||||
Topoheight int64 `json:"topoheight"` // at what topoheight is this balance
|
Topoheight int64 `json:"topoheight"` // at what topoheight is this balance
|
||||||
BlockHash string `json:"blockhash"` // blockhash at this topoheight
|
BlockHash crypto.Hash `json:"blockhash"` // blockhash at this topoheight
|
||||||
Merkle_Balance_TreeHash string `json:"treehash"`
|
Merkle_Balance_TreeHash string `json:"treehash"`
|
||||||
DHeight int64 `json:"dheight"` // daemon height
|
DHeight int64 `json:"dheight"` // daemon height
|
||||||
DTopoheight int64 `json:"dtopoheight"` // daemon topoheight
|
DTopoheight int64 `json:"dtopoheight"` // daemon topoheight
|
||||||
|
@ -248,6 +248,30 @@ func (w *Wallet_Memory) Sync_Wallet_Memory_With_Daemon() (err error) {
|
|||||||
return w.Sync_Wallet_Memory_With_Daemon_internal(scid)
|
return w.Sync_Wallet_Memory_With_Daemon_internal(scid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *Wallet_Memory) NameToAddress(name string) (addr string, err error) {
|
||||||
|
if name == "" {
|
||||||
|
return addr, fmt.Errorf("empty string is not a valid address")
|
||||||
|
}
|
||||||
|
|
||||||
|
if !IsDaemonOnline() {
|
||||||
|
err = fmt.Errorf("offline or not connected. cannot send transaction.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var result rpc.NameToAddress_Result
|
||||||
|
if err = rpc_client.Call("DERO.NameToAddress", rpc.NameToAddress_Params{Name: name, TopoHeight: -1}, &result); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if result.Status == "OK" {
|
||||||
|
addr = result.Address
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
err = fmt.Errorf("Err %s", result.Status)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// this is as simple as it gets
|
// this is as simple as it gets
|
||||||
// single threaded communication to relay TX to daemon
|
// single threaded communication to relay TX to daemon
|
||||||
// if this is successful, then daemon is in control
|
// if this is successful, then daemon is in control
|
||||||
@ -401,12 +425,7 @@ func (w *Wallet_Memory) GetEncryptedBalanceAtTopoHeight(scid crypto.Hash, topohe
|
|||||||
var nb crypto.NonceBalance
|
var nb crypto.NonceBalance
|
||||||
nb.Unmarshal(hexdecoded)
|
nb.Unmarshal(hexdecoded)
|
||||||
|
|
||||||
var block_hash crypto.Hash
|
return result.Bits, nb.NonceHeight, result.BlockHash, nb.Balance, nil
|
||||||
if err = block_hash.UnmarshalText([]byte(result.BlockHash)); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
return result.Bits, nb.NonceHeight, block_hash, nb.Balance, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Wallet_Memory) DecodeEncryptedBalance_Memory(el *crypto.ElGamal, hint uint64) (balance uint64) {
|
func (w *Wallet_Memory) DecodeEncryptedBalance_Memory(el *crypto.ElGamal, hint uint64) (balance uint64) {
|
||||||
|
@ -64,21 +64,6 @@ func Transfer(ctx context.Context, p rpc.Transfer_Params) (result rpc.Transfer_R
|
|||||||
p.SC_RPC = append(p.SC_RPC, rpc.Argument{Name: rpc.SCID, DataType: rpc.DataHash, Value: crypto.HashHexToHash(p.SC_ID)})
|
p.SC_RPC = append(p.SC_RPC, rpc.Argument{Name: rpc.SCID, DataType: rpc.DataHash, Value: crypto.HashHexToHash(p.SC_ID)})
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// if you need to send tx now mostly for testing purpose use this
|
|
||||||
tx, err := w.wallet.TransferPayload0(p.Transfers, false, p.SC_RPC, false)
|
|
||||||
if err != nil {
|
|
||||||
rlog.Warnf("Error while building Transaction err %s\n", err)
|
|
||||||
return err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
err = w.wallet.SendTransaction(tx)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
tx, err := w.wallet.TransferPayload0(p.Transfers, p.Ringsize, false, p.SC_RPC, false)
|
tx, err := w.wallet.TransferPayload0(p.Transfers, p.Ringsize, false, p.SC_RPC, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.logger.V(1).Error(err, "Error building tx")
|
w.logger.V(1).Error(err, "Error building tx")
|
||||||
@ -92,14 +77,5 @@ func Transfer(ctx context.Context, p rpc.Transfer_Params) (result rpc.Transfer_R
|
|||||||
|
|
||||||
// we must return a txid if everything went alright
|
// we must return a txid if everything went alright
|
||||||
result.TXID = tx.GetHash().String()
|
result.TXID = tx.GetHash().String()
|
||||||
|
|
||||||
/*
|
|
||||||
uid, err := w.wallet.PoolTransfer(p.Transfers, p.SC_RPC)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
|
|
||||||
}
|
|
||||||
_ = uid
|
|
||||||
*/
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
@ -375,8 +375,8 @@ func Test_Creation_TX(t *testing.T) {
|
|||||||
t.Logf("dst pre %d post %d", pre_transfer_dst_balance, post_transfer_dst_balance)
|
t.Logf("dst pre %d post %d", pre_transfer_dst_balance, post_transfer_dst_balance)
|
||||||
// we sent 1+1 from src
|
// we sent 1+1 from src
|
||||||
// we sent 1 from dst to src
|
// we sent 1 from dst to src
|
||||||
if pre_transfer_src_balance-post_transfer_src_balance != 1 {
|
if pre_transfer_src_balance-post_transfer_src_balance != 1+dtx.Fees()+reverse_dtx.Fees() {
|
||||||
t.Fatalf("transfer failed.Invalid balance expected %d actual %d", 1, pre_transfer_src_balance-post_transfer_src_balance)
|
t.Fatalf("transfer failed.Invalid balance expected %d actual %d", 1, pre_transfer_src_balance-(post_transfer_src_balance+dtx.Fees()+reverse_dtx.Fees()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// fmt.Printf("balance src %v\n", wsrc.account.Balance_Mature)
|
// fmt.Printf("balance src %v\n", wsrc.account.Balance_Mature)
|
||||||
|
@ -163,9 +163,8 @@ func (w *Wallet_Memory) TransferPayload0(transfers []rpc.Transfer, ringsize uint
|
|||||||
}
|
}
|
||||||
|
|
||||||
for t := range transfers {
|
for t := range transfers {
|
||||||
saddress := transfers[t].Destination
|
|
||||||
|
|
||||||
if saddress == "" { // user skipped destination
|
if transfers[t].Destination == "" { // user skipped destination
|
||||||
if transfers[t].SCID.IsZero() {
|
if transfers[t].SCID.IsZero() {
|
||||||
err = fmt.Errorf("Main Destination cannot be empty")
|
err = fmt.Errorf("Main Destination cannot be empty")
|
||||||
return
|
return
|
||||||
@ -182,7 +181,6 @@ func (w *Wallet_Memory) TransferPayload0(transfers []rpc.Transfer, ringsize uint
|
|||||||
}
|
}
|
||||||
for _, k := range w.Random_ring_members(scid) {
|
for _, k := range w.Random_ring_members(scid) {
|
||||||
if k != w.GetAddress().String() {
|
if k != w.GetAddress().String() {
|
||||||
saddress = k
|
|
||||||
transfers[t].Destination = k
|
transfers[t].Destination = k
|
||||||
i = 1000000 // break outer loop also
|
i = 1000000 // break outer loop also
|
||||||
ring_count++
|
ring_count++
|
||||||
@ -193,13 +191,16 @@ func (w *Wallet_Memory) TransferPayload0(transfers []rpc.Transfer, ringsize uint
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if saddress == "" {
|
if transfers[t].Destination == "" {
|
||||||
err = fmt.Errorf("could not obtain random ring member for scid %s", transfers[t].SCID)
|
err = fmt.Errorf("could not obtain random ring member for scid %s", transfers[t].SCID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if _, err = rpc.NewAddress(saddress); err != nil {
|
|
||||||
fmt.Printf("err processing address '%s' err '%s'\n", saddress, err)
|
// try to resolve name to address here
|
||||||
return
|
if _, err = rpc.NewAddress(transfers[t].Destination); err != nil {
|
||||||
|
if transfers[t].Destination, err = w.NameToAddress(transfers[t].Destination); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,6 +232,8 @@ func (w *Wallet_Memory) TransferPayload0(transfers []rpc.Transfer, ringsize uint
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
height := uint64(er.Height)
|
height := uint64(er.Height)
|
||||||
|
block_hash = er.BlockHash
|
||||||
|
topoheight = er.Topoheight
|
||||||
treehash := er.Merkle_Balance_TreeHash
|
treehash := er.Merkle_Balance_TreeHash
|
||||||
|
|
||||||
treehash_raw, err := hex.DecodeString(treehash)
|
treehash_raw, err := hex.DecodeString(treehash)
|
||||||
|
Loading…
Reference in New Issue
Block a user