mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-28 19:55:53 +03:00
btc: fix history bug
This commit is contained in:
parent
36f8167986
commit
a791a2edf1
@ -268,6 +268,12 @@
|
||||
=. scans (~(del by scans) [xpub.comm %0])
|
||||
=. scans (~(del by scans) [xpub.comm %1])
|
||||
=. walts (~(del by walts) xpub.comm)
|
||||
=. history
|
||||
%- ~(rep by history)
|
||||
|= [[=txid =hest] out=_history]
|
||||
?: =(xpub.hest xpub.comm)
|
||||
(~(del by out) txid)
|
||||
out
|
||||
:_ state
|
||||
[give-initial]~
|
||||
::
|
||||
@ -798,12 +804,21 @@
|
||||
|^
|
||||
=/ h (~(get by history) txid.ti)
|
||||
=. ahistorical-txs (~(del in ahistorical-txs) txid.ti)
|
||||
=/ our-addrs=(set address) :: all our addresses in inputs/outputs of tx
|
||||
=/ our-inputs=(set address)
|
||||
%- silt
|
||||
%+ skim
|
||||
%+ turn (weld inputs.ti outputs.ti)
|
||||
%+ turn inputs.ti
|
||||
|=(=val:tx address.val)
|
||||
is-our-address
|
||||
=/ our-outputs=(set address)
|
||||
%- silt
|
||||
%+ skim
|
||||
%+ turn outputs.ti
|
||||
|=(=val:tx address.val)
|
||||
is-our-address
|
||||
=/ our-addrs=(set address) :: all our addresses in inputs/outputs of tx
|
||||
(~(uni in our-inputs) our-outputs)
|
||||
::
|
||||
=/ addr-info-cards=(list card)
|
||||
%+ turn ~(tap in our-addrs)
|
||||
|= a=address
|
||||
@ -827,7 +842,7 @@
|
||||
=/ =xpub
|
||||
xpub.w:(need (address-coords:bl (snag 0 ~(tap in our-addrs)) ~(val by walts)))
|
||||
?~ h :: addresses in wallets, but tx not in history
|
||||
=/ new-hest=hest (mk-hest xpub our-addrs)
|
||||
=/ new-hest=hest (mk-hest xpub our-inputs our-outputs)
|
||||
=. history (~(put by history) txid.ti new-hest)
|
||||
:_ state
|
||||
:_ addr-info-cards
|
||||
@ -844,14 +859,14 @@
|
||||
::
|
||||
++ mk-hest
|
||||
:: has tx-info
|
||||
|= [=xpub:bc our-addrs=(set address)]
|
||||
|= [=xpub:bc our-inputs=(set address) our-outputs=(set address)]
|
||||
^- hest
|
||||
:* xpub
|
||||
txid.ti
|
||||
confs.ti
|
||||
recvd.ti
|
||||
(turn inputs.ti |=(v=val:tx (is-our-ship our-addrs v)))
|
||||
(turn outputs.ti |=(v=val:tx (is-our-ship our-addrs v)))
|
||||
(turn inputs.ti |=(v=val:tx (is-our-ship our-inputs v)))
|
||||
(turn outputs.ti |=(v=val:tx (is-our-ship our-outputs v)))
|
||||
~
|
||||
==
|
||||
::
|
||||
|
@ -23,14 +23,19 @@ export default class Transaction extends Component {
|
||||
render() {
|
||||
const pending = (!this.props.tx.recvd);
|
||||
|
||||
const weSent = _.find(this.props.tx.inputs, (input) => {
|
||||
let weSent = _.find(this.props.tx.inputs, (input) => {
|
||||
return (input.ship === window.ship);
|
||||
});
|
||||
let weRecv = this.props.tx.outputs.every((output) => {
|
||||
return (output.ship === window.ship)
|
||||
});
|
||||
|
||||
let action = (weSent) ? "sent" : "recv";
|
||||
let action =
|
||||
(weRecv) ? "recv" :
|
||||
(weSent) ? "sent" : "recv";
|
||||
|
||||
let counterShip;
|
||||
let counterAddress;
|
||||
let counterShip = null;
|
||||
let counterAddress = null;
|
||||
let value;
|
||||
let sign;
|
||||
|
||||
@ -44,16 +49,26 @@ export default class Transaction extends Component {
|
||||
sign = '-'
|
||||
}
|
||||
else if (action === "recv") {
|
||||
let incoming = _.find(this.props.tx.outputs, (output) => {
|
||||
return (output.ship === window.ship);
|
||||
});
|
||||
value = incoming.val.value;
|
||||
value = _.reduce(this.props.tx.outputs, (sum, output) => {
|
||||
if (output.ship === window.ship) {
|
||||
return sum + output.val.value;
|
||||
} else {
|
||||
return sum;
|
||||
}
|
||||
}, 0);
|
||||
|
||||
let counter = _.find(this.props.tx.inputs, (input) => {
|
||||
return (input.ship !== window.ship);
|
||||
});
|
||||
counterShip = _.get(counter, 'ship', null);
|
||||
counterAddress = _.get(counter, 'val.address', null);
|
||||
|
||||
if (weSent && weRecv) {
|
||||
counterAddress = _.get(_.find(this.props.tx.inputs, (input) => {
|
||||
return (input.ship === window.ship);
|
||||
}), 'val.address', null);
|
||||
} else {
|
||||
let counter = _.find(this.props.tx.inputs, (input) => {
|
||||
return (input.ship !== window.ship);
|
||||
});
|
||||
counterShip = _.get(counter, 'ship', null);
|
||||
counterAddress = _.get(counter, 'val.address', null);
|
||||
}
|
||||
sign = '';
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user