Bitcoin Forum
April 26, 2024, 12:20:43 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: shared payments - поделенные платежи  (Read 1523 times)
icreator (OP)
Legendary
*
Offline Offline

Activity: 1554
Merit: 1008



View Profile WWW
October 02, 2014, 03:59:03 AM
Last edit: October 02, 2014, 09:13:31 AM by icreator
 #1

Есть потребность одним платежом раскидывать на много адресов с разными весовыми коэффициентами

сейчас приходится для этого пользоваться сторонними службами - в случае если часть и большие списки

а что если в самом клиенте создать эту возможность?

делаем так называемый shared address - в который записываем список адресов с весовыми коэффициентами:

Code:
shadrr_list = { "addr1": 2, "addr2": 0.33, ... }

для этого в API:
Code:
# создать и сохранить в wallet.dat список, так чтобы изменить этот список нельзя было
shaddr = makesharedaddress( shaddr_list, label )
# причем создается адрес на 1 символ длинее - с добавкой 'S':
shaddr --> 'S1NilT.....13Gfas'
len(shaddr ) --> 35

Чтобы послать всем поделенные платежи вызываем команду API:
Code:
sendshared( shaddr, amount )

тело функции (послать поленные платежи) примерно такое
Code:
################## on python
def sendshared( shaddr, amount ):
  if not amount > 0: return 'error'
  # calc sum
  sum = 0.0
  for v in shaddrs:
    if v>0:
      sum += v

  # recalc amo_outs
  list_out = {}
  for (k, v) in shaddrs.iteritems():
    if v>0:
      list_out[k] = round(amount *v / sum, 8)

  sum_out = 0.0
  for v in list_out:
    sum_out += v
  diff = amount - sum_out
  # ну и раскидать разницу по 0.00000001 случайно на адреса
  while diff>0:
    diff -= 0.00000001
    list_out[random_key[list_out]] += 0.00000001

  return connection.sendmany(list_out)
#################

Erachain Blockchain is fully ready for use Digital Ecosystem based on blockchain technology for business and government with low transaction costs, identification and built-in functions.
+Decentralized exchange of tokens in Erachain
1714134043
Hero Member
*
Offline Offline

Posts: 1714134043

View Profile Personal Message (Offline)

Ignore
1714134043
Reply with quote  #2

1714134043
Report to moderator
Every time a block is mined, a certain amount of BTC (called the subsidy) is created out of thin air and given to the miner. The subsidy halves every four years and will reach 0 in about 130 years.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
ArsenShnurkov
Legendary
*
Offline Offline

Activity: 1386
Merit: 1000



View Profile
October 02, 2014, 08:27:12 AM
 #2

поздравляю, ты придумал бюджетный автомат
icreator (OP)
Legendary
*
Offline Offline

Activity: 1554
Merit: 1008



View Profile WWW
October 02, 2014, 08:46:36 AM
 #3

его много кто придумал и он даже есть на моих сервисах

но зачем? когда каждый мог бы в своем кошельке это сделать автоматом

Erachain Blockchain is fully ready for use Digital Ecosystem based on blockchain technology for business and government with low transaction costs, identification and built-in functions.
+Decentralized exchange of tokens in Erachain
GGUL
Legendary
*
Offline Offline

Activity: 1468
Merit: 1102


View Profile
October 02, 2014, 08:59:41 AM
 #4

Навскидку..
Надо проверять (в общем случае):

- Отрицательные доли
-  amount >0
- sum >0
- diff может быть > 0, может быть <0
- diff нельзя распределять на нулевые суммы
- после распределения diff не должно получиться  отрицательных сумм
- не очень хорошо всю погрешность кидать на одну сумму.
- после распределения некоторые суммы могут получиться равным 0

думаю, что это не полный перечень. Smiley
icreator (OP)
Legendary
*
Offline Offline

Activity: 1554
Merit: 1008



View Profile WWW
October 02, 2014, 09:11:03 AM
 #5

добавил проверку на отриц доли

все должно пахать

Erachain Blockchain is fully ready for use Digital Ecosystem based on blockchain technology for business and government with low transaction costs, identification and built-in functions.
+Decentralized exchange of tokens in Erachain
icreator (OP)
Legendary
*
Offline Offline

Activity: 1554
Merit: 1008



View Profile WWW
October 02, 2014, 09:14:13 AM
 #6


- не очень хорошо всю погрешность кидать на одну сумму.
random_key

Erachain Blockchain is fully ready for use Digital Ecosystem based on blockchain technology for business and government with low transaction costs, identification and built-in functions.
+Decentralized exchange of tokens in Erachain
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!