syntax cleanup

This commit is contained in:
timlucmiptev 2020-11-19 11:11:02 +02:00 committed by ixv
parent 83cf3a4b45
commit 663aacbc23
2 changed files with 11 additions and 10 deletions

View File

@ -86,10 +86,10 @@ Uses `btc-wallet-hook`, with max-gap=3
=eny1 0v3uc.iuebi.5qilc.l8d87.c1k6n.7iksq.nkobs.8s5he.raq40.9ff0b.5tj3u.kjtg7.aq59e.hatv7.oioam.mlsr4.pqqcd.cnbjn.pnpi2.1m5rt.k4scg =eny1 0v3uc.iuebi.5qilc.l8d87.c1k6n.7iksq.nkobs.8s5he.raq40.9ff0b.5tj3u.kjtg7.aq59e.hatv7.oioam.mlsr4.pqqcd.cnbjn.pnpi2.1m5rt.k4scg
=eny2 0v1gt.mc4ca.lfs0m.q1dal.lqobu.mmlbd.2umnp.lj9dr.4pf4s.pvclr.dps96.4a6i8.rt6n9.krp0r.11kqu.ckqe4.1tmat.gr754.463aj.a4b41.jj7qg =eny2 0v1gt.mc4ca.lfs0m.q1dal.lqobu.mmlbd.2umnp.lj9dr.4pf4s.pvclr.dps96.4a6i8.rt6n9.krp0r.11kqu.ckqe4.1tmat.gr754.463aj.a4b41.jj7qg
=inputs ~[[u(value val0) %0 0] [u(value val1) %0 2] [u(value val2) %0 1] [u(value val3) %1 2]] =inputs ~[[u(value val0) %0 0] [u(value val1) %0 2] [u(value val2) %0 1] [u(value val3) %1 2]]
(~(single-random-draw sut:bwsl [*walt:bwsl eny1 400.100 100 2]) inputs) (~(single-random-draw sut:bwsl [*walt:bwsl eny1 400.100 100 2]) inputs)
(~(single-random-draw sut:bwsl [*walt:bwsl eny2 400.100 100 2]) inputs)(~(single-random-draw sut:bwsl [*walt:bwsl eny2 400.100 100 2]) inputs) (~(single-random-draw sut:bwsl [*walt:bwsl eny2 400.100 100 2]) inputs)
``` ```
Above tests w 2 outputs, total fees with 2 inputs of 27.500. Gives: Above tests w 2 outputs, total fees with 2 inputs of 27.500. Gives:

View File

@ -114,17 +114,17 @@
%+ add base-weight %+ add base-weight
(mul input-weight (lent selected)) (mul input-weight (lent selected))
:: value of an input after fee :: value of an input after fee
:: 0 if net is <= 0 :: 0 if net is <= 0
:: ::
++ net-value ++ net-value
|= val=sats ^- sats |= val=sats ^- sats
=/ cost (mul input-weight feyb) =/ cost (mul input-weight feyb)
?: (lte val cost) 0 ?: (lte val cost) 0
(sub val cost) (sub val cost)
:: Uses naive random selection. Should switch to branch-and-bound later :: Uses naive random selection. Should switch to branch-and-bound later.
:: ::
++ select-utxos ++ select-utxos
|^ ^- (unit (list input)) |^ ^- (unit [=vbytes (list input)])
%- single-random-draw %- single-random-draw
%- zing %- zing
(turn ~(val by wach.w) to-inputs) (turn ~(val by wach.w) to-inputs)
@ -139,19 +139,20 @@
:: ::
++ single-random-draw ++ single-random-draw
|= is=(list input) |= is=(list input)
^- (unit (list input)) ^- (unit [=vbytes (list input)])
=/ rng ~(. og eny) =/ rng ~(. og eny)
=/ target (add targ (mul feyb base-weight)) :: add base fees to target =/ target (add targ (mul feyb base-weight)) :: add base fees to target
=| [select=(list input) total=sats:btc] =| [select=(list input) total=sats:btc]
|- ?~ is ~ |- ?: =(~ is) ~
=^ n rng (rads:rng (lent is)) =^ n rng (rads:rng (lent is))
=/ i=input (snag n `(list input)`is) =/ i=input (snag n is)
=/ net-val (net-value value.utxo.i) =/ net-val (net-value value.utxo.i)
=? select (gth net-val 0) [i select] :: select if net-value > 0 =? select (gth net-val 0) [i select] :: select if net-value > 0
=/ new-total (add total net-val) =/ new-total (add total net-val)
?: (gte new-total target) `select ?: (gte new-total target)
`[(total-vbytes select) select]
%= $ %= $
is (oust [n 1] `(list input)`is) is (oust [n 1] is)
total new-total total new-total
== ==
:: ::