# Tesla Distributed Charge



## andyschroder (Nov 19, 2019)

I wanted to share a project that I was able to get kicked off thanks to model3dbc.

http://andyschroder.com/DistributedCharge/

More to come!


----------



## JasonF (Oct 26, 2018)

I think that system is way too complex, failure-prone, and insecure. Someone could capture the Bitcoin wallet info from the car and re-use it elsewhere. The internet or wifi could go down 5 minutes after you begin charging, causing charging to stop. The PC or other comms equipment could crash, also stopping charging immediately. Or you could plug into an unscrupulous charger owner that advertises a low rate for charging, but then 15 seconds into the charge cycle the fee could go way up - and you would have walked away by then, so you wouldn't know it until your Bitcoin account is suddenly cleaned out.


----------



## garsh (Apr 4, 2016)

OTOH, it looks like the software could be updated to allow controlling & restricting charging based on all sorts of criteria.

Time limits
Limit to only your friends/family
Accept credit card payments
Accept paypal


----------



## JasonF (Oct 26, 2018)

Maybe, but the design looked to me like it's intended to make an individual bitcoin transaction for each kW.


----------



## andyschroder (Nov 19, 2019)

JasonF said:


> I think that system is way too complex, failure-prone, and insecure. Someone could capture the Bitcoin wallet info from the car and re-use it elsewhere. The internet or wifi could go down 5 minutes after you begin charging, causing charging to stop. The PC or other comms equipment could crash, also stopping charging immediately. Or you could plug into an unscrupulous charger owner that advertises a low rate for charging, but then 15 seconds into the charge cycle the fee could go way up - and you would have walked away by then, so you wouldn't know it until your Bitcoin account is suddenly cleaned out.


The Bitcoin wallet is not stored on the car. The lnd node (which holds the bitcoin wallet) is placed remotely and is communicated with securely from the car. The authentication of this secure connection uses Macaroons (https://github.com/lightningnetwork/lnd/issues/20), which have the potential for many types of limits and restrictions. Even if the car is broken into and this Macaroons is stolen, because of the limits that the Macaroons could have on it, risk is limited and the Macaroons can be invalidated and a new one regenerated.

Internet connection is a concern, but how else do you propose communicating? More reliable internet could be provided by the charge unit to the buyer. The seller is motivated to ensure reliable internet to customers, otherwise they will lose revenue.

If you are worried about PC reliablitiy or comms, you should switch back to a carborated gasoline engine, or a diesel with a mechanical injector pump.

The car has a maximum sale rate that it will limit to (https://github.com/AndySchroder/DistributedCharge/blob/master/car.py#L64, https://github.com/AndySchroder/DistributedCharge/blob/master/car.py#L368, https://github.com/AndySchroder/DistributedCharge/blob/master/car.py#L421).

Definitely variable rates could be implemented. That is something I would like to see.

However, you do have a point that it would be annoying if a seller jerks the rates around and then you are assuming you'll come back to a full charge, but find out your car just stopped paying because the rates were too high. That problem I think would need to be solved with a rating system that buyers can participate in. There are lots of other things that buyers could rate a seller on besides how much variability they have in their rates.


----------



## andyschroder (Nov 19, 2019)

JasonF said:


> Maybe, but the design looked to me like it's intended to make an individual bitcoin transaction for each kW.


The current design pays for 25 W*hours with each bitcoin payment over the lightning network. A bitcoin transaction per kW makes no sense as kW is a unit of power and not energy.


----------



## andyschroder (Nov 19, 2019)

garsh said:


> OTOH, it looks like the software could be updated to allow controlling & restricting charging based on all sorts of criteria.
> 
> Time limits
> Limit to only your friends/family
> ...


Lots of limits can be very useful.

I have no intention to support credit cards or paypal. First off, I don't think they could support these high of transaction rates. Second, the purpose is to eliminate high fees and charge backs, and preserve financial privacy. Third, I'm not interested in supporting inflationary monetary systems.

However, based on the license I have released the source code with (https://github.com/AndySchroder/DistributedCharge#license), anyone can change it however they want.


----------



## JWardell (May 9, 2016)

I love it. Another project I planned in the months of scheming before my 3 arrived was to install a charger but lock or significantly reduce its charge current for public use and then allow full current for myself or a with some code. It seems you certainly have the ability to do something like that, and go one step further with charging via bitcoin. Great idea.


----------



## andyschroder (Nov 19, 2019)

If your car and wall unit use the same lnd node (bitcoin lightning network node), you may be able to stream payments to yourself and not have any transaction fees. Then all you'd be wasting is a tiny amount of network bandwidth. I'll have to check if paying to yourself with 0 lightning network hops is possible. Doing all that I've done with the lightning network just to pay yourself is obviously an extremely overly complicated setup, but if you do it, you will have the benefit of your car supporting any other wall unit that uses my setup, and at the same time, anyone else that has their car setup to make payments through this protocol can use your wall unit and both of you will benefit. Basically, both your car and your wall unit would be setup for a larger, more general network (if my idea every gains any traction).

With all that being said, I think https://github.com/ngardiner/TWCManager has the ability to whitelist certain VIN numbers, since the charge port SWCAN broadcasts the VIN number to every wall unit you plug into (which I think is a huge, inappropriate privacy leak on Tesla's part), and then the TWC translates the CAN VIN number message to the RS-485 port, which is what TWCManager uses. That's actually probably all you need for what you're asking for, but it's not cryptographically secure like my system is. Anyone could spoof a VIN number on the charge port SW CAN bus.


----------



## garsh (Apr 4, 2016)

andyschroder said:


> the charge port SWCAN broadcasts the VIN number to every wall unit you plug into (which I think is a huge, inappropriate privacy leak on Tesla's part)


VINs are displayed publicly and visually through the windshield of every vehicle, so it's not that big of a deal.

Setting up a payment system like this, however, will allow a wall connector owner to tie a particular VIN to a particular bitcoin account, which is a bigger reduction in privacy.


----------



## andyschroder (Nov 19, 2019)

It is true that VIN numbers are displayed publicly on the windshield, but they are hard to read with a camera, and can be blocked by the owner. License plates are still clearly visible though in most lightning conditions.

Bitcoin has no notion of accounts, only public addresses and unspent outputs. The bitcoin lightning network also has no notion of accounts, only nodes. The lightning network onion routes payments, so there is no way to tie the payments received by the wall unit back to a particular unspent output or lightning network node. So, even though the VIN number can be logged by the wall unit, it can't be tied to where the payment came from.

I hope tesla will decide to stop broadcasting the VIN number on the charge port SW CAN. It is really a bad design. All we can do is make that point known at this time. Someone could also create a man in the middle device on the charge port SW CAN that segments, filters this out, and then relays messages. Currently my system just taps into the bus.


----------

