Skip to content

Commit

Permalink
convert payment addr to hex & make payment hash copyable
Browse files Browse the repository at this point in the history
  • Loading branch information
bgptr committed Aug 17, 2021
1 parent 10788f5 commit ed97e24
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
Expand Up @@ -92,7 +92,13 @@ const DecodedPayRequest = ({
<label>
<T id="ln.paymentsTab.paymentHashLabel" m="Payment Hash" />:
</label>
{decoded.paymentHash}
<div className={styles.paymentHashContainer}>
<span className={styles.paymentHash}>{decoded.paymentHash}</span>
<CopyToClipboard
textToCopy={decoded.paymentHash}
ButtonComponent={SmallButton}
/>
</div>
</div>

<DetailsTable
Expand Down
Expand Up @@ -70,12 +70,24 @@
grid-row-gap: 5px;
margin-top: 15px;
line-height: 16px;
align-items: center;
}

.dataGrid label {
padding-right: 10px;
margin: 0;
}

.details {
margin-top: 30px;
}

.paymentHashContainer {
display: flex;
flex-direction: row;
align-items: center;
}

.paymentHash {
padding-right: 10px;
}
Expand Up @@ -20,7 +20,7 @@ export const getDecodedPayRequestDetails = (decoded) => {
label: (
<T id="ln.decodedPayRequestDetails.paymentAddr" m="Payment Address" />
),
value: decoded.paymentAddr,
value: decoded.paymentAddrHex,
truncate: 40
}
];
Expand Down
3 changes: 3 additions & 0 deletions app/components/views/LNPage/SendTab/hooks.js
Expand Up @@ -126,6 +126,9 @@ export function useSendTab(setTimeout) {
if (!expired) {
setTimeout(checkExpired, timeToExpire + 1000);
}
resp.paymentAddrHex = Buffer.from(resp.paymentHash, "base64").toString(
"hex"
);
setDecodedPayRequest(resp);
setDecodingError(null);
setExpired(expired);
Expand Down
3 changes: 2 additions & 1 deletion test/unit/components/views/LNPage/SendTab.spec.js
Expand Up @@ -174,6 +174,7 @@ const mockValidDecodedPayRequest = {
cltvExpiry: 80,
routeHintsList: [],
paymentAddr: "mock-payment-address",
paymentAddrHex: "9a8724fa96b299e9edfa16ac",
numMAtoms: 1000000000,
featuresMap: [
[
Expand Down Expand Up @@ -271,7 +272,7 @@ test("test send form with valid lightning request", async () => {
`Fallback Address:${mockValidDecodedPayRequest.fallbackAddr}`
);
expect(screen.getByText("Payment Address:").parentNode.textContent).toMatch(
`Payment Address:${mockValidDecodedPayRequest.paymentAddr}`
`Payment Address:${mockValidDecodedPayRequest.paymentAddrHex}`
);

// close details
Expand Down

0 comments on commit ed97e24

Please sign in to comment.